Skip to content

Commit 6b77409

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents f3ff4c0 + 8839741 commit 6b77409

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,8 @@ function(_add_variant_link_flags)
463463
list(APPEND result "-Wl,-Bsymbolic")
464464
elseif("${LFLAGS_SDK}" STREQUAL "ANDROID")
465465
list(APPEND link_libraries "dl" "log" "atomic" "icudataswift" "icui18nswift" "icuucswift")
466-
# We provide our own C++ below, so we ask the linker not to do it. However,
467-
# we need to add the math library, which is linked implicitly by libc++.
468-
list(APPEND result "-nostdlib++" "-lm")
466+
# We need to add the math library, which is linked implicitly by libc++
467+
list(APPEND result "-lm")
469468
if("${LFLAGS_ARCH}" MATCHES armv7)
470469
set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a")
471470
elseif("${LFLAGS_ARCH}" MATCHES aarch64)
@@ -1371,8 +1370,16 @@ function(_add_swift_library_single target name)
13711370
${SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES})
13721371
endif()
13731372

1374-
set_property(TARGET "${target}" PROPERTY
1373+
# NOTE(compnerd) use the C linker language to invoke `clang` rather than
1374+
# `clang++` as we explicitly link against the C++ runtime. We were previously
1375+
# actually passing `-nostdlib++` to avoid the C++ runtime linkage.
1376+
if(SWIFTLIB_SINGLE_SDK STREQUAL ANDROID)
1377+
set_property(TARGET "${target}" PROPERTY
1378+
LINKER_LANGUAGE "C")
1379+
else()
1380+
set_property(TARGET "${target}" PROPERTY
13751381
LINKER_LANGUAGE "CXX")
1382+
endif()
13761383

13771384
if(target_static)
13781385
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY

stdlib/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ include(AddSwiftStdlib)
77

88
# Create convenience targets for the Swift standard library.
99

10+
# NOTE(compnerd) this will pass the *build* configuration to the *host*
11+
# libraries. Explicitly indicate to CMake that it should **NOT** track the
12+
# implicit language runtimes. This can go away once we migrate to an external
13+
# project with its own configure with the CMAKE_SYSTEM_NAME set rather than
14+
# using the custom cross-compilation solution
15+
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
16+
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
17+
18+
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "")
19+
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
20+
1021
# NOTE(compnerd) save the original compiler for the host swiftReflection that
1122
# we build
1223
set(HOST_CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER})

0 commit comments

Comments
 (0)