Skip to content

Commit 4b1fe09

Browse files
authored
[libc++] Simplify the conditions for generating a linker script (#73151)
We really shouldn't be depending on far away configuration options like LLVM_HAVE_LINK_VERSION_SCRIPT here. This patch simplifies the enablement of the linker scripts and as a result gets rid of an undesirable dependency on HandleLLVMOptions.cmake. As a drive-by, the patch also stops taking into account whether Python3 is available. This should have no bearing on whether we generate a linker script or not, which is required for correctness. If someone tries to build libc++ and generate a linker script but Python3 is not available, they should get an error instead of silently getting an incorrect installation of the library.
1 parent 53578e5 commit 4b1fe09

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

libcxx/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,18 @@ option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
251251

252252
# Generate and install a linker script inplace of libc++.so. The linker script
253253
# will link libc++ to the correct ABI library. This option is on by default
254-
# on UNIX platforms other than Apple unless
255-
# 'LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY' is on. This option is also
256-
# disabled when the ABI library is not specified or is specified to be "none".
257-
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
258-
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
259-
AND NOT LIBCXX_CXX_ABI STREQUAL "none"
260-
AND Python3_EXECUTABLE
261-
AND LIBCXX_ENABLE_SHARED)
262-
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
254+
# on UNIX platforms other than Apple unless we statically link libc++abi
255+
# inside libc++.so, we don't build libc++.so at all or we don't have any
256+
# ABI library.
257+
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
258+
OR NOT LIBCXX_ENABLE_SHARED
259+
OR LIBCXX_CXX_ABI STREQUAL "none")
260+
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
261+
elseif(UNIX AND NOT APPLE)
262+
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
263+
else()
264+
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
263265
endif()
264-
265266
option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
266267
"Use and install a linker script for the given ABI library"
267268
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})

0 commit comments

Comments
 (0)