warnings about missing symbols when building with the mold linker and lto
Hey, libbsd seems to have some issues during linking when using the mold linker and -flto. I am using mold built from git at commit b04aba89d3a1931470983212925443e7aefca1e1
and libbsd at commit 73b25a8f871b3a20f6ff76679358540f95d7dbfd
. I've turned mold's warnings into errors with -Wl,--fatal-warnings
, so I can catch them more easily. Below is the last few lines of the build log, I am also attaching the complete log.
GCC version used is gcc (Gentoo 13.1.1_p20230527 p3) 13.1.1 20230527
Steps to reproduce:
- install libbsd's build dependencies and mold
- clone libbsd's repo and cd into it
- run
export CFLAGS="-O2 -pipe -flto=auto"
andexport LDFLAGS="-fuse-ld="mold -Wl,--fatal-warnings"
- run
./autogen
and./configure --prefix=/usr
- build libbsd with
make V=1
libtool: link: gcc -shared -fPIC -DPIC .libs/closefrom.o .libs/dehumanize_number.o .libs/err.o .libs/expand_number.o .libs/explicit_bzero.o .libs/fgetln.o .libs/fgetwln.o .libs/flopen.o .libs/fmtcheck.o .libs/fparseln.o .libs/freezero.o .libs/getbsize.o .libs/getpeereid.o .libs/heapsort.o .libs/humanize_number.o .libs/inet_net_pton.o .libs/merge.o .libs/pidfile.o .libs/progname.o .libs/pwcache.o .libs/radixsort.o .libs/readpassphrase.o .libs/reallocarray.o .libs/reallocf.o .libs/recallocarray.o .libs/setmode.o .libs/setproctitle.o .libs/stringlist.o .libs/strnstr.o .libs/strtoi.o .libs/strtonum.o .libs/strtou.o .libs/timeconv.o .libs/unvis.o .libs/vis.o .libs/bsd_getopt.o .libs/arc4random.o .libs/arc4random_uniform.o .libs/md5.o .libs/nlist.o .libs/strlcat.o .libs/strlcpy.o .libs/wcslcat.o .libs/wcslcpy.o .libs/strmode.o .libs/fpurge.o .libs/funopen.o -lmd -O2 -flto=auto -Wl,--version-script=./libbsd.map -fuse-ld=mold -Wl,--fatal-warnings -Wl,-soname -Wl,libbsd.so.0 -o .libs/libbsd.so.0.11.7
mold: error: ./libbsd.map: cannot assign version `LIBBSD_0.2` to symbol `strnvis`: symbol not found
mold: error: ./libbsd.map: cannot assign version `LIBBSD_0.2` to symbol `strnunvis`: symbol not found
mold: error: ./libbsd.map: cannot assign version `LIBBSD_0.5` to symbol `setproctitle`: symbol not found
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:645: libbsd.la] Error 1
make[2]: Leaving directory '/home/kostadin/libbsd/src'
make[1]: *** [Makefile:420: all-recursive] Error 1
make[1]: Leaving directory '/home/kostadin/libbsd'
make: *** [Makefile:352: all] Error 2