Cross-posted to https://github.com/llvm/llvm-project/issues/53660
Before 2017-01, ld.lld used to allocate space for COMMON symbols in
-r mode. This was fixed by ⚙ D28984 [LLD] Do not allocate space for common symbols with -r
⚙ D28984 [LLD] Do not allocate space for common symbols with -r added some options along with the fix:
--no-define-common: inherited from gold and incompatible with GNU ld (28871 – gold: --no-define-common is incompatible with GNU ld). According to https://codesearch.debian.net/search , there is no usage.
-dp: I’ve tried a few patterns and am convinced that grub has something like
-dpdo not have usage.
-dp, the option is only effective in
-r mode. Ignoring the option is a correct implementation, unless (hypothetically) a project takes
-r output and interprets it in its own way and somehow doesn’t support
SHN_COMMON input. This seems extremely unlikely as if it deals with normal relocatable object files printed by the assembler, it needs to support
% gcc -fpic -fcommon -r -fuse-ld=bfd b.c -o b.ro && readelf -Ws b.ro | egrep 'Num:| x' Num: Value Size Type Bind Vis Ndx Name 9: 0000000000000004 4 OBJECT GLOBAL DEFAULT COM x % gcc -fpic -fcommon -r -fuse-ld=bfd -Wl,-dc b.c -o b.ro && readelf -Ws b.ro | egrep 'Num:| x' Num: Value Size Type Bind Vis Ndx Name 9: 0000000000000000 4 OBJECT GLOBAL DEFAULT 7 x
So I suggest we remove
--no-define-common, and make
-dp a no-op. Since
-dp do look like unused, remove them. -d may need to be kept for a while.
For the upcoming 14.0.0 release, I think we can warn about the options:
if (args.hasArg(OPT_define_common, OPT_no_define_common)) warn("-d, -dc, -dp, and --[no-]define-common are ignored and will be removed. See https://github.com/llvm/llvm-project/issues/53660");
The warning will (a) give us idea whether they are really unused, (b) push projects to remove the options, (c) decide whether we should (actually quite trivial) keep them with full functionality, keep them as ignored options, or remove them altogether.