Skip to content

Commit f1a7047

Browse files
authored
[CMake] Pass the specified c++ stdlib to swiftc internal clang (swiftlang#84668)
On linux if llvm is built with `LLVM_ENABLE_LIBCXX` or `-stdlib=libc++` it is not used by the internal swift clang and causes linkage errors. It may also apply to `-FPIC` or `-FPIE` flags <!-- If this pull request is targeting a release branch, please fill out the following form: https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1 Otherwise, replace this comment with a description of your changes and rationale. Provide links to external references/discussions if appropriate. If this pull request resolves any GitHub issues, link them like so: Resolves <link to issue>, resolves <link to another issue>. For more information about linking a pull request to an issue, see: https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue --> <!-- Before merging this pull request, you must run the Swift continuous integration tests. For information about triggering CI builds via @swift-ci, see: https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci Thank you for your contribution to Swift! -->
1 parent 35a0a93 commit f1a7047

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ function(add_swift_compiler_modules_library name)
109109
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
110110
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
111111

112+
# Pass the declared C++ stdlib for swift's internal clang.
113+
set(swift_compile_cxx_flags ${CMAKE_CXX_FLAGS})
114+
separate_arguments(swift_compile_cxx_flags)
115+
foreach(cxx_flag ${swift_compile_cxx_flags})
116+
if (cxx_flag MATCHES "^-stdlib=")
117+
list(APPEND swift_compile_options "-Xcc" ${cxx_flag})
118+
break()
119+
endif()
120+
endforeach()
121+
112122
if (NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
113123
if(SWIFT_MIN_RUNTIME_VERSION)
114124
list(APPEND swift_compile_options

0 commit comments

Comments
 (0)