Title: [288994] trunk
- Revision
- 288994
- Author
- [email protected]
- Date
- 2022-02-02 13:41:06 -0800 (Wed, 02 Feb 2022)
Log Message
[CMake] Stop defaulting to ld.gold
https://bugs.webkit.org/show_bug.cgi?id=235476
Reviewed by Michael Catanzaro.
Remove the USE_LD_GOLD option, and let the build use by default the system linker.
The output from running the linker with -Wl,--version is matched to determine which linker
is currently in use, and set variables LD_SUPPORTS_<feature> accordingly. This is needed
because not all of them support certain features and after a few attempts at doing feature
checks it was becoming clear that on one hand the checks were getting gnarly, and on the
other hand vetting certain linkers provides a stronger guarantee of sucessful builds.
Similarly, extend the check used to determine whether the static library archiver supports
thin archivers to cover the one included with LLVM (llvm-ar), and enable usage of think
archivers if they can be both created by the archiver and consumed by the linker. Previously
the build system was enabling thin archives without knowing whether the linker would succeed
using them.
* Source/cmake/OptionsCommon.cmake:
Modified Paths
Diff
Modified: trunk/ChangeLog (288993 => 288994)
--- trunk/ChangeLog 2022-02-02 21:38:02 UTC (rev 288993)
+++ trunk/ChangeLog 2022-02-02 21:41:06 UTC (rev 288994)
@@ -1,3 +1,26 @@
+2022-02-02 Adrian Perez de Castro <[email protected]>
+
+ [CMake] Stop defaulting to ld.gold
+ https://bugs.webkit.org/show_bug.cgi?id=235476
+
+ Reviewed by Michael Catanzaro.
+
+ Remove the USE_LD_GOLD option, and let the build use by default the system linker.
+
+ The output from running the linker with -Wl,--version is matched to determine which linker
+ is currently in use, and set variables LD_SUPPORTS_<feature> accordingly. This is needed
+ because not all of them support certain features and after a few attempts at doing feature
+ checks it was becoming clear that on one hand the checks were getting gnarly, and on the
+ other hand vetting certain linkers provides a stronger guarantee of sucessful builds.
+
+ Similarly, extend the check used to determine whether the static library archiver supports
+ thin archivers to cover the one included with LLVM (llvm-ar), and enable usage of think
+ archivers if they can be both created by the archiver and consumed by the linker. Previously
+ the build system was enabling thin archives without knowing whether the linker would succeed
+ using them.
+
+ * Source/cmake/OptionsCommon.cmake:
+
2022-02-01 Carlos Garcia Campos <[email protected]>
[GTK][WPE] Switch to use ATSPI instead of ATK
Modified: trunk/Source/cmake/OptionsCommon.cmake (288993 => 288994)
--- trunk/Source/cmake/OptionsCommon.cmake 2022-02-02 21:38:02 UTC (rev 288993)
+++ trunk/Source/cmake/OptionsCommon.cmake 2022-02-02 21:41:06 UTC (rev 288994)
@@ -6,26 +6,9 @@
add_definitions(-DHAVE_CONFIG_H=1)
add_definitions(-DPAS_BMALLOC=1)
-option(USE_THIN_ARCHIVES "Produce all static libraries as thin archives" ON)
-if (USE_THIN_ARCHIVES)
- execute_process(COMMAND ${CMAKE_AR} -V OUTPUT_VARIABLE AR_VERSION ERROR_VARIABLE AR_ERROR)
- if ("${AR_ERROR}" MATCHES "^usage:")
- # This `ar` doesn't understand "-V". Ignore the error and treat this as
- # an unsupported `ar`. TODO: Determine BSD or Xcode equivalent.
- elseif ("${AR_ERROR}")
- message(WARNING "Error from `ar`: ${AR_ERROR}")
- elseif ("${AR_VERSION}" MATCHES "^GNU ar")
- set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
- set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
- set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
- set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
- endif ()
-endif ()
-
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
define_property(TARGET PROPERTY FOLDER INHERITED BRIEF_DOCS "folder" FULL_DOCS "IDE folder name")
-set(ARM_TRADITIONAL_DETECTED FALSE)
if (WTF_CPU_ARM)
set(ARM_THUMB2_TEST_SOURCE
"
@@ -36,16 +19,11 @@
")
CHECK_CXX_SOURCE_COMPILES("${ARM_THUMB2_TEST_SOURCE}" ARM_THUMB2_DETECTED)
- if (NOT ARM_THUMB2_DETECTED)
- set(ARM_TRADITIONAL_DETECTED TRUE)
- # See https://bugs.webkit.org/show_bug.cgi?id=159880#c4 for details.
- message(STATUS "Disabling GNU gold linker, because it doesn't support ARM instruction set properly.")
- endif ()
endif ()
# Use ld.lld when building with LTO
CMAKE_DEPENDENT_OPTION(USE_LD_LLD "Use LLD linker" ON
- "LTO_MODE;NOT USE_LD_GOLD;NOT WIN32" OFF)
+ "LTO_MODE;NOT WIN32" OFF)
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")
@@ -57,25 +35,76 @@
endif ()
endif ()
-# Use ld.gold if it is available and isn't disabled explicitly
-CMAKE_DEPENDENT_OPTION(USE_LD_GOLD "Use GNU gold linker" ON
- "NOT CXX_ACCEPTS_MFIX_CORTEX_A53_835769;NOT ARM_TRADITIONAL_DETECTED;NOT WIN32;NOT APPLE;NOT USE_LD_LLD" OFF)
-if (USE_LD_GOLD)
- execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
- if ("${LD_VERSION}" MATCHES "GNU gold")
- string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold -Wl,--disable-new-dtags")
- string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold -Wl,--disable-new-dtags")
- string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold -Wl,--disable-new-dtags")
+# Determine which linker is being used with the chosen linker flags.
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -Wl,--version
+ OUTPUT_VARIABLE LD_VERSION
+ ERROR_QUIET
+)
+set(LD_SUPPORTS_GDB_INDEX TRUE)
+set(LD_SUPPORTS_SPLIT_DEBUG TRUE)
+set(LD_SUPPORTS_THIN_ARCHIVES TRUE)
+if (LD_VERSION MATCHES "^LLD ")
+ set(LD_VARIANT LLD)
+elseif (LD_VERSION MATCHES "^mold ")
+ set(LD_VARIANT MOLD)
+elseif (LD_VERSION MATCHES "^GNU gold ")
+ set(LD_VARIANT GOLD)
+elseif (LD_VERSION MATCHES "^GNU ld ")
+ set(LD_VARIANT BFD)
+ set(LD_SUPPORTS_GDB_INDEX FALSE)
+else ()
+ set(LD_VARIANT UNKNOWN)
+ set(LD_SUPPORTS_GDB_INDEX FALSE)
+ set(LD_SUPPORTS_SPLIT_DEBUG FALSE)
+ set(LD_SUPPORTS_THIN_ARCHIVES 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})")
+
+# Determine whether the archiver in use supports thin archives.
+execute_process(
+ COMMAND ${CMAKE_AR} -V
+ OUTPUT_VARIABLE AR_VERSION
+ RESULT_VARIABLE AR_STATUS
+ ERROR_QUIET
+)
+set(AR_SUPPORTS_THIN_ARCHIVES FALSE)
+if (AR_STATUS EQUAL 0)
+ if (AR_VERSION MATCHES "^GNU ar ")
+ set(AR_VARIANT BFD)
+ set(AR_SUPPORTS_THIN_ARCHIVES TRUE)
+ elseif (AR_VERSION MATCHES "^LLVM ")
+ set(AR_VARIANT LLVM)
+ set(AR_SUPPORTS_THIN_ARCHIVES TRUE)
else ()
- message(WARNING "GNU gold linker isn't available, using the default system linker.")
- set(USE_LD_GOLD OFF)
+ set(AR_VARIANT UNKNOWN)
endif ()
endif ()
+unset(AR_VERSION)
+unset(AR_STATUS)
+message(STATUS "Archiver variant in use: ${AR_VARIANT} (thin archives: ${AR_SUPPORTS_THIN_ARCHIVES})")
+# 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)
+ set(USE_THIN_ARCHIVES_DEFAULT ON)
+else ()
+ set(USE_THIN_ARCHIVES_DEFAULT OFF)
+endif ()
+option(USE_THIN_ARCHIVES "Produce all static libraries as thin archives" ${USE_THIN_ARCHIVES_DEFAULT})
+
+if (USE_THIN_ARCHIVES)
+ set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> rT <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif ()
+
set(ENABLE_DEBUG_FISSION_DEFAULT OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
check_cxx_compiler_flag(-gsplit-dwarf CXX_COMPILER_SUPPORTS_GSPLIT_DWARF)
- if (CXX_COMPILER_SUPPORTS_GSPLIT_DWARF)
+ if (CXX_COMPILER_SUPPORTS_GSPLIT_DWARF AND LD_SUPPORTS_SPLIT_DEBUG)
set(ENABLE_DEBUG_FISSION_DEFAULT ON)
endif ()
endif ()
@@ -85,9 +114,7 @@
if (DEBUG_FISSION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gsplit-dwarf")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf")
-
- # The ld.bfd linker does not support --gdb-index, possibly others as well.
- if (USE_LD_GOLD OR USE_LD_LLD)
+ if (LD_SUPPORTS_GDB_INDEX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gdb-index")
endif ()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes