-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lld][COFF] Add /linkreprofullpathrsp flag #165449
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
Open
DavidTruby
wants to merge
9
commits into
llvm:main
Choose a base branch
from
DavidTruby:lrfpr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−13
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e49faac
[lld][COFF] Add /linkreprofullpathrsp flag
DavidTruby f34b707
Actually find the full path
DavidTruby 5070301
Fix failing test
DavidTruby 822cc21
Add pdbs and wholearchives to the linkrepro file
DavidTruby acb00f7
Add pdb to test
DavidTruby db873da
Fix tests
DavidTruby 173c1fd
Flush and close file at the end of LinkerMain
DavidTruby 9a99826
Fix path separator in tests
DavidTruby 8f4d0f5
Add test that re-linking produces same binary
DavidTruby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # REQUIRES: x86 | ||
|
|
||
| # RUN: rm -rf %t.dir %t.obj | ||
| # RUN: yaml2obj %p/Inputs/hello32.yaml -o %t.obj | ||
| # RUN: yaml2obj %p/Inputs/empty.yaml -o %t.archive.obj | ||
| # RUN: rm -f %t.archive.lib | ||
| # RUN: llvm-ar rcs %t.archive.lib %t.archive.obj | ||
| # RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-simple-ts.yaml -pdb %t.pdb | ||
|
|
||
|
|
||
| Test link.exe-style /linkreprofullpathrsp: flag. | ||
| # RUN: mkdir -p %t.dir/build1 | ||
| # RUN: cd %t.dir/build1 | ||
| # RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console /defaultlib:%p/Inputs/library.lib \ | ||
| # RUN: /libpath:%p/Inputs /defaultlib:std64.lib ret42.lib /entry:main@0 /linkreprofullpathrsp:%t.rsp \ | ||
| # RUN: /wholearchive:%t.archive.lib /out:%t.exe %t.pdb | ||
| # RUN: FileCheck %s --check-prefix=RSP -DT=%t -DP=%p < %t.rsp | ||
|
|
||
| # RUN: lld-link @%t.rsp /out:%t2.exe /entry:main@0 | ||
| # RUN: diff %t.exe %t2.exe | ||
|
|
||
| # RSP: "[[T]].obj" | ||
| # RSP-NEXT: "[[P]]{{[/\\]}}Inputs{{[/\\]}}std32.lib" | ||
| # RSP-NEXT: "[[P]]{{[/\\]}}Inputs{{[/\\]}}ret42.lib" | ||
| # RSP-NEXT: "/wholearchive:[[T]].archive.lib" | ||
| # RSP-NEXT: "[[T]].pdb" | ||
| # RSP-NEXT: "/defaultlib:[[P]]{{[/\\]}}Inputs{{[/\\]}}library.lib" | ||
| # RSP-NEXT: "/defaultlib:[[P]]{{[/\\]}}Inputs{{[/\\]}}std64.lib" | ||
|
|
||
| #--- drectve.s | ||
| .section .drectve, "yn" | ||
| .ascii "/defaultlib:std32" | ||
|
|
||
| #--- archive.s | ||
| .text | ||
| .intel_syntax noprefix | ||
| .globl exportfn3 | ||
| .p2align 4 | ||
| exportfn3: | ||
| ret | ||
|
|
||
| .section .drectve,"yni" | ||
| .ascii " /EXPORT:exportfn3" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably exercice the link command a second time, by using the generated .rsp to ensure it works as expected. It wouldn't be bad if we checked afterwards some expected outcomes, such as the presence of symbols in the binary as well as the presence of debug info (and maybe ensure no warnings are generated).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any advice on how I could go about doing that? I'm not really a linker expert and this is my first LLD patch in a long while so I'm kinda learning as I'm going 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do
lld-link input1.obj input2.obj /listreprofullpathrsp:file.rspthen in a second execution you could dolld-link @file.rspwhich should yield the same outcomes (same warnings if any, same outputs).As for warnings, you can do
RSP-NOT: warningto ensure the absence of warnings. Same thing for debug info, assuming that/debugis used during the link phase, you can usellvm-pdbutil dump -all %t.pdb | FileCheck %s ...to ascertain that same important debug information is there. Usually you can run thatllvm-pdbutilcommand manually on your local machine, and copy-paste in the test a few lines that should be important.