Skip to content

Override -arch For Stdlib Targets #41119

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

Closed
wants to merge 1 commit into from

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Feb 1, 2022

On Apple Silicon hosts, CMake defaults OSX_ARCHITECTURES to the
host arch. When our cmake later explicitly provides -arch, clang
interprets two -arch flags as a directive to emit fat object files. When we go
to lipo them together, the host arches in the object files collide
and the build goes kaput.

In the same vein as #41059, stamp out the last place we were explicitly passing -arch.

On Apple Silicon hosts, CMake defaults OSX_ARCHITECTURES to the
host arch. When the cmake later explicitly provides -arch, clang
interprets this as a directive to emit fat object files. When we go
to lipo them together, the host arches in the object files collide
and the build goes kaput.
@CodaFi CodaFi requested a review from edymtt February 1, 2022 05:45
@@ -1203,6 +1202,10 @@ function(add_swift_target_library_single target name)

list(APPEND library_search_directories "${SWIFT_SDK_${sdk}_ARCH_${arch}_PATH}/usr/lib/swift")

# Override -arch on macOS. This is crucial for Apple Silicon, where CMake forces
# the *host* architecture to appear as the argument to -arch otherwise.
set_property(TARGET ${target} PROPERTY OSX_ARCHITECTURES "${SWIFTLIB_SINGLE_ARCHITECTURE}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edymtt I'm not sure if this is the appropriate place to put it, but we aren't passing target down to _add_target_variant_c_compile_link_flags AFAICT so it's a bit tough to move there.

@CodaFi
Copy link
Contributor Author

CodaFi commented Feb 1, 2022

@swift-ci test

@CodaFi
Copy link
Contributor Author

CodaFi commented Feb 1, 2022

Eric has a better answer here.

@CodaFi CodaFi closed this Feb 1, 2022
@CodaFi CodaFi deleted the an-apple-silicon-a-day branch February 1, 2022 23:45
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

Successfully merging this pull request may close these issues.

1 participant