Skip to content

Commit a5f7f34

Browse files
committed
Add patch for enabling exception handling in xeus-cpp-lite
1 parent 62bff9e commit a5f7f34

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
2+
index f91563dd0378..37cf3b62e6ec 100644
3+
--- a/clang/lib/Interpreter/Interpreter.cpp
4+
+++ b/clang/lib/Interpreter/Interpreter.cpp
5+
@@ -142,6 +142,48 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
6+
return std::move(Clang);
7+
}
8+
9+
+static llvm::Error HandleFrontendOptions(const CompilerInstance &CI) {
10+
+ const auto &FrontendOpts = CI.getFrontendOpts();
11+
+
12+
+ if (FrontendOpts.ShowHelp) {
13+
+ driver::getDriverOptTable().printHelp(
14+
+ llvm::outs(), "clang -cc1 [options] file...",
15+
+ "LLVM 'Clang' Compiler: http://clang.llvm.org",
16+
+ /*ShowHidden=*/false, /*ShowAllAliases=*/false,
17+
+ llvm::opt::Visibility(driver::options::CC1Option));
18+
+ return llvm::createStringError(llvm::errc::not_supported, "Help displayed");
19+
+ }
20+
+
21+
+ if (FrontendOpts.ShowVersion) {
22+
+ llvm::cl::PrintVersionMessage();
23+
+ return llvm::createStringError(llvm::errc::not_supported,
24+
+ "Version displayed");
25+
+ }
26+
+
27+
+ if (!FrontendOpts.LLVMArgs.empty()) {
28+
+ unsigned NumArgs = FrontendOpts.LLVMArgs.size();
29+
+ auto Args = std::make_unique<const char *[]>(NumArgs + 2);
30+
+ Args[0] = "clang-repl (LLVM option parsing)";
31+
+ for (unsigned i = 0; i != NumArgs; ++i) {
32+
+ Args[i + 1] = FrontendOpts.LLVMArgs[i].c_str();
33+
+ // remove the leading '-' from the option name
34+
+ if (Args[i + 1][0] == '-') {
35+
+ auto *option = static_cast<llvm::cl::opt<bool> *>(
36+
+ llvm::cl::getRegisteredOptions()[Args[i + 1] + 1]);
37+
+ if (option) {
38+
+ option->setInitialValue(true);
39+
+ } else {
40+
+ llvm::errs() << "Unknown LLVM option: " << Args[i + 1] << "\n";
41+
+ }
42+
+ }
43+
+ }
44+
+ Args[NumArgs + 1] = nullptr;
45+
+ llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
46+
+ }
47+
+
48+
+ return llvm::Error::success();
49+
+}
50+
+
51+
} // anonymous namespace
52+
53+
namespace clang {
54+
@@ -452,7 +494,12 @@ const char *const Runtimes = R"(
55+
56+
llvm::Expected<std::unique_ptr<Interpreter>>
57+
Interpreter::create(std::unique_ptr<CompilerInstance> CI) {
58+
- llvm::Error Err = llvm::Error::success();
59+
+
60+
+ llvm::Error Err = HandleFrontendOptions(*CI);
61+
+ if (Err) {
62+
+ return std::move(Err);
63+
+ }
64+
+
65+
auto Interp =
66+
std::unique_ptr<Interpreter>(new Interpreter(std::move(CI), Err));
67+
if (Err)

recipes/recipes_emscripten/llvm/recipe.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ source:
1313
- patches/cross_compile.patch
1414
- patches/shift_temporary_files_to_tmp_dir.patch
1515
- patches/wasm-ld.patch
16+
- patches/enable_exception_handling.patch
1617

1718
build:
1819
number: 0

0 commit comments

Comments
 (0)