-
Notifications
You must be signed in to change notification settings - Fork 56
Update Emscripten build to llvm 22 #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mcbarton
wants to merge
24
commits into
compiler-research:main
Choose a base branch
from
mcbarton:emscripten-llvm22
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4c692a4
Update Emscripten llvm support to llvm 22
mcbarton ddbb2ac
Update exports.ld
mcbarton d9c6ff1
Merge branch 'main' into emscripten-llvm22
mcbarton 7ab6c0e
Update action.yml
mcbarton 5075fc0
Disable failing tests for Emscripten llvm 22 build
mcbarton 8e847e9
Fix previous commit
mcbarton 79ffc47
Update FunctionReflectionTest.cpp
mcbarton 804a86f
Update TracingTests.cpp
mcbarton 2be4fc0
Update FunctionReflectionTest.cpp
mcbarton f9f21f7
Update TracingTests.cpp
mcbarton 8df3d89
Update FunctionReflectionTest.cpp
mcbarton 1e1bc07
Update TracingTests.cpp
mcbarton 9a23965
Merge branch 'main' into emscripten-llvm22
mcbarton 941a9aa
Try to fix
mcbarton 295020e
Update emscripten.yml
mcbarton 0d483c6
Update action.yml
mcbarton b0f408d
Merge branch 'main' into emscripten-llvm22
mcbarton cf4bb1b
Merge branch 'main' into emscripten-llvm22
mcbarton 8fe21ea
Update action.yml
mcbarton 356eed0
Try fix
mcbarton dd3368e
Merge branch 'main' into emscripten-llvm22
mcbarton c1714df
Merge branch 'main' into emscripten-llvm22
mcbarton 4c44d26
Merge branch 'main' into emscripten-llvm22
mcbarton 882bad2
Fix clang-runtime deployment
mcbarton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
patches/llvm/emscripten-clang22-1-enable_exception_handling.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h | ||
| index f56da69a05caf..f5dfc36953308 100644 | ||
| --- a/clang/include/clang/Frontend/CompilerInstance.h | ||
| +++ b/clang/include/clang/Frontend/CompilerInstance.h | ||
| @@ -246,6 +246,11 @@ class CompilerInstance : public ModuleLoader { | ||
| /// Load the list of plugins requested in the \c FrontendOptions. | ||
| void LoadRequestedPlugins(); | ||
|
|
||
| + /// Parse and apply LLVM command line arguments from FrontendOptions. | ||
| + /// This processes the LLVMArgs option that comes from -mllvm flags. | ||
| + /// This should be called after plugins are loaded and before ExecuteAction. | ||
| + void parseLLVMArgs(); | ||
| + | ||
| /// @} | ||
| /// @name Compiler Invocation and Options | ||
| /// @{ | ||
| diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp | ||
| index 2cd7888b0d192..a1ea9486ac406 100644 | ||
| --- a/clang/lib/Frontend/CompilerInstance.cpp | ||
| +++ b/clang/lib/Frontend/CompilerInstance.cpp | ||
| @@ -1102,6 +1102,20 @@ void CompilerInstance::LoadRequestedPlugins() { | ||
| } | ||
| } | ||
|
|
||
| +void CompilerInstance::parseLLVMArgs() { | ||
| + if (!getFrontendOpts().LLVMArgs.empty()) { | ||
| + unsigned NumArgs = getFrontendOpts().LLVMArgs.size(); | ||
| + auto Args = std::make_unique<const char *[]>(NumArgs + 2); | ||
| + Args[0] = "clang (LLVM option parsing)"; | ||
| + for (unsigned i = 0; i != NumArgs; ++i) | ||
| + Args[i + 1] = getFrontendOpts().LLVMArgs[i].c_str(); | ||
| + Args[NumArgs + 1] = nullptr; | ||
| + llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get(), /*Overview=*/"", | ||
| + /*Errs=*/nullptr, | ||
| + /*VFS=*/&getVirtualFileSystem()); | ||
| + } | ||
| +} | ||
| + | ||
| /// Determine the appropriate source input kind based on language | ||
| /// options. | ||
| static Language getLanguageFromOptions(const LangOptions &LangOpts) { | ||
| diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | ||
| index 05f646b43e3c4..9fa6fbb0017e1 100644 | ||
| --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | ||
| +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | ||
| @@ -237,17 +237,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { | ||
| // | ||
| // FIXME: Remove this, one day. | ||
| // This should happen AFTER plugins have been loaded! | ||
| - if (!Clang->getFrontendOpts().LLVMArgs.empty()) { | ||
| - unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size(); | ||
| - auto Args = std::make_unique<const char*[]>(NumArgs + 2); | ||
| - Args[0] = "clang (LLVM option parsing)"; | ||
| - for (unsigned i = 0; i != NumArgs; ++i) | ||
| - Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str(); | ||
| - Args[NumArgs + 1] = nullptr; | ||
| - llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get(), /*Overview=*/"", | ||
| - /*Errs=*/nullptr, | ||
| - /*VFS=*/&Clang->getVirtualFileSystem()); | ||
| - } | ||
| + Clang->parseLLVMArgs(); | ||
|
|
||
| #if CLANG_ENABLE_STATIC_ANALYZER | ||
| // These should happen AFTER plugins have been loaded! | ||
| diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp | ||
| index 9c94cfa5ee381..bfb6c2a0505d1 100644 | ||
| --- a/clang/lib/Interpreter/Interpreter.cpp | ||
| +++ b/clang/lib/Interpreter/Interpreter.cpp | ||
| @@ -257,6 +257,9 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> Instance, | ||
| auto LLVMCtx = std::make_unique<llvm::LLVMContext>(); | ||
| TSCtx = std::make_unique<llvm::orc::ThreadSafeContext>(std::move(LLVMCtx)); | ||
|
|
||
| + // Honor -mllvm options | ||
| + CI->parseLLVMArgs(); | ||
| + | ||
| Act = TSCtx->withContextDo([&](llvm::LLVMContext *Ctx) { | ||
| return std::make_unique<IncrementalAction>(*CI, *Ctx, ErrOut, *this, | ||
| std::move(Consumer)); | ||
| @@ -465,6 +468,12 @@ Interpreter::Parse(llvm::StringRef Code) { | ||
| return std::move(Err); | ||
| } | ||
|
|
||
| + // Re-apply stored -mllvm options; wasm builds reset LLVM opts in wasm-ld. | ||
| + llvm::Triple Triple(getCompilerInstance()->getTargetOpts().Triple); | ||
| + if (Triple.isWasm()) { | ||
| + getCompilerInstance()->parseLLVMArgs(); | ||
| + } | ||
| + | ||
| // Tell the interpreter sliently ignore unused expressions since value | ||
| // printing could cause it. | ||
| getCompilerInstance()->getDiagnostics().setSeverity( |
14 changes: 14 additions & 0 deletions
14
patches/llvm/emscripten-clang22-2-webassembly_target_machine_reordering.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
| index 6827ee652794..3ad7ec5d32b6 100644 | ||
| --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
| +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | ||
| @@ -227,8 +227,8 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine( | ||
| this->Options.DataSections = true; | ||
| this->Options.UniqueSectionNames = true; | ||
|
|
||
| - initAsmInfo(); | ||
| basicCheckForEHAndSjLj(this); | ||
| + initAsmInfo(); | ||
| // Note that we don't use setRequiresStructuredCFG(true). It disables | ||
| // optimizations than we're ok with, and want, such as critical edge | ||
| // splitting and tail merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.