Skip to content

Commit 6eeef54

Browse files
committed
Update_clang_version
1 parent e17a10a commit 6eeef54

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mamba install`xeus-cpp` notebook -c conda-forge
3838
Or you can install it from the sources, you will first need to install dependencies
3939

4040
```bash
41-
mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab clangdev=16 cpp-argparse pugixml -c conda-forge
41+
mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab clangdev=17 cpp-argparse pugixml -c conda-forge
4242
```
4343

4444
Then you can compile the sources (replace `$CONDA_PREFIX` with a custom installation

docs/InstallationAndUsage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You will first need to install dependencies.
66
.. code-block:: bash
77
88
mamba install cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab
9-
clangdev=16 cpp-argparse pugixml -c conda-forge
9+
clangdev=17 cpp-argparse pugixml -c conda-forge
1010
1111
1212
**Note:** Use a mamba environment with python version >= 3.11 for fetching clang-versions.

environment-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- nlohmann_json
1212
- cppzmq
1313
- xtl
14-
- clangdev >=16,<17
14+
- clangdev >=17,<18
1515
- pugixml
1616
- cpp-argparse
1717
- zlib

src/xinterpreter.cpp

+20-11
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client
130130

131131
Args ClangArgs = {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"};
132132
ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
133-
auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
133+
clang::IncrementalCompilerBuilder builder;
134+
builder.SetCompilerArgs(ClangArgs);
135+
auto CI = cantFail(builder.CreateCpp());
134136
if (Client)
135137
{
136138
CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
@@ -139,7 +141,7 @@ create_interpreter(const Args& ExtraArgs = {}, clang::DiagnosticConsumer* Client
139141
}
140142

141143
static void
142-
inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAddr, clang::Interpreter& Interp)
144+
inject_symbol(llvm::StringRef LinkerMangledName, llvm::orc::ExecutorAddr KnownAddr, clang::Interpreter& Interp)
143145
{
144146
using namespace llvm;
145147
using namespace llvm::orc;
@@ -153,7 +155,7 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd
153155
}
154156

155157
// Nothing to define, we are redefining the same function. FIXME: Diagnose.
156-
if (*Symbol && (JITTargetAddress) *Symbol == KnownAddr)
158+
if (*Symbol && (ExecutorAddr) *Symbol == KnownAddr)
157159
{
158160
return;
159161
}
@@ -163,12 +165,19 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd
163165
SymbolMap::iterator It;
164166
static llvm::orc::SymbolMap m_InjectedSymbols;
165167

166-
llvm::orc::LLJIT* Jit = const_cast<llvm::orc::LLJIT*>(Interp.getExecutionEngine());
167-
JITDylib& DyLib = Jit->getMainJITDylib();
168+
auto JitOrError = Interp.getExecutionEngine();
168169

170+
if (Error Err = JitOrError.takeError())
171+
{
172+
logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed2: ");
173+
return;
174+
}
175+
176+
llvm::orc::LLJIT &Jit = *JitOrError;
177+
llvm::orc::JITDylib &DyLib = Jit.getMainJITDylib();
169178
std::tie(It, Inserted) = m_InjectedSymbols.try_emplace(
170-
Jit->getExecutionSession().intern(LinkerMangledName),
171-
JITEvaluatedSymbol(KnownAddr, JITSymbolFlags::Exported)
179+
Jit.getExecutionSession().intern(LinkerMangledName),
180+
ExecutorSymbolDef(KnownAddr, JITSymbolFlags::Exported)
172181
);
173182
assert(Inserted && "Why wasn't this found in the initial Jit lookup?");
174183

@@ -178,14 +187,14 @@ inject_symbol(llvm::StringRef LinkerMangledName, llvm::JITTargetAddress KnownAdd
178187
// The symbol be in the DyLib or in-process.
179188
if (auto Err = DyLib.remove({It->first}))
180189
{
181-
logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed2: ");
190+
logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: ");
182191
return;
183192
}
184193
}
185194

186195
if (Error Err = DyLib.define(absoluteSymbols({*It})))
187196
{
188-
logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed3: ");
197+
logAllUnhandledErrors(std::move(Err), errs(), "[IncrementalJIT] define() failed4: ");
189198
}
190199
}
191200

@@ -559,8 +568,8 @@ namespace xcpp
559568

560569
// Inject versions of printf and fprintf that output to std::cout
561570
// and std::cerr (see implementation above).
562-
inject_symbol("printf", llvm::pointerToJITTargetAddress(printf_jit), *m_interpreter);
563-
inject_symbol("fprintf", llvm::pointerToJITTargetAddress(fprintf_jit), *m_interpreter);
571+
inject_symbol("printf", llvm::orc::ExecutorAddr::fromPtr(printf_jit), *m_interpreter);
572+
inject_symbol("fprintf", llvm::orc::ExecutorAddr::fromPtr(fprintf_jit), *m_interpreter);
564573
}
565574

566575
void interpreter::restore_output()

0 commit comments

Comments
 (0)