[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
Thu Nov 28 08:09:19 PST 2024
================
@@ -51,45 +76,50 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
- std::string OutputFileName = PTU.TheModule->getName().str() + ".wasm";
+ std::string ObjectFileName =
+ PTU.TheModule->getName().str() + ".o"; // For the wasm object
+ std::string BinaryFileName =
+ PTU.TheModule->getName().str() + ".wasm"; // For the wasm binary
std::error_code Error;
- llvm::raw_fd_ostream OutputFile(llvm::StringRef(OutputFileName), Error);
+ llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error);
llvm::legacy::PassManager PM;
- if (TargetMachine->addPassesToEmitFile(PM, OutputFile, nullptr,
+ if (TargetMachine->addPassesToEmitFile(PM, ObjectFileOutput, nullptr,
llvm::CodeGenFileType::ObjectFile)) {
return llvm::make_error<llvm::StringError>(
"Wasm backend cannot produce object.", llvm::inconvertibleErrorCode());
}
if (!PM.run(*PTU.TheModule)) {
-
----------------
vgvassilev wrote:
Stray change.
https://github.com/llvm/llvm-project/pull/117978
More information about the cfe-commits
mailing list