[LLD] [COFF] Implement MinGW default manifest handling
commiteb4fbb65902c2c9b1b87d9becffa8b55f090aa87
authorMartin Storsjo <martin@martin.st>
Wed, 4 Sep 2019 20:34:00 +0000 (4 20:34 +0000)
committerMartin Storsjo <martin@martin.st>
Wed, 4 Sep 2019 20:34:00 +0000 (4 20:34 +0000)
treef3025b3918f8ef8881fff501e7030a2774330668
parent5033aa103b56b74eccc552d7caf5d8f31b651dbe
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370974 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Object/WindowsResource.h
lib/Object/WindowsResource.cpp