Meta+LibCore: Disable --no-undefined on FreeBSD and remove LibCore hack

It turns out it's much cleaner to just allow undefined symbols like we
already do for sanitizer Clang and remove the weak symbol definition.
This commit is contained in:
Undefine 2025-09-12 15:57:12 +02:00 committed by Jelle Raaijmakers
parent bd8c6c1431
commit abe536652f
2 changed files with 3 additions and 8 deletions

View File

@ -13,9 +13,6 @@
#if defined(AK_OS_MACOS) || defined(AK_OS_IOS)
# include <crt_externs.h>
#elif defined(AK_OS_FREEBSD)
// FIXME: Remove this once FreeBSD exports environ from libc
extern "C" __attribute__((weak)) char** environ;
#elif !defined(AK_OS_WINDOWS)
extern "C" char** environ;
#endif

View File

@ -69,16 +69,14 @@ 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))
# NOTE: FreeBSD doesn't export all symbols from LibC so we can't use --no-undefined
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND (ENABLE_ADDRESS_SANITIZER OR ENABLE_MEMORY_SANITIZER OR ENABLE_UNDEFINED_SANITIZER OR ENABLE_LAGOM_COVERAGE_COLLECTION)) OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
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)
# FIXME: Remove this once FreeBSD exports environ from libc
if (NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_link_options(LINKER:--no-allow-shlib-undefined)
endif()
add_link_options(LINKER:--no-allow-shlib-undefined)
endif()
endif()