This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Support setting the subsystem version via the subsystem argument
ClosedPublic

Authored by mstorsjo on Oct 4 2020, 1:07 PM.

Details

Summary

If a version is specified both with --{major,minor}-subsystem-version and with --subsystem <name>:<version>, the one specified last (that actually sets a version) takes precedance in GNU ld; thus doing the same here.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 4 2020, 1:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2020, 1:07 PM

With BFD (tested version 2.35) the latter specified option takes precedence:

$ gcc clear.c -Wl,--subsystem,windows:7.8,--major-subsystem-version,2,--minor-subsystem-version,3
$ llvm-readobj -h a.exe | grep SubsystemVersion
  MajorSubsystemVersion: 2
  MinorSubsystemVersion: 3

$ gcc clear.c -Wl,--major-subsystem-version,2,--minor-subsystem-version,3,--subsystem,windows:7.8
$ llvm-readobj -h a.exe | grep SubsystemVersion
  MajorSubsystemVersion: 7
  MinorSubsystemVersion: 8

With BFD (tested version 2.35) the latter specified option takes precedence:

$ gcc clear.c -Wl,--subsystem,windows:7.8,--major-subsystem-version,2,--minor-subsystem-version,3
$ llvm-readobj -h a.exe | grep SubsystemVersion
  MajorSubsystemVersion: 2
  MinorSubsystemVersion: 3

$ gcc clear.c -Wl,--major-subsystem-version,2,--minor-subsystem-version,3,--subsystem,windows:7.8
$ llvm-readobj -h a.exe | grep SubsystemVersion
  MajorSubsystemVersion: 7
  MinorSubsystemVersion: 8

Oh, tricky. Will have to see if we can match that with reasonable effort...

mstorsjo updated this revision to Diff 296157.Oct 5 2020, 5:21 AM
mstorsjo edited the summary of this revision. (Show Details)

Updated to iterate over --{major,minor}-subsystem-version and --subsystem, to pick the version from the last one that specifies it.

mati865 accepted this revision.Oct 5 2020, 5:39 AM
This revision is now accepted and ready to land.Oct 5 2020, 5:39 AM