Files
faumaray bba5c8a39a initial commit
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
2026-05-22 02:40:32 +03:00

30 lines
1.2 KiB
CMake

# Toolchain: clang targeting x86_64-linux-gnu (host glibc delegation)
# Produces a PIC object file suitable for voidlink to pack into a .vlc section.
#
# Usage (from a consumer CMakeLists.txt driven by void_add_universal_library):
# cmake -B build-linux -DCMAKE_TOOLCHAIN_FILE=<voidlibc>/cmake/toolchains/linux.cmake
#
# The resulting .o files are packed by voidlink; undefined symbols are resolved
# against the host process's glibc/libpthread/libm at dlopen time via DT_NEEDED.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
find_program(_CLANG_EXE NAMES clang clang-18 clang-17 clang-16 REQUIRED)
set(CMAKE_C_COMPILER "${_CLANG_EXE}" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "${_CLANG_EXE}" CACHE FILEPATH "")
# -fPIC: required for DSO code; -c: produce .o, not linked binary.
# -target: explicit x86_64-linux-gnu to avoid accidentally targeting musl.
set(CMAKE_C_FLAGS_INIT "-target x86_64-unknown-linux-gnu -fPIC")
set(CMAKE_CXX_FLAGS_INIT "-target x86_64-unknown-linux-gnu -fPIC")
# Object-only build: no linking step.
set(CMAKE_EXE_LINKER_FLAGS_INIT "")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)