This is an archive of the discontinued LLVM Phabricator instance.

[Driver][MSVC] Move lld specific flags before inputs
ClosedPublic

Authored by HaohaiWen on Jun 29 2023, 7:50 PM.

Details

Summary

Check linker earlier so that lld specific flags can be append before
inputs. Just like position of other flags. The intention is to make
expanded cmd more consistent and elegent so that user can easily
look for inputs when using -###.

Diff Detail

Event Timeline

HaohaiWen created this revision.Jun 29 2023, 7:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 7:50 PM
HaohaiWen requested review of this revision.Jun 29 2023, 7:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 7:50 PM

Is this a NFC change, as a preparation for a separate change? In that case, please add an NFC tag to the subject - if not, please explain (and test) the expected behaviour change.

HaohaiWen added a comment.EditedJun 30 2023, 8:34 PM

Is this a NFC change, as a preparation for a separate change? In that case, please add an NFC tag to the subject - if not, please explain (and test) the expected behaviour change.

The order of lld cmdargs would change from

lld "flags" "inputs" "/vfsoverlay:xxx"

to

lld "flags" "/vfsoverlay:xxx" "inputs"
mstorsjo added a comment.EditedJul 1 2023, 1:36 AM

Ok, thanks for clarifying. However I still don’t understand the “why” aspect here. You’re writing

so that lld specific flags can be append before inputs

Are you planning on adding such flags in a later patch, position dependent flags that need to be supplied before input files?

Or does the change in order of command line arguments have an effect on the behavior of the linker in this case?

Ok, thanks for clarifying. However I still don’t understand the “why” aspect here. You’re writing

so that lld specific flags can be append before inputs

Are you planning on adding such flags in a later patch, position dependent flags that need to be supplied before input files?

Or does the change in order of command line arguments have an effect on the behavior of the linker in this case?

Ok, on second thought, I guess that parsing the vfsoverlay option before the inputs makes it have an effect where it didn’t before. Is that right? (Most flags in lld aren’t very order dependent since it just checks for any occurrence of a flag anywhere among the arguments.)

Ok, thanks for clarifying. However I still don’t understand the “why” aspect here. You’re writing

so that lld specific flags can be append before inputs

Are you planning on adding such flags in a later patch, position dependent flags that need to be supplied before input files?

Or does the change in order of command line arguments have an effect on the behavior of the linker in this case?

Ok, on second thought, I guess that parsing the vfsoverlay option before the inputs makes it have an effect where it didn’t before. Is that right? (Most flags in lld aren’t very order dependent since it just checks for any occurrence of a flag anywhere among the arguments.)

I'm planing to add /dwodir to linker when user specify -gsplit-dwarf and using lld and lto.
The order does not matter.
I just want it looks more consistent and elegent since most flags are before inputs so that user can easily look for inputs when using -###.

mstorsjo accepted this revision.Jul 1 2023, 12:42 PM

Ok, thanks for clarifying. However I still don’t understand the “why” aspect here. You’re writing

so that lld specific flags can be append before inputs

Are you planning on adding such flags in a later patch, position dependent flags that need to be supplied before input files?

Or does the change in order of command line arguments have an effect on the behavior of the linker in this case?

Ok, on second thought, I guess that parsing the vfsoverlay option before the inputs makes it have an effect where it didn’t before. Is that right? (Most flags in lld aren’t very order dependent since it just checks for any occurrence of a flag anywhere among the arguments.)

I'm planing to add /dwodir to linker when user specify -gsplit-dwarf and using lld and lto.
The order does not matter.

Ok, thanks for clarifying that - since I didn't quite understand how this change would be needed for that option.

I just want it looks more consistent and elegent since most flags are before inputs so that user can easily look for inputs when using -###.

Ok, that sounds reasonable. Please clarify that intent in the commit message, and this seems ok to me.

This revision is now accepted and ready to land.Jul 1 2023, 12:42 PM
HaohaiWen edited the summary of this revision. (Show Details)Jul 1 2023, 6:26 PM
This revision was landed with ongoing or failed builds.Jul 1 2023, 6:29 PM
This revision was automatically updated to reflect the committed changes.