Re: clang 17 and ports fallout

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 08 Jan 2024 22:50:31 UTC
On 8 Jan 2024, at 21:57, mike tancsa <mike@sentex.net> wrote:
> 
> On 1/8/2024 3:40 PM, mike tancsa wrote:
>> After today's MFC of clang17,  I am seeing some fallout from a few ports that build with clang16 on RELENG_13 but now fail.  Any ideas what might be going on ?   I have nothing in /etc/make.conf nor /etc/src.conf
>> 
> These build on RELENG_14, so perhaps something still needs to be MFC'd to RELENG_13 ?
> 
> I have tried both with and without poudriere. Same error in poudriere
> 
> d_la-rrd_update.lo librrdupd_la-rrd_modify.lo librrdupd_la-quicksort.lo librrdupd_la-rrd_thread_safe.lo  -lm -lwrap -lglib-2.0 -lintl
> libtool: link: ar cr .libs/librrdupd.a .libs/librrdupd_la-mutex.o libs/librrdupd_la-optparse.o .libs/librrdupd_la-rrd_strtod.o libs/librrdupd_la-rrd_create.o .libs/librrdupd_la-hash_32.o libs/librrdupd_la-rrd_parsetime.o .libs/librrdupd_la-rrd_hw.o libs/librrdupd_la-rrd_hw_math.o .libs/librrdupd_la-rrd_hw_update.o libs/librrdupd_la-rrd_diff.o .libs/librrdupd_la-rrd_format.o libs/librrdupd_la-rrd_info.o .libs/librrdupd_la-rrd_error.o libs/librrdupd_la-rrd_open.o .libs/librrdupd_la-rrd_client.o libs/librrdupd_la-rrd_nan_inf.o .libs/librrdupd_la-rrd_rpncalc.o libs/librrdupd_la-rrd_utils.o .libs/librrdupd_la-rrd_snprintf.o libs/librrdupd_la-rrd_update.o .libs/librrdupd_la-rrd_modify.o libs/librrdupd_la-quicksort.o .libs/librrdupd_la-rrd_thread_safe.o
> libtool: link: ranlib .libs/librrdupd.a
> libtool: link: ( cd ".libs" && rm -f "librrdupd.la" && ln -s "../librrdupd.la" "librrdupd.la" )
> /bin/sh ../libtool  --tag=CC   --mode=link cc -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -D_GNU_SOURCE -fno-strict-aliasing -Wall -std=gnu99 -pedantic -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wold-style-definition -W -I.. -D_THREAD_SAFE -pthread -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -D_GNU_SOURCE -fno-strict-aliasing -Wall -std=gnu99 -pedantic -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wold-style-definition -W  -version-info 11:0:3 -export-symbols ./librrd.sym  -fstack-protector-strong  -L/usr/local/lib -L/usr/local/lib  -o librrd.la -rpath /usr/local/lib librrd_la-rrd_version.lo librrd_la-rrd_last.lo librrd_la-rrd_lastupdate.lo librrd_la-rrd_first.lo librrd_la-rrd_dump.lo librrd_la-rrd_flushcached.lo librrd_la-rrd_fetch.lo librrd_la-rrd_fetch_cb.lo librrd_la-rrd_resize.lo librrd_la-rrd_tune.lo librrd_la-rrd_list.lo  librrd_la-rrd_restore.lo   librrdupd.la -lglib-2.0 -lintl -lm -lwrap -lxml2
> libtool: link: echo "{ global:" > .libs/librrd.so.8.3.0-ver
> libtool: link:           sed -e "s|$|;|" < ./librrd.sym >> libs/librrd.so.8.3.0-ver
> libtool: link:   echo "local: *; };" >> .libs/librrd.so.8.3.0-ver
> libtool: link: cc -shared  -fPIC -DPIC .libs/librrd_la-rrd_version.o libs/librrd_la-rrd_last.o .libs/librrd_la-rrd_lastupdate.o libs/librrd_la-rrd_first.o .libs/librrd_la-rrd_dump.o libs/librrd_la-rrd_flushcached.o .libs/librrd_la-rrd_fetch.o libs/librrd_la-rrd_fetch_cb.o .libs/librrd_la-rrd_resize.o libs/librrd_la-rrd_tune.o .libs/librrd_la-rrd_list.o libs/librrd_la-rrd_restore.o -Wl,--whole-archive ./.libs/librrdupd.a -Wl,--no-whole-archive -L/usr/local/lib -lglib-2.0 -lintl -lm -lwrap -lxml2  -O2 -fstack-protector-strong -pthread -O2 -fstack-protector-strong -fstack-protector-strong   -pthread -Wl,-soname -Wl,librrd.so.8 -Wl,-version-script -Wl,.libs/librrd.so.8.3.0-ver -o libs/librrd.so.8.3.0
> ld: error: version script assignment of 'global' to symbol 'rrd_graph' failed: symbol not defined
> ld: error: version script assignment of 'global' to symbol 'rrd_graph_v' failed: symbol not defined
> ld: error: version script assignment of 'global' to symbol 'rrd_lcd' failed: symbol not defined
> ld: error: version script assignment of 'global' to symbol 'rrd_reduce_data' failed: symbol not defined
> ld: error: version script assignment of 'global' to symbol 'rrd_xport' failed: symbol not defined
> cc: error: linker command failed with exit code 1 (use -v to see invocation)
> gmake[3]: *** [Makefile:773: librrd.la] Error 1
> gmake[3]: Leaving directory '/wrkdirs/usr/ports/databases/rrdtool/work/rrdtool-1.8.0/src'
> gmake[2]: *** [Makefile:618: all] Error 2
> gmake[2]: Leaving directory '/wrkdirs/usr/ports/databases/rrdtool/work/rrdtool-1.8.0/src'
> gmake[1]: *** [Makefile:504: all-recursive] Error 1
> gmake[1]: Leaving directory '/wrkdirs/usr/ports/databases/rrdtool/work/rrdtool-1.8.0'
> *** Error code 1

I fixed a lot of ports in the run-up to merging llvm-17 in 15-CURRENT,
but I could not get them all.

The preferred way is fixing the port by removing the undefined symbols
from the linker version script in the port, but if that is not possible
or difficult, add -Wl,--undefined-version to the linker flags suppresses
the error. E.g. in the port Makefile:

LDFLAGS+=	-Wl,--undefined-version

For an example, see:

https://github.com/freebsd/freebsd-ports/commit/37790b26cbda11cd4bb6f237b86cd94739c4059c

-Dimitry