Skip to content

CMake: Specify modern Cxx interop flag when building SwiftCompilerSources #72033

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SwiftCompilerSources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,17 @@ function(add_swift_compiler_modules_library name)
"DEPENDS"
${ARGN})

# Prior to 5.9, we have to use the experimental flag for C++ interop.
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think CMAKE_Swift_COMPILER_VERSION is valid unless we're building with hosttools. Last time I checked it was empty when bootstrapping is enabled since we aren't using CMake's built-in Swift support in that case. @eeckstein knows more about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps this can be further refined to check something that indicates whether we are bootstrapping and specify -cxx-interoperability-mode=default when we are. Lmk if that sounds reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would make sense to me!

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with it. Bootstrapping is on life support and not even checked on the official CI: hosttools are de facto required at this point, with bootstrapping soon to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, given that assessment of bootstrapping, the fact that CI passed, and that this approach matches ASTGen I'm inclined to land it as-is. I think the failure case is just that we pass the deprecated flag when bootstrapping?

set(cxx_interop_flag "-enable-experimental-cxx-interop")
else()
set(cxx_interop_flag "-cxx-interoperability-mode=default")
endif()

set(swift_compile_options
"-color-diagnostics"
"-Xfrontend" "-validate-tbd-against-ir=none"
"-Xfrontend" "-enable-experimental-cxx-interop"
"${cxx_interop_flag}"
"-Xfrontend" "-disable-target-os-checking"
"-Xcc" "-std=c++17"
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
Expand Down