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

[CMake] Set CMAKE_{C|CXX}_COMPILER_TARGET for swift-syntax #78523

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jan 9, 2025

swift-syntax now have '.c' sources. We need to set this for cross-compiling.

@rintaro
Copy link
Member Author

rintaro commented Jan 9, 2025

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Jan 9, 2025

@swift-ci Please build toolchain

@DF0ster
Copy link

DF0ster commented Jan 9, 2025

agree with your suggestion

@rintaro rintaro force-pushed the swift-syntax-c-target branch from a34a6e2 to 7a50253 Compare January 9, 2025 18:18
swift-syntax now have '.c' sources. We need to set this for
cross-compiling.
@rintaro rintaro force-pushed the swift-syntax-c-target branch from 7a50253 to 9a881cb Compare January 9, 2025 18:20
@rintaro
Copy link
Member Author

rintaro commented Jan 9, 2025

swiftlang/swift-syntax#2934
@swift-ci Please smoke test

@rintaro rintaro requested review from bnbarham and etcwilde January 9, 2025 18:20
@rintaro
Copy link
Member Author

rintaro commented Jan 9, 2025

swiftlang/swift-syntax#2934
@swift-ci Please build toolchain

Copy link
Contributor

@etcwilde etcwilde left a 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})
Copy link
Contributor

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.

Copy link
Member Author

@rintaro rintaro Jan 9, 2025

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.

Copy link
Member

@compnerd compnerd left a 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.

@rintaro rintaro merged commit aa2090b into swiftlang:main Jan 9, 2025
5 of 6 checks passed
@rintaro rintaro deleted the swift-syntax-c-target branch January 9, 2025 23:07
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.

4 participants