Skip to content
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

LLD "foo.lib -wholearchive:foo.lib" doesn't work #36940

Closed
rnk opened this issue May 25, 2018 · 4 comments
Closed

LLD "foo.lib -wholearchive:foo.lib" doesn't work #36940

rnk opened this issue May 25, 2018 · 4 comments
Labels
bugzilla Issues migrated from bugzilla lld:COFF

Comments

@rnk
Copy link
Collaborator

rnk commented May 25, 2018

Bugzilla Link 37592
Resolution FIXED
Resolved on Aug 30, 2018 11:04
Version unspecified
OS Windows NT
CC @nico,@rui314,@sesse

Extended Description

Consider:

$ cat a.c
int foo() { return 1; }

$ cat b.c
int bar() { return 2; }

$ cat t.c
int foo();
int main() {
return foo();
}

$ cl -c t.c a.c b.c && lld-link /LIB a.obj b.obj -out:foo.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26131.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

t.c
a.c
b.c
Generating Code...

$ lld-link t.obj foo.lib -wholearchive:foo.lib -out:t.exe -verbose -nodefaultlib -entry:main
C:\src\llvm-project\build\bin\lld-link.exe: Reading t.obj
C:\src\llvm-project\build\bin\lld-link.exe: Directives: t.obj: /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES"
C:\src\llvm-project\build\bin\lld-link.exe: Reading foo.lib
C:\src\llvm-project\build\bin\lld-link.exe: Reading foo.lib(a.obj)
C:\src\llvm-project\build\bin\lld-link.exe: Directives: foo.lib(a.obj): /DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES"
C:\src\llvm-project\build\bin\lld-link.exe: Loaded foo.lib(a.obj) for foo
C:\src\llvm-project\build\bin\lld-link.exe: ICF needed 2 iterations

As you can see from the verbose output, b.obj is not loaded, but it is if I swap in link.exe:

$ link t.obj foo.lib -wholearchive:foo.lib -out:t.exe -verbose -nodefaultlib -entry:main
Microsoft (R) Incremental Linker Version 14.13.26131.1
Copyright (C) Microsoft Corporation. All rights reserved.

Processed /NODEFAULTLIB (suppressing all default libs)

Starting pass 1
Loaded foo.lib(a.obj)
Loaded foo.lib(b.obj)

Searching libraries
Searching foo.lib:

Finished searching libraries

Finished pass 1

Starting pass 2
t.obj
foo.lib(b.obj)
foo.lib(a.obj)
Finished pass 2

This is causing Chromium's base_unittests tests to fail with asan, which uses wholearchive.

@nico
Copy link
Contributor

nico commented Jun 1, 2018

ruiu's https://reviews.llvm.org/D41094 might have regressed this (?)

@rui314
Copy link
Member

rui314 commented Jun 1, 2018

Not sure about that, but a fix is under review: https://reviews.llvm.org/D47565

@rnk
Copy link
Collaborator Author

rnk commented Jun 12, 2018

*** Bug #34691 has been marked as a duplicate of this bug. ***

@nico
Copy link
Contributor

nico commented Aug 30, 2018

rL334552 / r334761.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla lld:COFF
Projects
None yet
Development

No branches or pull requests

3 participants