Skip to content

[lld][WebAssembly] Fix regression in function signature checking #78831

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
Jan 20, 2024
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
11 changes: 10 additions & 1 deletion lld/test/wasm/signature-mismatch.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# RUN: wasm-ld -r -o %t.reloc.o %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=WARN
# RUN: obj2yaml %t.reloc.o | FileCheck %s -check-prefix=RELOC

# RUN: rm -f %t.a
# RUN: ar crS %t.a %t.ret32.o %t.call.o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be llvm-ar? I wasn't sure this would work on e.g. Windows where there's no "system" ar, and the (few) other uses of 'ar' in tests use llvm-ar.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by: 4b4763f

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

# RUN: wasm-ld --export=call_ret32 --export=ret32 -o %t2.wasm %t.main.o %t.a 2>&1 | FileCheck %s -check-prefix=ARCHIVE
# RUN: obj2yaml %t2.wasm | FileCheck %s -check-prefix=YAML

# RUN: not wasm-ld --fatal-warnings -o %t.wasm %t.main.o %t.ret32.o %t.call.o 2>&1 | FileCheck %s -check-prefix=ERROR

.functype ret32 (i32, i64, i32) -> (i32)
Expand Down Expand Up @@ -42,6 +47,10 @@ ret32_address_main:
# WARN-NEXT: >>> defined as (i32, i64, i32) -> i32 in {{.*}}.main.o
# WARN-NEXT: >>> defined as (f32) -> i32 in {{.*}}.ret32.o

# ARCHIVE: warning: function signature mismatch: ret32
# ARCHIVE-NEXT: >>> defined as (i32, i64, i32) -> i32 in {{.*}}.main.o
# ARCHIVE-NEXT: >>> defined as (f32) -> i32 in {{.*}}.ret32.o

# ERROR: error: function signature mismatch: ret32
# ERROR-NEXT: >>> defined as (i32, i64, i32) -> i32 in {{.*}}.main.o
# ERROR-NEXT: >>> defined as (f32) -> i32 in {{.*}}.ret32.o
Expand All @@ -56,7 +65,7 @@ ret32_address_main:

# YAML: - Type: CUSTOM
# YAML-NEXT: Name: name
# YAML-NEXT: FunctionNames:
# YAML-NEXT: FunctionNames:
# YAML-NEXT: - Index: 0
# YAML-NEXT: Name: 'signature_mismatch:ret32'
# YAML-NEXT: - Index: 1
Expand Down
2 changes: 1 addition & 1 deletion lld/wasm/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void SymbolTable::addLazy(StringRef name, InputFile *file) {

LLVM_DEBUG(dbgs() << "replacing existing undefined\n");
const InputFile *oldFile = s->getFile();
replaceSymbol<LazySymbol>(s, name, 0, file)->extract();
LazySymbol(name, 0, file).extract();
if (!config->whyExtract.empty())
ctx.whyExtractRecords.emplace_back(toString(oldFile), s->getFile(), *s);
}
Expand Down