From 9226e87baacece10ea4971a9588d46e30cc23492 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 16 Oct 2026 07:54:06 +0000 Subject: feat(driver): embed native compilation and link resources Link LLVM, the Clang driver and LLD statically, and embed native link inputs so executable generation needs no installed development toolchain. Keep glibc dynamically linked on Linux. Co-Authored-By: Claude Fable 5.1 --- CMakeLists.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 76b76a7..f875856 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,38 +65,40 @@ add_library(CPSCodeGen STATIC lib/CodeGen/FileHandler.cc ) -llvm_map_components_to_libnames(llvm_libs core support) +llvm_map_components_to_libnames(llvm_libs core support native passes) if(CPSC_RUN_MODE STREQUAL "EMBEDDED") - llvm_map_components_to_libnames(llvm_libs core support native mcjit) + llvm_map_components_to_libnames(llvm_libs core support native passes mcjit) foreach(llvm_lib IN LISTS llvm_libs) get_target_property(llvm_type ${llvm_lib} TYPE) if(NOT llvm_type STREQUAL "STATIC_LIBRARY") message(FATAL_ERROR "EMBEDDED requires static LLVM libraries: ${llvm_lib}") endif() endforeach() - include(cmake/EmbeddedLLVM.cmake) endif() +include(cmake/EmbeddedLLVM.cmake) add_executable(cpsc tools/driver/main.cc) target_compile_definitions(cpsc PRIVATE CPSC_RUN_${CPSC_RUN_MODE}) if(CPSC_RUN_MODE STREQUAL "EMBEDDED") target_sources(cpsc PRIVATE tools/driver/EmbeddedRunner.cc) - if(MINGW) - target_link_options(cpsc PRIVATE -static) - elseif(APPLE) - # LLVM's support interface can include unused Homebrew dylibs such as Z3. - target_link_options(cpsc PRIVATE -Wl,-dead_strip_dylibs) - elseif(UNIX AND NOT APPLE) - target_link_options(cpsc PRIVATE -static-libstdc++ -static-libgcc -Wl,--as-needed) - endif() endif() -target_link_libraries(cpsc +if(MINGW) + target_link_options(cpsc PRIVATE -static) +elseif(APPLE) + # LLVM's support interface can include unused Homebrew dylibs such as Z3. + target_link_options(cpsc PRIVATE -Wl,-dead_strip_dylibs) +elseif(UNIX AND NOT APPLE) + target_link_options(cpsc PRIVATE -static-libstdc++ -static-libgcc -Wl,--as-needed) +endif() +target_link_libraries(cpsc PRIVATE CPSCodeGen CPSParser CPSLexer ${llvm_libs} ) +include(cmake/NativeCompiler.cmake) + include(cmake/Manual.cmake) configure_file(cmake/Install.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/Install.cmake" @ONLY) -- cgit v1.3.1-4-g156e