Title: [289218] trunk
Revision
289218
Author
[email protected]
Date
2022-02-07 07:27:16 -0800 (Mon, 07 Feb 2022)

Log Message

[CMake] REGRESSION(r288994): Linker does not get passed --disable-new-dtags
https://bugs.webkit.org/show_bug.cgi?id=236205

Reviewed by Darin Adler.

* Source/cmake/OptionsCommon.cmake: Arrange passing --disable-new-dtags to linkers that
are known to support the option. While at it, reorganize a bit how detected linker/archiver
features are printed out for better readability.

Modified Paths

Diff

Modified: trunk/ChangeLog (289217 => 289218)


--- trunk/ChangeLog	2022-02-07 15:22:19 UTC (rev 289217)
+++ trunk/ChangeLog	2022-02-07 15:27:16 UTC (rev 289218)
@@ -1,3 +1,14 @@
+2022-02-07  Adrian Perez de Castro  <[email protected]>
+
+        [CMake] REGRESSION(r288994): Linker does not get passed --disable-new-dtags
+        https://bugs.webkit.org/show_bug.cgi?id=236205
+
+        Reviewed by Darin Adler.
+
+        * Source/cmake/OptionsCommon.cmake: Arrange passing --disable-new-dtags to linkers that
+        are known to support the option. While at it, reorganize a bit how detected linker/archiver
+        features are printed out for better readability.
+
 2022-02-03  Myles C. Maxfield  <[email protected]>
 
         Two bopomofo tone marks are not moved to the correct place in vertical text with a particular bopomofo font

Modified: trunk/Source/cmake/OptionsCommon.cmake (289217 => 289218)


--- trunk/Source/cmake/OptionsCommon.cmake	2022-02-07 15:22:19 UTC (rev 289217)
+++ trunk/Source/cmake/OptionsCommon.cmake	2022-02-07 15:27:16 UTC (rev 289218)
@@ -27,9 +27,9 @@
 if (USE_LD_LLD)
     execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
     if ("${LD_VERSION}" MATCHES "LLD")
-        string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=lld -Wl,--disable-new-dtags")
-        string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=lld -Wl,--disable-new-dtags")
-        string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=lld -Wl,--disable-new-dtags")
+        string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=lld")
+        string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=lld")
+        string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=lld")
     else ()
         set(USE_LD_LLD OFF)
     endif ()
@@ -44,6 +44,7 @@
 set(LD_SUPPORTS_GDB_INDEX TRUE)
 set(LD_SUPPORTS_SPLIT_DEBUG TRUE)
 set(LD_SUPPORTS_THIN_ARCHIVES TRUE)
+set(LD_SUPPORTS_DISABLE_NEW_DTAGS TRUE)
 if (LD_VERSION MATCHES "^LLD ")
     set(LD_VARIANT LLD)
 elseif (LD_VERSION MATCHES "^mold ")
@@ -58,9 +59,14 @@
     set(LD_SUPPORTS_GDB_INDEX FALSE)
     set(LD_SUPPORTS_SPLIT_DEBUG FALSE)
     set(LD_SUPPORTS_THIN_ARCHIVES FALSE)
+    set(LD_SUPPORTS_DISABLE_NEW_DTAGS FALSE)
 endif ()
 unset(LD_VERSION)
-message(STATUS "Linker variant in use: ${LD_VARIANT} (thin archives: ${LD_SUPPORTS_THIN_ARCHIVES}, split debug: ${LD_SUPPORTS_SPLIT_DEBUG}, --gdb-index: ${LD_SUPPORTS_GDB_INDEX})")
+message(STATUS "Linker variant in use: ${LD_VARIANT} ")
+message(STATUS "  Linker supports thin archives - ${LD_SUPPORTS_THIN_ARCHIVES}")
+message(STATUS "  Linker supports split debug info - ${LD_SUPPORTS_SPLIT_DEBUG}")
+message(STATUS "  Linker supports --gdb-index - ${LD_SUPPORTS_GDB_INDEX}")
+message(STATUS "  Linker supports --disable-new-dtags - ${LD_SUPPORTS_DISABLE_NEW_DTAGS}")
 
 # Determine whether the archiver in use supports thin archives.
 execute_process(
@@ -83,8 +89,22 @@
 endif ()
 unset(AR_VERSION)
 unset(AR_STATUS)
-message(STATUS "Archiver variant in use: ${AR_VARIANT} (thin archives: ${AR_SUPPORTS_THIN_ARCHIVES})")
+message(STATUS "Archiver variant in use: ${AR_VARIANT}")
+message(STATUS "  Archiver supports thin archives - ${AR_SUPPORTS_THIN_ARCHIVES}")
 
+# Use --disable-new-dtags to ensure that the rpath set by CMake when building
+# will use a DT_RPATH entry in the ELF headers, to ensure that the build
+# directory lib/ subdir is always used and developers do not accidentally run
+# test programs from the build directory against system libraries. Without
+# passing the option DT_RUNPATH is used, which can be overriden by the value
+# of LD_LIBRARY_PATH set in the environment, resulting in unexpected behaviour
+# for developers.
+if (LD_SUPPORTS_DISABLE_NEW_DTAGS)
+    string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--disable-new-dtags")
+    string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--disable-new-dtags")
+    string(APPEND CMAKE_MODULE_LINKER_FLAGS " -Wl,--disable-new-dtags")
+endif ()
+
 # Prefer thin archives by default if they can be both created by the
 # archiver and read back by the linker.
 if (AR_SUPPORTS_THIN_ARCHIVES AND LD_SUPPORTS_THIN_ARCHIVES)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to