llvm-mingw icon indicating copy to clipboard operation
llvm-mingw copied to clipboard

suppress build-id

Open mafemergency opened this issue 2 years ago • 3 comments

i'm unable to suppress the generation of the .buildid section and COFF debug directory when linking a binary without debug info. i would've hoped for --build-id=none however the mingw frontend explicitly disallows[1] this option. when digging in i found a possible toggle[2] from this commit[3] which maybe if i could set config->debug to false all would be well. omitting -g or passing -g0 didn't do the trick. have i missed something or is build-id forced?

1: https://github.com/llvm/llvm-project/blob/c0f0d50653e16145beee474a3d0d602596502dde/lld/MinGW/Options.td#L167 2: https://github.com/llvm/llvm-project/blob/c0f0d50653e16145beee474a3d0d602596502dde/lld/COFF/Writer.cpp#L2000 3: https://github.com/llvm/llvm-project/commit/3c046af5a931055470d23cceaaae3d9903dfe2a9

mafemergency avatar Jun 15 '23 04:06 mafemergency

i'm unable to suppress the generation of the .buildid section and COFF debug directory when linking a binary without debug info.

i would've hoped for --build-id=none however the mingw frontend explicitly disallows[1] this option.

It's not so much "explicitly disallows", as it only knows about the plain --build-id form without any parameters.

If GNU ld supports --build-id=none, I guess we could add support for that too. What other valid parameter values are there, other than none?

when digging in i found a possible toggle[2] from this commit[3] which maybe if i could set config->debug to false all would be well. omitting -g or passing -g0 didn't do the trick. have i missed something or is build-id forced?

If you link with -s or -S for producing stripped output, then config->debug is set to false, and you get no build ID.

mstorsjo avatar Jun 15 '23 06:06 mstorsjo

If you link with -s or -S for producing stripped output, then config->debug is set to false, and you get no build ID.

thank you! this indeed removed .buildid section and debug directory.

If GNU ld supports --build-id=none, I guess we could add support for that too. What other valid parameter values are there, other than none?

fast, md5, sha1/tree, uuid, hex-string, none as seen here: https://github.com/llvm/llvm-project/blob/c0f0d50653e16145beee474a3d0d602596502dde/lld/ELF/Driver.cpp#L850

mafemergency avatar Jun 15 '23 15:06 mafemergency