Meta: Do not allow undefined symbols in executables and shared objects

The `--allow-shlib-undefined` option is a bit of a misnomer. It actually
controls whether we should be allowed to have undefined references after
symbols from all dependencies have been resolved, so it applies both to
shared libraries and executables.

LLD defaults to allowing undefined references in shared libraries, but
not in executables. Previously, we had to disable this check for
executables too, as it caused a build failure due to the
LibC-LibPthread-libc++ and the LibCore-LibCrypto circular dependencies.

Now that those have been resolved, we can enable this warning, in the
hopes that it will prevent us from introducing circular libraries and
missing dependencies that might cause unexpected breakage.
This commit is contained in:
Daniel Bertalan 2022-01-08 20:33:36 +01:00 committed by Linus Groh
parent e1eefe2b52
commit 4a428ba252
Notes: sideshowbarker 2024-07-17 21:17:53 +09:00

View File

@ -204,10 +204,10 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
# Clang doesn't add compiler_rt to the search path when compiling with -nostdlib.
link_directories(${TOOLCHAIN_ROOT}/lib/clang/${CMAKE_CXX_COMPILER_VERSION}/lib/${SERENITY_ARCH}-pc-serenity/)
add_link_options(LINKER:--allow-shlib-undefined)
endif()
add_link_options(LINKER:-z,text)
add_link_options(LINKER:--no-allow-shlib-undefined)
add_compile_definitions(SANITIZE_PTRS)
set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")