Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ jobs:
{
git apply -v emscripten-clang19-2-shift-temporary-files-to-tmp-dir.patch
git apply -v emscripten-clang19-3-remove-zdefs.patch
git apply -v emscripten-clang19-4-enable_exception_handling.patch
}
elseif ( "${{ matrix.clang-runtime }}" -imatch "20" )
{
Expand Down
67 changes: 67 additions & 0 deletions patches/llvm/emscripten-clang19-4-enable_exception_handling.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 985d0b7c0..20a727893 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -135,6 +135,48 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
return std::move(Clang);
}

+static llvm::Error HandleFrontendOptions(const CompilerInstance &CI) {
+ const auto &FrontendOpts = CI.getFrontendOpts();
+
+ if (FrontendOpts.ShowHelp) {
+ driver::getDriverOptTable().printHelp(
+ llvm::outs(), "clang -cc1 [options] file...",
+ "LLVM 'Clang' Compiler: http://clang.llvm.org",
+ /*ShowHidden=*/false, /*ShowAllAliases=*/false,
+ llvm::opt::Visibility(driver::options::CC1Option));
+ return llvm::createStringError(llvm::errc::not_supported, "Help displayed");
+ }
+
+ if (FrontendOpts.ShowVersion) {
+ llvm::cl::PrintVersionMessage();
+ return llvm::createStringError(llvm::errc::not_supported,
+ "Version displayed");
+ }
+
+ if (!FrontendOpts.LLVMArgs.empty()) {
+ unsigned NumArgs = FrontendOpts.LLVMArgs.size();
+ auto Args = std::make_unique<const char *[]>(NumArgs + 2);
+ Args[0] = "clang-repl (LLVM option parsing)";
+ for (unsigned i = 0; i != NumArgs; ++i) {
+ Args[i + 1] = FrontendOpts.LLVMArgs[i].c_str();
+ // remove the leading '-' from the option name
+ if (Args[i + 1][0] == '-') {
+ auto *option = static_cast<llvm::cl::opt<bool> *>(
+ llvm::cl::getRegisteredOptions()[Args[i + 1] + 1]);
+ if (option) {
+ option->setInitialValue(true);
+ } else {
+ llvm::errs() << "Unknown LLVM option: " << Args[i + 1] << "\n";
+ }
+ }
+ }
+ Args[NumArgs + 1] = nullptr;
+ llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
+ }
+
+ return llvm::Error::success();
+}
+
} // anonymous namespace

llvm::Expected<std::unique_ptr<CompilerInstance>>
@@ -306,7 +348,12 @@ const char *const Runtimes = R"(

llvm::Expected<std::unique_ptr<Interpreter>>
Interpreter::create(std::unique_ptr<CompilerInstance> CI) {
- llvm::Error Err = llvm::Error::success();
+
+ llvm::Error Err = HandleFrontendOptions(*CI);
+ if (Err) {
+ return std::move(Err);
+ }
+
auto Interp =
std::unique_ptr<Interpreter>(new Interpreter(std::move(CI), Err));
if (Err)
Loading