[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


================
@@ -302,7 +302,16 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
   } else if (!args.hasArg(OPT_strip_all)) {
     add("-debug:dwarf");
   }
-  add(args.hasArg(OPT_no_build_id) ? "-build-id:no" : "-build-id");
+  if (auto *a = args.getLastArg(OPT_build_id)) {
+    StringRef v = a->getValue();
+    if (v == "none")
+      add("-build-id:no");
+    else if (v.empty())
+      add("-build-id");
+    else
+      warn("unsupported build id hashing: " + a->getSpelling());
----------------
mstorsjo wrote:

As the default is `-build-id`, I think it's probably best to keep doing that for the unhandled cases as well. Practically speaking, e.g. if someone invokes it as `--build-id=fast` (which seems to be the default in the ELF case), we could warn about `fast` being unsupported, but the most logical fallback probably is to still generate the build-id.

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


More information about the llvm-commits mailing list