Skip to content

[lld][WebAssembly] Improve error message on adding LTO object post-LTO. NFC #66688

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

Merged
merged 1 commit into from
Sep 18, 2023
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
2 changes: 1 addition & 1 deletion lld/test/wasm/lto/libcall-truncsfhf2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ define void @_start() {
ret void
}

; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO.
; CHECK: wasm-ld: error: {{.*}}truncsfhf2.o): attempt to add bitcode file after LTO (__truncsfhf2)
6 changes: 3 additions & 3 deletions lld/wasm/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ void ArchiveFile::addMember(const Archive::Symbol *sym) {
sym->getName());

InputFile *obj = createObjectFile(mb, getName(), c.getChildOffset());
symtab->addFile(obj);
symtab->addFile(obj, sym->getName());
}

static uint8_t mapVisibility(GlobalValue::VisibilityTypes gvVisibility) {
Expand Down Expand Up @@ -826,9 +826,9 @@ BitcodeFile::BitcodeFile(MemoryBufferRef m, StringRef archiveName,

bool BitcodeFile::doneLTO = false;

void BitcodeFile::parse() {
void BitcodeFile::parse(StringRef symName) {
if (doneLTO) {
error(toString(this) + ": attempt to add bitcode file after LTO.");
error(toString(this) + ": attempt to add bitcode file after LTO (" + symName + ")");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lld/wasm/InputFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class BitcodeFile : public InputFile {
uint64_t offsetInArchive);
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }

void parse();
void parse(StringRef symName);
std::unique_ptr<llvm::lto::InputFile> obj;

// Set to true once LTO is complete in order prevent further bitcode objects
Expand Down
4 changes: 2 additions & 2 deletions lld/wasm/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace llvm::object;
namespace lld::wasm {
SymbolTable *symtab;

void SymbolTable::addFile(InputFile *file) {
void SymbolTable::addFile(InputFile *file, StringRef symName) {
log("Processing: " + toString(file));

// .a file
Expand All @@ -50,7 +50,7 @@ void SymbolTable::addFile(InputFile *file) {

// LLVM bitcode file
if (auto *f = dyn_cast<BitcodeFile>(file)) {
f->parse();
f->parse(symName);
bitcodeFiles.push_back(f);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lld/wasm/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SymbolTable {

void wrap(Symbol *sym, Symbol *real, Symbol *wrap);

void addFile(InputFile *file);
void addFile(InputFile *file, StringRef symName = {});

void compileBitcodeFiles();

Expand Down