diff --git a/README.md b/README.md index 3ba55c83..6ed086e6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ mamba install`xeus-cpp` notebook -c conda-forge Or you can install it from the sources, you will first need to install dependencies ```bash -mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab clangdev=16 cpp-argparse pugixml -c conda-forge +mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab clangdev=17 cpp-argparse pugixml -c conda-forge ``` Then you can compile the sources (replace `$CONDA_PREFIX` with a custom installation diff --git a/docs/InstallationAndUsage.rst b/docs/InstallationAndUsage.rst index 2a2912c3..c99c8932 100644 --- a/docs/InstallationAndUsage.rst +++ b/docs/InstallationAndUsage.rst @@ -6,7 +6,7 @@ You will first need to install dependencies. .. code-block:: bash mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab - clangdev=16 cpp-argparse pugixml -c conda-forge + clangdev=17 cpp-argparse pugixml -c conda-forge **Note:** Use a mamba environment with python version >= 3.11 for fetching clang-versions. diff --git a/environment-dev.yml b/environment-dev.yml index 65476d59..56917780 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -11,7 +11,7 @@ dependencies: - nlohmann_json - cppzmq - xtl - - clangdev >=16,<17 + - clangdev >=17,<18 - pugixml - cpp-argparse - zlib diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index bc6587f0..7e0b8c4c 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -130,7 +130,9 @@ create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client Args ClangArgs = {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end()); - auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs)); + clang::IncrementalCompilerBuilder builder; + builder.SetCompilerArgs(ClangArgs); + auto CI = cantFail(builder.CreateCpp()); if (Client) { CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false); @@ -139,7 +141,7 @@ create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client } static void -inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAddr, clang::Interpreter& Interp) +inject_symbol(llvm::StringRef LinkerMangledName, llvm::orc::ExecutorAddr KnownAddr, clang::Interpreter& Interp) { using namespace llvm; using namespace llvm::orc; @@ -153,7 +155,7 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd } // Nothing to define, we are redefining the same function. FIXME: Diagnose. - if (*Symbol && (JITTargetAddress) *Symbol == KnownAddr) + if (*Symbol && (ExecutorAddr) *Symbol == KnownAddr) { return; } @@ -163,12 +165,19 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd SymbolMap::iterator It; static llvm::orc::SymbolMap m_InjectedSymbols; - llvm::orc::LLJIT* Jit = const_cast(Interp.getExecutionEngine()); - JITDylib& DyLib = Jit->getMainJITDylib(); + auto JitOrError = Interp.getExecutionEngine(); + if (Error Err = JitOrError.takeError()) + { + logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed2: "); + return; + } + + llvm::orc::LLJIT &Jit = *JitOrError; + llvm::orc::JITDylib &DyLib = Jit.getMainJITDylib(); std::tie(It, Inserted) = m_InjectedSymbols.try_emplace( - Jit->getExecutionSession().intern(LinkerMangledName), - JITEvaluatedSymbol(KnownAddr, JITSymbolFlags::Exported) + Jit.getExecutionSession().intern(LinkerMangledName), + ExecutorSymbolDef(KnownAddr, JITSymbolFlags::Exported) ); assert(Inserted && "Why wasn't this found in the initial Jit lookup?"); @@ -178,14 +187,14 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd // The symbol be in the DyLib or in-process. if (auto Err = DyLib.remove({It->first})) { - logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed2: "); + logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: "); return; } } if (Error Err = DyLib.define(absoluteSymbols({*It}))) { - logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: "); + logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed4: "); } } @@ -559,8 +568,8 @@ namespace xcpp // Inject versions of printf and fprintf that output to std::cout // and std::cerr (see implementation above). - inject_symbol("printf", llvm::pointerToJITTargetAddress(printf_jit), *m_interpreter); - inject_symbol("fprintf", llvm::pointerToJITTargetAddress(fprintf_jit), *m_interpreter); + inject_symbol("printf", llvm::orc::ExecutorAddr::fromPtr(printf_jit), *m_interpreter); + inject_symbol("fprintf", llvm::orc::ExecutorAddr::fromPtr(fprintf_jit), *m_interpreter); } void interpreter::restore_output()