Skip to content

Commit 3b80a76

Browse files
authored
[cmake] explicitly set linker language for static libraries (#37642)
This mimicks the same logic used for shared libraries a few lines above. This will allow the minimal freestanding stdlib to build with #37511, solving errors like ``` ninja: error: build.ninja:4213: multiple rules generate stdlib/public/SwiftOnoneSupport/CMakeFiles/ swiftSwiftOnoneSupport-freestanding-x86_64-static.dir/__/__/ linker-support/magic-symbols-for-install-name.c.o [-w dupbuild=err] ``` Addresses rdar://78336832
1 parent c3638af commit 3b80a76

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,16 @@ function(_add_swift_target_library_single target name)
13431343
${library_search_directories})
13441344
target_link_libraries("${target_static}" PRIVATE
13451345
${SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES})
1346+
1347+
# Force executables linker language to be CXX so that we do not link using the
1348+
# host toolchain swiftc.
1349+
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "ANDROID")
1350+
set_property(TARGET "${target_static}" PROPERTY
1351+
LINKER_LANGUAGE "C")
1352+
else()
1353+
set_property(TARGET "${target_static}" PROPERTY
1354+
LINKER_LANGUAGE "CXX")
1355+
endif()
13461356
endif()
13471357

13481358
# Do not add code here.

0 commit comments

Comments
 (0)