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:
Andrew Kaster 2024-06-18 09:24:10 -06:00 committed by Andrew Kaster
commit 223b13ae93
Notes: github-actions[bot] 2025-01-06 19:42:41 +00:00
3 changed files with 23 additions and 0 deletions

View file

@ -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)