[clang] [clang-repl] Fix target creation in Wasm.cpp (PR #130909)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 00:06:52 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Anutosh Bhat (anutosh491)

<details>
<summary>Changes</summary>

After #<!-- -->129868 went in, I realize some updates have been made to the Triple.

Not sure if @<!-- -->nikic overlooked including this change in his PR (hence I have having build issue when compiling clang against emscripten while building for wasm)

But yeah just like the change was addressed in other files, we need to make the change here too I think

https://github.com/llvm/llvm-project/blob/d921bf233c4fd3840953b1a4b5bb35ad594da773/clang/lib/Interpreter/DeviceOffload.cpp#L79-L86

---
Full diff: https://github.com/llvm/llvm-project/pull/130909.diff


1 Files Affected:

- (modified) clang/lib/Interpreter/Wasm.cpp (+2-2) 


``````````diff
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index aa10b160ccf84..c12412c26d6e0 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -74,7 +74,7 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
 
   llvm::TargetOptions TO = llvm::TargetOptions();
   llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
-      PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
+      PTU.TheModule->getTargetTriple().str(), "", "", TO, llvm::Reloc::Model::PIC_);
   PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
   std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
   std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
@@ -146,4 +146,4 @@ llvm::Error WasmIncrementalExecutor::cleanUp() {
 
 WasmIncrementalExecutor::~WasmIncrementalExecutor() = default;
 
-} // namespace clang
\ No newline at end of file
+} // namespace clang

``````````

</details>


https://github.com/llvm/llvm-project/pull/130909


More information about the cfe-commits mailing list