[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#955166: FTBFS with gcc-9: undefined reference to bsd_getopt, etc.



Package: src:kfreebsd-10
Version: 10.3~svn300087-5
Severity: serious
Tags: patch

kfreebsd-10 FTBFS with gcc-9 due to:

| gcc-9 -D_GNU_SOURCE -isystem /usr/include/freebsd -I/home/build/kfreebsd-10-10.3~svn300087/flavor-10.3-0-amd64/sys/modules/aic7xxx/aicasm -I../../../dev/aic7xxx/aicasm -std=gnu99  -fstack-protector -Wno-pointer-sign  -Wno-missing-prototypes -ldb -lbsd -o aicasm aicasm.o aicasm_symbol.o aicasm_gram.o aicasm_macro_gram.o aicasm_scan.o aicasm_macro_scan.o -ll
| /usr/bin/ld: aicasm.o: in function `main':
| aicasm.c:(.text+0x4a1): undefined reference to `bsd_getopt'
| /usr/bin/ld: aicasm_symbol.o: in function `symtable_open':
| aicasm_symbol.c:(.text+0x220): undefined reference to `__db185_open'
| collect2: error: ld returned 1 exit status
| *** [aicasm] Error code 1

The linker invocation now adds the "--as-needed" parameter by default,
before -ldb and -lbsd, and furthermore those libraries were linked in
before the object files which use their functions:

| /usr/lib/gcc/x86_64-kfreebsd-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-kfreebsd-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-kfreebsd-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccgJKsnR.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64_fbsd --hash-style=gnu --as-needed -dynamic-linker /lib/ld-kfreebsd-x86-64.so.1 -pie -o aicasm /usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../../x86_64-kfreebsd-gnu/Scrt1.o /usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../../x86_64-kfreebsd-gnu/crti.o /usr/lib/gcc/x86_64-kfreebsd-gnu/9/crtbeginS.o -L/usr/lib/gcc/x86_64-kfreebsd-gnu/9 -L/usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../../x86_64-kfreebsd-gnu -L/usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../../../lib -L/lib/x86_64-kfreebsd-gnu -L/lib/../lib -L/usr/lib/x86_64-kfreebsd-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../.. -ldb -lbsd a
 icasm.o aicasm_symbol.o aicasm_gram.o aicasm_macro_gram.o aicasm_scan.o aicasm_macro_scan.o -ll -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-kfreebsd-gnu/9/crtendS.o /usr/lib/gcc/x86_64-kfreebsd-gnu/9/../../../x86_64-kfreebsd-gnu/crtn.o

As a result, those libraries would not be linked in at all.  Object
files aicasm.o, aicasm_symbol.o subsequently cannot find find the
required functions.

I've fixed this by using LDADD within the Makefile, instead of
LDFLAGS within our debian/rules, to add the library dependencies.
Now the library dependencies are added after the object files,
as they should be.

-- System Information:
Debian Release: 8.0
  APT prefers stable-kfreebsd-proposed-updates
  APT policy: (500, 'stable-kfreebsd-proposed-updates'), (500, 'stable-kfreebsd')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 10.1-0-amd64
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
Date: Fri, 27 Mar 2020 21:26:21 +0000
From: Steven Chamberlain <steven@pyro.eu.org>
Subject: Add extra libs required to build aicasm

--- a/sys/dev/aic7xxx/aicasm/Makefile
+++ b/sys/dev/aic7xxx/aicasm/Makefile
@@ -14,7 +14,7 @@ GENHDRS=      aicasm_gram.h aicasm_macro_gram
 SRCS=  ${GENHDRS} ${CSRCS} ${YSRCS} ${LSRCS}
 CLEANFILES+= ${GENHDRS} ${YSRCS:R:C/(.*)/\1.output/g}
 DPADD= ${LIBL}
-LDADD= -ll
+LDADD= -ldb -lbsd -ll
 WARNS?=        0
 
 # Correct path for kernel builds

Reply to: