You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both these commands contain a --cross-compile-hosts macosx-x86_64 flag, so I expect artifacts for both arm64 and x86 to be built.
The arm one builds as expected, but x86 build crashes with an error:
Undefined symbols for architecture x86_64:
"_yaml_document_end_event_initialize", referenced from:
_$s4Yams7EmitterC9serialize4nodeyAA4NodeO_tKF in libYams.a(Emitter.swift.o)
"_yaml_document_start_event_initialize", referenced from:
_$s4Yams7EmitterC9serialize4nodeyAA4NodeO_tKF in libYams.a(Emitter.swift.o)
What's interesting is that all symbols start with _yams and running lipo -info for other dependencies return x86_64, only libCYaml.a return arm64.
Moreover, if I open dependencies/yams/build.ninja and manually replace all occurrences of -arch arm64 with -arch x86_64, everything builds as expected (until next cmake command overwrites everything).
Looks like there is an issue with CMakeLists somewhere, maybe even in Yams repo itself, I'll appreciate any help with this issue.
The text was updated successfully, but these errors were encountered:
azarovalex
changed the title
libCYaml.a builds with wrong arch on M1 MaclibCYaml.a has wrong arch on M1 Mac
Sep 3, 2022
So, the best fix I found so far is to force libCYaml.a to be built as a fat binary with both arm64 and x86_64 inside the Yams repo by adding set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
at the top of Sources/CYaml/CMakeLists.txt.
Without it generated build.ninja for CYaml sources will contain -arch arm64 flag and results in a arm64 binary when x86_64 is expected, even though we explicitly pass -DCMAKE_C_FLAGS=-target arm64-apple-macosx10.15 to cmake.🤔
This is a workaround unblockes me on building the swift toolchain on M1, but we need a better fix somewhere in build-script-helper.py, because current CMAKE_C_FLAGS it passes isn't enough to convince cmake to generate right flags for libCYaml.a. I am no expert in cmake, so idk how to do this.
@edymtt Can you take a look at this problem, it currently blocks toolchain build on M1 macs.
It is probably one line fix here, but I cannot add CMAKE_OSX_ARCHITECTURES since Yams has Swift sources as well and cmake doesn't allow using it.
As part of the toolchain build process on M1 mac, the
build-toolchain
script runs the next 2 commands:build-script-helper.py build
andbuild-script-helper.py install
Full commands
swift-driver/Utilities/build-script-helper.py build --package-path /Users/azarovalex/Developer/OpenSource/swift-project/swift-driver --build-path /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/swiftdriver-macosx-arm64 --configuration release --toolchain /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/intermediate-install/macosx-arm64/Library/Developer/Toolchains/swift-LOCAL-2022-09-03-a.xctoolchain/usr --ninja-bin /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/ninja-build/ninja --cmake-bin /opt/homebrew/bin/cmake --cross-compile-hosts macosx-x86_64
swift-driver/Utilities/build-script-helper.py install --package-path /Users/azarovalex/Developer/OpenSource/swift-project/swift-driver --build-path /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/swiftdriver-macosx-arm64 --configuration release --toolchain /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/intermediate-install/macosx-arm64/Library/Developer/Toolchains/swift-LOCAL-2022-09-03-a.xctoolchain/usr --ninja-bin /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/ninja-build/ninja --cmake-bin /opt/homebrew/bin/cmake --cross-compile-hosts macosx-x86_64 --prefix /Users/azarovalex/Developer/OpenSource/swift-project/build/buildbot_osx/intermediate-install/macosx-arm64/Library/Developer/Toolchains/swift-LOCAL-2022-09-03-a.xctoolchain/usr
Both these commands contain a
--cross-compile-hosts macosx-x86_64
flag, so I expect artifacts for both arm64 and x86 to be built.The arm one builds as expected, but x86 build crashes with an error:
What's interesting is that all symbols start with
_yams
and runninglipo -info
for other dependencies returnx86_64
, onlylibCYaml.a
returnarm64
.Moreover, if I open
dependencies/yams/build.ninja
and manually replace all occurrences of-arch arm64
with-arch x86_64
, everything builds as expected (until next cmake command overwrites everything).Looks like there is an issue with CMakeLists somewhere, maybe even in Yams repo itself, I'll appreciate any help with this issue.
The text was updated successfully, but these errors were encountered: