Re: git: 5c16e71d30c3 - main - Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 11 Dec 2023 15:15:48 UTC
On 11 Dec 2023, at 16:03, Kristof Provost <kp@FreeBSD.org> wrote:
> On 8 Dec 2023, at 18:39, Dimitry Andric wrote:
> The branch main has been updated by dim:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=5c16e71d30c388dd43b217de10a3ccb4b0219d0d <https://cgit.freebsd.org/src/commit/?id=5c16e71d30c388dd43b217de10a3ccb4b0219d0d>
> commit 5c16e71d30c388dd43b217de10a3ccb4b0219d0d
> Merge: b121cb0095c8 703029dbba78
> Author: Dimitry Andric <dim@FreeBSD.org>
> AuthorDate: 2023-11-30 20:06:52 +0000
> Commit: Dimitry Andric <dim@FreeBSD.org>
> CommitDate: 2023-12-08 17:35:59 +0000
> 
> Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367
> 
> This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
> openmp to llvmorg-17.0.6-0-g6009708b4367.
> 
> PR: 273753
> MFC after: 1 month
> 
> 
> There appears to be some fallout in some ports.
> 
> For example, devel/ivykis (but also sysutils/flashrom and databases/rrdtool) fails like this:
> 
> /bin/sh ../libtool  --tag=CC    --mode=link cc  -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wall  -version-info 5:6:5 -Wl,--version-script,../libivykis.posix.ver -fstack-protector-strong -o libivykis.la -rpath /usr/local/lib iv_avl.lo iv_event.lo iv_fatal.lo iv_task.lo  iv_timer.lo iv_tls.lo iv_work.lo iv_event_raw_posix.lo iv_fd.lo  iv_fd_poll.lo iv_fd_pump.lo iv_main_posix.lo  iv_popen.lo iv_signal.lo iv_thread_posix.lo  iv_tid_posix.lo iv_time_posix.lo iv_wait.lo    iv_fd_kqueue.lo
> libtool: link: cc -shared  -fPIC -DPIC  .libs/iv_avl.o .libs/iv_event.o .libs/iv_fatal.o .libs/iv_task.o .libs/iv_timer.o .libs/iv_tls.o .libs/iv_work.o .libs/iv_event_raw_posix.o .libs/iv_fd.o .libs/iv_fd_poll.o .libs/iv_fd_pump.o .libs/iv_main_posix.o .libs/iv_popen.o .libs/iv_signal.o .libs/iv_thread_posix.o .libs/iv_tid_posix.o .libs/iv_time_posix.o .libs/iv_wait.o .libs/iv_fd_kqueue.o    -O2 -fstack-protector-strong -Wl,--version-script -Wl,../libivykis.posix.ver -fstack-protector-strong   -Wl,-soname -Wl,libivykis.so.0 -o .libs/libivykis.so.0.5.6
> ld: error: version script assignment of 'IVYKIS_0.29' to symbol 'iv_inotify_register' failed: symbol not defined
> ld: error: version script assignment of 'IVYKIS_0.29' to symbol 'iv_inotify_unregister' failed: symbol not defined
> ld: error: version script assignment of 'IVYKIS_0.29' to symbol 'iv_inotify_watch_register' failed: symbol not defined
> ld: error: version script assignment of 'IVYKIS_0.29' to symbol 'iv_inotify_watch_unregister' failed: symbol not defined
> cc: error: linker command failed with exit code 1 (use -v to see invocation)
> I believe the issue is that it doesn’t build inotify code on FreeBSD, but still mentions the relevant functions in the linker script. The other affected ports I’ve run into appear to have similar issues.
> 
In this case, if it never builds the inotify code, you can safely delete those symbols from the linker version script.

> There’s likely to be a fair amount of fallout from that, e.g. https://github.com/llvm/llvm-project/issues/75056
> 
> I’m not sure what the best path forward is. Should we try to make ld warn but not fail on issues like that, or fix each affected port or ?
> 
I fixed dozens of ports for this in https://bugs.freebsd.org/273753, but I haven't gone over all of them, since I have limited resources.

That said, there are generally two ways to fix this: either add -Wl,--undefined-version to the linker flags, or actually remove the undefined symbols from the linker version scripts.

Example of the former: https://cgit.freebsd.org/ports/commit/?id=e0c21e404ed0f04c06c3bce7dd093c6e5ffea188 :

--- a/java/openjfx14/Makefile
+++ b/java/openjfx14/Makefile
@@ -95,6 +95,9 @@ _INSTALLDIR=  ${PREFIX}/${PKGBASE}
 CFLAGS+=       -Wno-error=incompatible-function-pointer-types
 .endif

+# Suppress errors with lld >= 17 due to undefined symbols.
+LDFLAGS+=      -Wl,--undefined-version
+
 post-extract:
        ${MKDIR} ${WRKDIR}/jars
 .for f in core grouping queries queryparser sandbox

Example of the latter: https://cgit.freebsd.org/ports/commit/?id=aef056cf0fe1852a7b708d090310a6eb4853b269 :

--- a/databases/rubygem-pg_query/files/patch-ext_pg__query_pg__query__ruby.sym
+++ b/databases/rubygem-pg_query/files/patch-ext_pg__query_pg__query__ruby.sym
@@ -1,5 +1,5 @@
---- ext/pg_query/pg_query_ruby.sym.orig        2023-06-25 07:13:00 UTC
+--- ext/pg_query/pg_query_ruby.sym.orig        2023-11-19 20:29:16 UTC
 +++ ext/pg_query/pg_query_ruby.sym
-@@ -1 +1,2 @@
- _Init_pg_query
+@@ -1 +1 @@
+-_Init_pg_query
 +Init_pg_query

-Dimitry