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

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 01:20:44 PST 2023


================
@@ -393,5 +393,5 @@ RUN: ld.lld -### foo.o -m i386pep -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_6
 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
+RUN: ld.lld -### foo.o -m i386pep -build-id=none 2>&1 | FileCheck -check-prefix=NO_BUILD_ID %s
----------------
mstorsjo wrote:

The canonical form of the option, for the MinGW/ELF driver, is with two leading dashes, `--build-id`. (The ELF style linker uses a single dash for single-char options like `-s`, and double dashes for long options like `--strip-all`, while the MS link.exe style linker uses either `/` or `-` with all options.) In this case, in GNU ld (which uses `getopt_long`), does handle it if passed with one leading dash as well (which means that the `J<>` type in Options.td is right - if only double dashes works, we should have used `JJ<>` instead); but we should at least test the canonical form (we could test the other form with only one leading dash as well, but I don't think there's any reason to do that here).

But we should also test two other cases:
- The plain `--build-id` without argument. Previously this was plain ignored, now we need to check that it does what it should.
- As we're changing the lld-link defaults, we also need to test that `ld.lld` without any `--build-id` option still adds the build id

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


More information about the llvm-commits mailing list