Index: lld/ELF/Driver.cpp =================================================================== --- lld/ELF/Driver.cpp +++ lld/ELF/Driver.cpp @@ -572,10 +572,14 @@ // -build-id=sha1 are actually tree hashes for performance reasons. static std::pair> getBuildId(opt::InputArgList &Args) { - if (Args.hasArg(OPT_build_id)) + auto *Arg = Args.getLastArg(OPT_build_id, OPT_build_id_eq); + if (!Arg) + return {BuildIdKind::None, {}}; + + if (Arg->getOption().getID() == OPT_build_id) return {BuildIdKind::Fast, {}}; - StringRef S = getString(Args, OPT_build_id_eq, "none"); + StringRef S = Arg->getValue(); if (S == "md5") return {BuildIdKind::Md5, {}}; if (S == "sha1" || S == "tree") Index: lld/test/ELF/build-id.s =================================================================== --- lld/test/ELF/build-id.s +++ lld/test/ELF/build-id.s @@ -33,6 +33,10 @@ # RUN: ld.lld --build-id=md5 --build-id=none %t -o %t2 # RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s +# RUN: ld.lld --build-id --build-id=none %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s +# RUN: ld.lld --build-id=none --build-id %t -o %t2 +# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=DEFAULT %s .globl _start _start: