[clang] [clang-repl] Fix generation of wasm binaries while running clang-repl in browser (PR #117978)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 29 00:32:33 PST 2024
================
@@ -69,27 +95,30 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
llvm::inconvertibleErrorCode());
}
- OutputFile.close();
+ ObjectFileOutput.close();
std::vector<const char *> LinkerArgs = {"wasm-ld",
"-shared",
"--import-memory",
- "--no-entry",
- "--export-all",
"--experimental-pic",
"--stack-first",
"--allow-undefined",
- OutputFileName.c_str(),
+ ObjectFileName.c_str(),
"-o",
- OutputFileName.c_str()};
- int Result =
- lld::wasm::link(LinkerArgs, llvm::outs(), llvm::errs(), false, false);
- if (!Result)
+ BinaryFileName.c_str()};
+
+ const lld::DriverDef WasmDriver = {lld::Flavor::Wasm, &lld::wasm::link};
+ std::vector<lld::DriverDef> WasmDriverArgs;
+ WasmDriverArgs.push_back(WasmDriver);
+ lld::Result Result =
+ lld::lldMain(LinkerArgs, llvm::outs(), llvm::errs(), WasmDriverArgs);
+
+ if (Result.retCode != 0)
----------------
vgvassilev wrote:
```suggestion
if (Result.retCode)
```
https://github.com/llvm/llvm-project/pull/117978
More information about the cfe-commits
mailing list