Re: clang 17 and ports fallout

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 10 Jan 2024 16:22:10 UTC
On 10 Jan 2024, at 13:16, mike tancsa <mike@sentex.net> wrote:
> 
> On 1/10/2024 2:53 AM, Antoine Brodin wrote:
>> 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
>>> 
>>> Thanks very much! That did indeed fix databases/rrdtool and and sysutils/flashrom builds. What is the best way to flag any such issues ? Just open a PR for each individual port ?
>>> 
>> Hello,
>> 
>> databases/rrdtool builds fine on stable/13 here:
>> https://pkg-status.freebsd.org/gohan04/data/stable13amd64-default-foo/2024-01-09_21h18m24s/logs/rrdtool-1.8.0_2.log
>> 
>> 
> I am not sure why it fails for me both in poudrier and outside it. But the same type of error as 
> https://pkg-status.freebsd.org/gohan04/data/stable13amd64-default-foo/2024-01-09_21h18m24s/logs/errors/ivykis-0.42.4.log
> and adding 
> LDFLAGS+= -Wl,--undefined-version
> 
> 
> fixes it for me
> I just checked on releng_14 that also has clang 17 MFCd and I get the same error on the port. I am building it with less features than the default so not sure if that makes it fail in my environment. However the same options work with clang16
> /usr/local/lib  -L/usr/local/lib  -o rrdupdate rrdupdate.o librrdupd.la 
> libtool: link: cc -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -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.. -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -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 -fstack-protector-strong -o rrdupdate rrdupdate.o  -L/usr/local/lib ./.libs/librrdupd.a -lm -lwrap -lglib-2.0 -lintl -pthread
> 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 -Wl,-rpath -Wl,/usr/local/lib   -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[4]: *** [Makefile:773: librrd.la] Error 1
> gmake[4]: Leaving directory '/usr/ports/databases/rrdtool/work/rrdtool-1.8.0/src'
> gmake[3]: *** [Makefile:618: all] Error 2
> gmake[3]: Leaving directory '/usr/ports/databases/rrdtool/work/rrdtool-1.8.0/src'
> gmake[2]: *** [Makefile:504: all-recursive] Error 1
> gmake[2]: Leaving directory '/usr/ports/databases/rrdtool/work/rrdtool-1.8.0'
> ===> Compilation failed unexpectedly.
> Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to

I built the port and it worked just fine, but apparently this happens only when you turn off the GRAPH option.

I committed a fix in https://cgit.freebsd.org/ports/commit/?id=2ed094adef32cc683a9a077f1c8eb2241754068a .

-Dimitry