[lld] [LLD][COFF] Add -build-id flag to generate .buildid section. (PR #71433)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 13:52:27 PST 2023


================
@@ -389,3 +389,9 @@ Test GCC specific LTO options that GCC passes unconditionally, that we ignore.
 
 RUN: ld.lld -### foo.o -m i386pep -plugin /usr/lib/gcc/x86_64-w64-mingw32/10-posix/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/10-posix/lto-wrapper -plugin-opt=-fresolution=/tmp/ccM9d4fP.res -plugin-opt=-pass-through=-lmingw32 2> /dev/null
 RUN: ld.lld -### foo.o -m i386pep -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/liblto_plugin.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/cckbC7wB.res -plugin-opt=-pass-through=-lmingw32 2> /dev/null
+
+RUN: ld.lld -### foo.o -m i386pep 2>&1 | FileCheck -check-prefix=BUILD_ID %s
+BUILD_ID:-build-id
+
+RUN: ld.lld -### foo.o -m i386pep -no-build-id 2>&1 | FileCheck -check-prefix=NO_BUILD_ID %s
----------------
mstorsjo wrote:

We shouldn't be making up a new option format here; as there is precedent for GNU ld (and in general for ELF style linkers within LLD as well), we should follow that.

In lld/ELF/Options, we have this:
```
def build_id: J<"build-id=">, HelpText<"Generate build ID note">,
  MetaVarName<"[fast,md5,sha1,uuid,0x<hexstring>]">;
```
So we probably should do roughly the same for MinGW as well. We don't really support all these other options (but we can maybe warn and say that we don't do e.g. md5/sha1/whatever, but use some unspecified hash?), but `--build-id=none` should at least be handled.

https://github.com/llvm/llvm-project/pull/71433


More information about the llvm-commits mailing list