Files
Raúl MarínandClaude Opus 4.7 47a0302640 Build compiler-rt internally instead of via external cmake
Replace the execute_process() invocation in cmake/build_clang_builtin.cmake
with native add_library() targets, so compiler-rt builds the same way as
LLVM (mirroring contrib/llvm-project-cmake/).

contrib/compiler-rt-cmake/ now produces clang_rt_builtins, asan/asan_static/
asan_cxx, msan/msan_cxx, tsan/tsan_cxx, ubsan_standalone/ubsan_standalone_cxx,
and xray as regular cmake targets that are added to global-libs (so ninja
sees them as proper build-graph dependencies of every executable, instead of
relying on incidental scheduling order).

Source lists are extracted from the upstream lib/<X>/CMakeLists.txt files
with provenance comments. Build flags mirror SANITIZER_COMMON_CFLAGS plus
each component's per-target additions (-fPIE/-ffreestanding for msan,
-msse4.2 for tsan, -frtti for ubsan_cxx, etc.).

Verified by full builds in fresh folders for release+xray and SANITIZE in
{address, memory, thread, undefined}: all binaries link, run, and contain
the expected runtime symbols.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2026-04-28 08:09:27 +00:00

28 lines
1.1 KiB
CMake

# Set standard, system and compiler libraries explicitly for illumos/SunOS.
# This is intended for more control of what we are linking.
# illumos requires these defines to expose POSIX APIs in system headers:
# - _REENTRANT: thread-safe libc functions
# - _POSIX_PTHREAD_SEMANTICS: POSIX-compliant function signatures
# - __EXTENSIONS__: expose non-standard but necessary APIs
add_compile_definitions(_REENTRANT _POSIX_PTHREAD_SEMANTICS __EXTENSIONS__)
set (DEFAULT_LIBS "-nodefaultlibs")
# On SunOS/illumos, building compiler-rt from source is not yet supported
# (no toolchain file in contrib/compiler-rt-cmake/), so we use -lgcc_s.
set (BUILTINS_LIBRARY "-lgcc_s")
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} -lc -lm -lrt -lpthread -ldl -lsocket -lnsl -lsendfile -lproc -lumem")
message(STATUS "Default libraries: ${DEFAULT_LIBS}")
set(CMAKE_CXX_STANDARD_LIBRARIES ${DEFAULT_LIBS})
set(CMAKE_C_STANDARD_LIBRARIES ${DEFAULT_LIBS})
add_library(Threads::Threads INTERFACE IMPORTED)
set_target_properties(Threads::Threads PROPERTIES INTERFACE_LINK_LIBRARIES pthread)
include (cmake/unwind.cmake)
include (cmake/cxx.cmake)