From abe536652fb23697eee3df6f44d2343457c3520d Mon Sep 17 00:00:00 2001 From: Undefine Date: Fri, 12 Sep 2025 15:57:12 +0200 Subject: [PATCH] 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. --- Libraries/LibCore/Environment.cpp | 3 --- Meta/CMake/lagom_compile_options.cmake | 8 +++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Libraries/LibCore/Environment.cpp b/Libraries/LibCore/Environment.cpp index a8e44723e7..38971f21d0 100644 --- a/Libraries/LibCore/Environment.cpp +++ b/Libraries/LibCore/Environment.cpp @@ -13,9 +13,6 @@ #if defined(AK_OS_MACOS) || defined(AK_OS_IOS) # include -#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 diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 8610074332..81580f6fdf 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -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()