As everyone is probably tired of hearing now I normally build NetBSD almost entirely fully static-linked. Static-linked programs start up a _lot_ faster and my systems are generally much snappier than equivalent systems would be with stock dynamic-linked builds. This makes a huge difference for some jobs, such as system builds. Individually static linking prepares/"proves" the system for full crunchgen static linking too (which I have done to NetBSD-5). However I do find all kinds of rather ugly broken assumptions about how programs should be linked, etc. And then there are some even more interesting surprises! So, it seems like sometime in the last year common symbols are no longer marked as common! For reference, from nm(1): "B" The symbol is in the BSS data section.. This section typically contains zero-initialized or uninitialized data, although the exact behavior is system dependent. "C" The symbol is common. Common symbols are uninitialized data. When linking, multiple common symbols may appear with the same name. If the symbol is defined anywhere, the common symbols are treated as undefined references. And from ld(1): The linker merges multiple common symbols for the same variable into a single symbol. Here's a real-world example showing the move from C to B: 9.99.81 $ nm /usr/lib/librumpnet.a | fgrep rumpns_ifnet 0000000000000010 C rumpns_ifnet_list 0000000000000008 C rumpns_ifnet_mtx 0000000000000008 C rumpns_ifnet_pslist U rumpns_ifnet_pslist 10.99.11 $ nm /usr/lib/librumpnet.a | fgrep rumpns_ifnet 0000000000000010 B rumpns_ifnet_list 0000000000000000 B rumpns_ifnet_mtx 0000000000000008 B rumpns_ifnet_pslist U rumpns_ifnet_pslist This results in the mess shown below because, I think, the linker can no longer assume that each reference is to a common object, yet multiple objects are loaded from different libraries which each define the same symbol(s). Part of the problem might be that these variables are defined each in a separate source module, and only once. But "it used to work"! I seem to remember some discussion or notice about this, perhaps not directly related to NetBSD, but I can't find it again. Perhaps this is fallout from a compiler or binutils upgrade? /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x0): multiple definition of `rumpns_ifnet_mtx'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.data.cacheline_aligned+0x0): first defined here /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x8): multiple definition of `rumpns_ifnet_pslist'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.bss+0x8): first defined here /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x10): multiple definition of `rumpns_ifnet_list'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.bss+0x10): first defined here /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x0): multiple definition of `rumpns_ifnet_mtx'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.data.cacheline_aligned+0x0): first defined here /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x8): multiple definition of `rumpns_ifnet_pslist'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.bss+0x8): first defined here /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/lib/gcc/x86_64--netbsd/12.4.0/../../../../x86_64--netbsd/bin/ld: /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet.a(net_stub.o):(.bss+0x10): multiple definition of `rumpns_ifnet_list'; /Users/woods/build/woods/very.local/trunk-amd64-destdir/usr/lib/librumpnet_net.a(if.o):(.bss+0x10): first defined here collect2: error: ld returned 1 exit status collect2: error: ld returned 1 exit status *** Failed target: t_bpfjit *** In directory: /Volumes/work/woods/g-NetBSD-src/tests/net/bpfjit *** Failed commands: ${_MKTARGET_LINK} => @echo ' ' " link " bpfjit/t_bpfjit ${_CCLINK.${:Ut_bpfjit}} ${_LDFLAGS.${:Ut_bpfjit}} ${_LDSTATIC.${:Ut_bpfjit}} -o ${.TARGET} ${OBJS.${:Ut_bpfjit}} ${_PROGLDOPTS} ${_LDADD.${:Ut_bpfjit}} => /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/bin/x86_64--netbsd-gcc --sysroot=/Users/woods/build/woods/very.local/trunk-amd64-destdir -Wl,--warn-shared-textrel -Wl,-z,relro -static -o t_bpfjit t_bpfjit.o -lrumpnet_bpfjit -lrumpkern_sljit -lrumpdev_bpf -lrumpnet_net -lrumpnet -lrumpvfs -lrumpvfs_nofifofs -lrump -lrumpuser -lpthread -latf-c ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${:Ut_bpfjit}} => /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/bin/nbctfmerge -t -g -L VERSION -g -o t_bpfjit t_bpfjit.o ${PAXCTL} ${PAXCTL_FLAGS.${:Ut_bpfjit}} ${.TARGET} => /Users/woods/build/woods/very.local/trunk-x86_64-amd64-tools/bin/nbpaxctl +m t_bpfjit *** [t_bpfjit] Error code 1 -- Greg A. Woods <gwoods%acm.org@localhost> Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost> Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgp5UF292SulK.pgp
Description: OpenPGP Digital Signature