At first it looked like a fluke when building a release. What's this "ld -dc" command-line? Well -dc is short for --define-common, an option that has been dropped by upstream llvm(lld).
IIUC this ld(1) behavior is somewhat similar to -fno-common for cc(1). base-clang already does -fno-common by default, base-gcc does not. The diff below replaces ld -dc by cc -fno-common, but TBF I'm not sure what we're trying to achieve (avoid?) here. A test (make build + release) on a base-gcc arch would be welcome. commit 6cf10f57e9d6a5c359007e7b75ed737be8954bb4 Author: jca <j...@wxcvbn.org> Date: Wed Dec 28 16:36:41 2022 +0100 crunchgen: stop using ld -dc (dropped in lld 15) Instead, use cc -fno-common to prevent base-gcc from using commons. base-clang already does the right thing. diff --git a/usr.sbin/crunchgen/crunchgen.c b/usr.sbin/crunchgen/crunchgen.c index 4526290197e..6350b61195b 100644 --- a/usr.sbin/crunchgen/crunchgen.c +++ b/usr.sbin/crunchgen/crunchgen.c @@ -893,12 +893,13 @@ top_makefile_rules(FILE * outmk) fprintf(outmk, ".include <bsd.own.mk>\n"); fprintf(outmk, "CFLAGS+=$(NOPIE_FLAGS)\n"); fprintf(outmk, "CFLAGS+=-Oz\n"); + fprintf(outmk, "CFLAGS+=-fno-common\n"); fprintf(outmk, "CFLAGS+=-fno-stack-protector\n"); fprintf(outmk, "CFLAGS+=-fno-unwind-tables\n"); fprintf(outmk, "CFLAGS+=-fno-asynchronous-unwind-tables\n"); fprintf(outmk, "LDFLAGS+=$(NOPIE_LDFLAGS)\n"); fprintf(outmk, "STRIP?=strip\n"); - fprintf(outmk, "LINK=$(LD) -dc -r ${LDFLAGS}\n"); + fprintf(outmk, "LINK=$(LD) -r ${LDFLAGS}\n"); fprintf(outmk, "LIBS="); for (l = libdirs; l != NULL; l = l->next) fprintf(outmk, " -L%s", l->str); diff --git a/usr.sbin/crunchgen/crunchide.c b/usr.sbin/crunchgen/crunchide.c index 16e032370db..84539fb57be 100644 --- a/usr.sbin/crunchgen/crunchide.c +++ b/usr.sbin/crunchgen/crunchide.c @@ -29,7 +29,7 @@ * crunchide.c - tiptoes through an a.out symbol table, hiding all defined * global symbols. Allows the user to supply a "keep list" of symbols * that are not to be hidden. This program relies on the use of the - * linker's -dc flag to actually put global bss data into the file's + * compiler's -fno-common flag to actually put global bss data into the file's * bss segment (rather than leaving it as undefined "common" data). * * The point of all this is to allow multiple programs to be linked @@ -39,8 +39,8 @@ * small stub routine, called "foostub.c", eg: * int foo_main(int argc, char **argv){ return main(argc, argv); } * like so: - * cc -c foo.c foostub.c - * ld -dc -r foo.o foostub.o -o foo.combined.o + * cc -fno-common -c foo.c foostub.c + * ld -r foo.o foostub.o -o foo.combined.o * crunchide -k _foo_main foo.combined.o * at this point, foo.combined.o can be linked with another program * and invoked with "foo_main(argc, argv)". foo's main() and any -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE