[LLD] [COFF] Implement MinGW default manifest handling
authorMartin Storsjo <martin@martin.st>
Wed, 4 Sep 2019 20:34:00 +0000 (20:34 +0000)
committerMartin Storsjo <martin@martin.st>
Wed, 4 Sep 2019 20:34:00 +0000 (20:34 +0000)
commitd581dd50138186fe2c29eff617e7ca5897e3c69e
tree8c2400b2af40312f8bcde615019c793305802778
parenta6e8b685e13492abfb2e58dc49007deda165a00d
[LLD] [COFF] Implement MinGW default manifest handling

In mingw environments, resources are normally compiled to resource
object files directly, instead of letting the linker convert them to
COFF format.

Since some time, GCC supports the notion of a default manifest object.
When invoking the linker, GCC looks for the default manifest object
file, and if found in the expected path, it is added to linker commands.

The default manifest is one that indicates support for the latest known
versions of windows, to implicitly unlock the modern behaviours of certain
APIs.

Not all mingw/gcc distributions include this file, but e.g. in msys2,
the default manifest object is distributed in a separate package (which
can be but might not always be installed).

This means that even if user projects only use one single resource
object file, the linker can end up with two resource object files,
and thus needs to support merging them.

The default manifest has a language id of zero, and GNU ld has got
logic for dropping a manifest with a zero language id, if there's
another manifest present with a nonzero language id. If there are
multiple manifests with a nonzero language id, the merging process
errors out.

Differential Revision: https://reviews.llvm.org/D66825

llvm-svn: 370974
lld/COFF/DriverUtils.cpp
lld/test/COFF/Inputs/manifest-lang0.res [new file with mode: 0644]
lld/test/COFF/Inputs/manifest-lang0.yaml [new file with mode: 0644]
lld/test/COFF/Inputs/manifest-lang1.res [new file with mode: 0644]
lld/test/COFF/Inputs/manifest-lang1.yaml [new file with mode: 0644]
lld/test/COFF/Inputs/manifest-lang2.res [new file with mode: 0644]
lld/test/COFF/Inputs/manifest-lang2.yaml [new file with mode: 0644]
lld/test/COFF/merge-resource-manifest.test [new file with mode: 0644]
llvm/include/llvm/Object/WindowsResource.h
llvm/lib/Object/WindowsResource.cpp