Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when compiling on CI: Must not detect more than one architecture #2469

Open
7sharp9 opened this issue Feb 14, 2025 · 4 comments
Open

Comments

@7sharp9
Copy link

7sharp9 commented Feb 14, 2025

Hi, Im getting an error when running on GI while building a mac architecture:
|

Run cmake --build Builds --config Release --parallel 4
  cmake --build Builds --config Release --parallel 4
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    BUILD_TYPE: Release
    BUILD_DIR: Builds
    DISPLAY: :0
    HOMEBREW_NO_INSTALL_CLEANUP: 1
    SCCACHE_GHA_ENABLED: true
    SCCACHE_CACHE_MULTIARCH: 1
    IPP_DIR: C:\Program Files (x86)\Intel\oneAPI\ipp\latest\lib\cmake\ipp
    MD_APPLE_SDK_ROOT: /Applications/Xcode_16.2.app
    SCCACHE_PATH: /Users/runner/hostedtoolcache/sccache/0.9.1/arm64/sccache
    ACTIONS_CACHE_URL: https://acghubeus1.actions.githubusercontent.com/gv5Ziv9LRLvK3r7wA0NxS1PnmS1Rp48kYoB753XWAcX7CS7FRq/
    ACTIONS_RUNTIME_TOKEN: ***
[0/2] Re-checking globbed directories...
[1/620] Building CXX object _deps/highway-build/CMakeFiles/hwy.dir/hwy/aligned_allocator.cc.o
FAILED: _deps/highway-build/CMakeFiles/hwy.dir/hwy/aligned_allocator.cc.o 
sccache /Applications/Xcode_16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DHWY_STATIC_DEFINE -DNDEBUG -DTOOLCHAIN_MISS_ASM_HWCAP_H -DTOOLCHAIN_MISS_SYS_AUXV_H -I/Users/runner/work/StudioStandard/StudioStandard/Builds/_deps/highway-src -O3 -DNDEBUG -O3 -mcpu=apple-m1 -ffp-contract=fast -std=c++17 -arch arm64 -arch x86_64 -isysroot /Applications/Xcode_16.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -mmacosx-version-min=11.0 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\" -fmerge-all-constants -Wall -Wextra -Wconversion -Wsign-conversion -Wvla -Wnon-virtual-dtor -Wcast-align -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wfor-loop-analysis -Wgnu-redeclared-enum -Winfinite-recursion -Wself-assign -Wstring-conversion -Wtautological-overlap-compare -Wthread-safety-analysis -Wundefined-func-template -fno-cxx-exceptions -fno-slp-vector
In file included from /Users/runner/work/StudioStandard/StudioStandard/Builds/_deps/highway-src/hwy/aligned_allocator.cc:16:
In file included from /Users/runner/work/StudioStandard/StudioStandard/Builds/_deps/highway-src/hwy/aligned_allocator.h:32:
In file included from /Users/runner/work/StudioStandard/StudioStandard/Builds/_deps/highway-src/hwy/base.h:29:
/Users/runner/work/StudioStandard/StudioStandard/Builds/_deps/highway-src/hwy/detect_compiler_arch.h:329:2: error: "Must not detect more than one architecture"
  329 | #error "Must not detect more than one architecture"
      |  ^
1 error generated.

Did I miss something I need to do on the CI?

@7sharp9 7sharp9 changed the title Issue when compiling on CI issue: Must not detect more than one architecture Issue when compiling on CI: Must not detect more than one architecture Feb 14, 2025
@johnplatts
Copy link
Contributor

johnplatts commented Feb 15, 2025

The issue is that the __x86_64__ and __aarch64__ macros are both defined, and only one of the two macros should be defined.

The Highway C++ files have to be compiled twice if you want to target for both x86_64 and ARM64 on macOS, once for x86_64 and once for ARM64.

One way to configure CMake to build for both x86_64 and ARM64 is to pass in the -G Xcode -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" options to cmake when configuring to build Google Highway for macOS on both x86_64 and ARM64. The -G Xcode -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" options will cause CMake to generate XCode project files that will target both x86_64 and ARM64.

If Google Highway is configured to be built for both x86_64 and ARM64 using XCode project files, cmake --build will invoke xcodebuild, which will take care of invoking the C++ compiler twice for each Google Highway C++ file, once for x86_64 and once for ARM64, which should fix the errors that you are encountering with building for both x86_64 and ARM64 on macOS.

@johnplatts
Copy link
Contributor

johnplatts commented Feb 15, 2025

@7sharp9 I did successfully build Google Highway for macOS for both x86_64 and ARM64 using a GitHub Workflow, and the results of that workflow run can be found at https://github.com/johnplatts/jep_google_highway/actions/runs/13345004943/job/37274387258.

Here is the GitHub workflow that I used to build Google Highway for macOS (and this workflow is not part of the Google Highway master branch):
https://github.com/johnplatts/jep_google_highway/blob/793e5c9cbef72a6984fd7dec934bbbeaa5143a13/.github/workflows/build_test.yml

@7sharp9
Copy link
Author

7sharp9 commented Feb 15, 2025

@johnplatts Im guessing the workflow Im using has never built highway before. When I build locally my cmake contains:

set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)

And highway is pulled in via CPMAddPackage:

CPMAddPackage(
        NAME highway
        GITHUB_REPOSITORY google/highway
        GIT_TAG d547f91bc94deffe8aafa044934e4fd78354493f
        OPTIONS "HWY_ENABLE_EXAMPLES OFF" "HWY_ENABLE_INSTALL OFF" "HWY_ENABLE_TESTS OFF" "HWY_FORCE_STATIC_LIBS ON"

That succesfully created a universal lib for highway etc an my local machine.

I'll have a look at the workflow you provided, thanks!

@7sharp9
Copy link
Author

7sharp9 commented Feb 15, 2025

@johnplatts I think it's to do with the -G Xcode with Ninja it fails with the error I mentioned above but -G Xcode doesnt. It seems to be really tricky to get per architecture compiler optimisations. e.g
Setting x64 specific: -march=x86-64-v2 -maes -mpclmul
And the same for arm: -mcpu=apple-m1 -ffp-contract=fast

I trie the -Xarch_x86_64 but they dont seem to work but there is an Xcode specific way to do this I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants