Skip to content

libCYaml.a has wrong arch on M1 Mac #1167

@azarovalex

Description

@azarovalex

As part of the toolchain build process on M1 mac, the build-toolchain script runs the next 2 commands:

build-script-helper.py build and build-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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions