mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
CMake: Enable -Wl,--no-undefined on ELF platforms
This is mostly a development helper, to move all undefined symbols in shared libraries to link time rather than load time. At the same time, set --no-allow-shlib-undefined and -z,defs to further enforce the rule.
This commit is contained in:
parent
5e43fec6dd
commit
223b13ae93
Notes:
github-actions[bot]
2025-01-06 19:42:41 +00:00
Author: https://github.com/ADKaster
Commit: 223b13ae93
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2983
3 changed files with 23 additions and 0 deletions
|
@ -15,6 +15,11 @@ set(BUILD_TESTING_SAVE ${BUILD_TESTING})
|
|||
set(BUILD_TESTING OFF)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
|
||||
# FIXME: https://github.com/apple/swift-collections/issues/440
|
||||
set(BUILD_SHARED_LIBS_SAVE ${BUILD_SHARED_LIBS})
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
FetchContent_MakeAvailable(SwiftCollections)
|
||||
|
||||
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVE})
|
||||
set(BUILD_TESTING ${BUILD_TESTING_SAVE})
|
||||
|
|
|
@ -54,6 +54,19 @@ if (NOT WIN32)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT WIN32 AND NOT APPLE AND NOT ENABLE_FUZZERS)
|
||||
# NOTE: Assume ELF
|
||||
# NOTE: --no-undefined is not compatible with clang sanitizer runtimes
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND (ENABLE_ADDRESS_SANITIZER OR ENABLE_MEMORY_SANITIZER OR ENABLE_UNDEFINED_SANITIZER OR ENABLE_LAGOM_COVERAGE_COLLECTION))
|
||||
add_link_options(LINKER:--allow-shlib-undefined)
|
||||
add_link_options(LINKER:-z,undefs)
|
||||
else()
|
||||
add_link_options(LINKER:-z,defs)
|
||||
add_link_options(LINKER:--no-undefined)
|
||||
add_link_options(LINKER:--no-allow-shlib-undefined)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_LAGOM_COVERAGE_COLLECTION)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND NOT ENABLE_FUZZERS)
|
||||
add_cxx_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
||||
|
|
|
@ -16,6 +16,11 @@ function(clang_plugin target_name)
|
|||
set_property(GLOBAL APPEND PROPERTY CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -fplugin=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/lib${target_name}.so)
|
||||
|
||||
add_lagom_library_install_rules(${target_name})
|
||||
|
||||
if (NOT WIN32 AND NOT APPLE)
|
||||
target_link_options(${target_name} PRIVATE LINKER:-z,undefs)
|
||||
target_link_options(${target_name} PRIVATE LINKER:--allow-shlib-undefined)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(depend_on_clang_plugin target_name plugin_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue