-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[CMake] Set CMAKE_{C|CXX}_COMPILER_TARGET for swift-syntax #78523
Conversation
@swift-ci Please smoke test |
@swift-ci Please build toolchain |
agree with your suggestion |
a34a6e2
to
7a50253
Compare
swift-syntax now have '.c' sources. We need to set this for cross-compiling.
7a50253
to
9a881cb
Compare
swiftlang/swift-syntax#2934 |
swiftlang/swift-syntax#2934 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain about needing CMAKE_SYSTEM_PROCESSOR
here or if it is fine to just use CMAKE_C_COMPILER_TARGET
/CMAKE_CXX_COMPILER_TARGET
for this?
If there isn't a complaint from CMake about Swift not supporting CMAKE_OSX_ARCHITECTURES
, I don't care too much, this should be fine.
@@ -8,6 +8,10 @@ endif() | |||
|
|||
# Build swift-syntax libraries with FetchContent. | |||
function(includeSwiftSyntax) | |||
set(CMAKE_SYSTEM_PROCESSOR ${SWIFT_HOST_VARIANT_ARCH}) | |||
set(CMAKE_OSX_ARCHITECTURES ${SWIFT_HOST_VARIANT_ARCH}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may trip up Swift since CMake doesn't support using CMAKE_OSX_ARCHITECTURES
with Swift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my local testing, not setting CMAKE_OSX_ARCHITECTURES
resulted incorrect -arch
in C compiler arguments, so this seems to be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain about needing CMAKE_SYSTEM_PROCESSOR here or if it is fine to just use CMAKE_C_COMPILER_TARGET/CMAKE_CXX_COMPILER_TARGET for this?
Specifying CMAKE_SYSTEM_PROCESSOR
will explicitly put you into the cross-compilation mode (CMAKE_CROSSCOMPILING
), so that seems reasonable to do.
swift-syntax now have '.c' sources. We need to set this for cross-compiling.