From e28cbb2efac9ed6e56cd9ab6eb1a3f16810d575a Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 03:54:49 +0000 Subject: 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 --- tools/driver/main.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tools/driver/main.cc') diff --git a/tools/driver/main.cc b/tools/driver/main.cc index f5373a0..4df8562 100644 --- a/tools/driver/main.cc +++ b/tools/driver/main.cc @@ -1,6 +1,9 @@ #include "cps/Lexer.h" #include "cps/Parser.h" #include "cps/CodeGen.h" +#ifdef CPSC_RUN_EMBEDDED +#include "EmbeddedRunner.h" +#endif #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" @@ -48,7 +51,9 @@ int main(int argc, char **argv) { llvm::errs() << "Error: no source file specified\n"; return 1; } +#ifdef CPSC_RUN_PATH std::string LliPath; +#endif if (Run) { #ifdef CPSC_RUN_PATH auto Lli = llvm::sys::findProgramByName("lli"); @@ -57,7 +62,7 @@ int main(int argc, char **argv) { return 1; } LliPath = *Lli; -#else +#elif defined(CPSC_RUN_NONE) llvm::errs() << "Error: -r is disabled in this build (CPSC_RUN_MODE=NONE)\n"; return 1; #endif @@ -93,6 +98,9 @@ int main(int argc, char **argv) { if (CG.hadError()) return 1; +#ifdef CPSC_RUN_EMBEDDED + if (Run && OutputPath.empty()) return runEmbedded(CG); +#endif std::error_code EC; int OutputFD; llvm::FileRemover TemporaryOutput; @@ -137,6 +145,8 @@ int main(int argc, char **argv) { return 1; } return Result; +#elif defined(CPSC_RUN_EMBEDDED) + return runEmbedded(CG); #else return 0; #endif -- cgit v1.3.1-4-g156e