aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-13 03:54:49 +0000
committer_ov4 <ov4@ov4.org>2026-10-13 03:54:49 +0000
commite28cbb2efac9ed6e56cd9ab6eb1a3f16810d575a (patch)
treea0402247ba92259f6b7f3a2ad2c8ed0ca8eab3de /cmake
parentba1b65f4a20566405c53d4ded90b483ec9aa7d09 (diff)
feat: embed a statically linked LLVM execution engine
Add EMBEDDED mode to run generated modules in-process without lli or PATH lookup. Link LLVM and support archives plus the C++ runtime statically, while retaining the system C runtime on Linux. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/EmbeddedLLVM.cmake26
1 files changed, 26 insertions, 0 deletions
diff --git a/cmake/EmbeddedLLVM.cmake b/cmake/EmbeddedLLVM.cmake
new file mode 100644
index 0000000..3b56a3c
--- /dev/null
+++ b/cmake/EmbeddedLLVM.cmake
@@ -0,0 +1,26 @@
+# LLVM packages can attach shared compression/terminal libraries even to
+# LLVMSupport.a. Use their archives so these do not become deployment files.
+get_target_property(cpsc_support_libs LLVMSupport INTERFACE_LINK_LIBRARIES)
+set(cpsc_saved_library_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+foreach(cpsc_dependency IN LISTS cpsc_support_libs)
+ if(cpsc_dependency STREQUAL "ZLIB::ZLIB")
+ set(cpsc_library_names z)
+ elseif(cpsc_dependency MATCHES "^zstd::libzstd")
+ set(cpsc_library_names zstd)
+ elseif(cpsc_dependency STREQUAL "Terminfo::terminfo")
+ set(cpsc_library_names terminfo tinfo curses ncurses ncursesw)
+ else()
+ continue()
+ endif()
+ list(GET cpsc_library_names 0 cpsc_library_name)
+ find_library(CPSC_STATIC_${cpsc_library_name} NAMES ${cpsc_library_names})
+ if(NOT CPSC_STATIC_${cpsc_library_name})
+ message(FATAL_ERROR
+ "EMBEDDED requires a static archive for ${cpsc_dependency}; install its development package")
+ endif()
+ string(REPLACE "${cpsc_dependency}" "${CPSC_STATIC_${cpsc_library_name}}"
+ cpsc_support_libs "${cpsc_support_libs}")
+endforeach()
+set(CMAKE_FIND_LIBRARY_SUFFIXES ${cpsc_saved_library_suffixes})
+set_property(TARGET LLVMSupport PROPERTY INTERFACE_LINK_LIBRARIES "${cpsc_support_libs}")