Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jan 2025 13:28:49 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Peter Blok <pblok@bsd4all.org>
Cc:        FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: libxkbcommon version-script detection
Message-ID:  <C63834FC-6722-4A19-ABBE-3C5F195572F2@FreeBSD.org>
In-Reply-To: <F5EBD424-FAFC-40D6-BBE8-01BEFD99A310@FreeBSD.org>
References:  <518E81E7-F1F0-422C-88A0-718088E4FDB6@bsd4all.org> <1DCB46A8-04C7-4F1A-ADEE-A5402E4B5617@FreeBSD.org> <2EFAFFD8-E1E1-42D0-B41D-217E97C27F2E@bsd4all.org> <F5EBD424-FAFC-40D6-BBE8-01BEFD99A310@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On 10 Jan 2025, at 12:56, Dimitry Andric <dim@FreeBSD.org> wrote:
> 
> On 10 Jan 2025, at 12:20, Peter Blok <pblok@bsd4all.org> wrote:
>> 
>> Test works ok when using clang18 from ports
>> 
>>> On 10 Jan 2025, at 11:19, Dimitry Andric <dim@FreeBSD.org> wrote:
>>> 
>>> On 10 Jan 2025, at 10:22, Peter Blok <pblok@bsd4all.org> wrote:
>>>> 
>>>> I have recompiled x11/libxkbcommon and it fails to detect if the compiler/linker supports versioned symbols. As a result other code expecting the versioned symbol to exist, fail to link.
>>>> 
>>>> C compiler for the host machine: cc (clang 19.1.5 "FreeBSD clang version 19.1.5 (https://github.com/llvm/llvm-project.git llvmorg-19.1.5-0-gab4b5a2db582)")
>>>> C linker for the host machine: cc ld.lld 19.1.5
>>>> 
>>>> Below the meson.build check. If I force have_version_script to true, the versioned symbols are created and other code links fine.
>>>> 
>>>> # Supports -Wl,--version-script?
>>>> have_version_script = cc.links(
>>>> 'int main(){}',
>>>> args: '-Wl,--undefined-version,--version-script=' + meson.current_source_dir()/'xkbcommon.map',
>>>> name: '-Wl,--version-script',
>>>> )
>>>> 
>>>> Below the output for the test.
>>>> 
>>>> Checking if "-Wl,--version-script" : links: NO
>>>> 
>>>> If I create test.c with content "int main(){}” and compile it manually with the same flags AFAIK, it compiles ok. No errors.
>>>> 
>>>> However when I capture "make configure" with ktrace, it fails with the error below.
>>>> 
>>>> ld: error: non-exported symbol 'environ' in '/usr/lib/crt1.o' is referenced by DSO '/lib/libc.so.7'
>>>>     ld: error: non-exported symbol '__progname' in '/usr/lib/crt1.o' is referenced by DSO '/lib/libc.so.7'
>>>>     cc: error: linker command failed with exit code 1 (use -v to see invocation)
>>>> 
>>>> What flags need to be added in meson.build to allow it to work?
>>>> 
>>>> BTW This is on recent stable, but I suspect it fails the same way on current which I do not run at the moment.
>>> 
>>> It works just fine on -CURRENT:
>>> 
>>> ...
>>> Checking if "-Wl,--version-script" : links: YES
>>> 
>>> Not sure what is going wrong in your environment. Is this stable/14?
> 
> It appears to help when the lines:
> 
> local:
>    *;
> 
> are removed from /wrkdirs/usr/ports/x11/libxkbcommon/work/libxkbcommon-1.7.0/xkbcommon.map. Apparently on main, environ and __progname are slightly different.
> 
> In any case, the "local: *;" thing has caused problems before, so maybe it's better to get rid of it.

Here's a better patch, that can also be upstreamed. It avoids the whole problem of trying to use the "full" xkbcommon.map during meson tests.

-Dimitry


[-- Attachment #2 --]
commit 51f362f344d06786f686a108ee3b68187a8ed03c
Author: Dimitry Andric <dimitry@andric.com>
Date:   2025-01-10T13:26:38+01:00

    x11/libxkbcommon: fix --version-script check in meson.build for good

diff --git a/x11/libxkbcommon/files/patch-meson.build b/x11/libxkbcommon/files/patch-meson.build
new file mode 100644
index 000000000000..adb5872f2a23
--- /dev/null
+++ b/x11/libxkbcommon/files/patch-meson.build
@@ -0,0 +1,11 @@
+--- meson.build.orig	2024-03-23 21:23:43 UTC
++++ meson.build
+@@ -145,7 +145,7 @@ have_version_script = cc.links(
+ # Supports -Wl,--version-script?
+ have_version_script = cc.links(
+     'int main(){}',
+-    args: '-Wl,--undefined-version,--version-script=' + meson.current_source_dir()/'xkbcommon.map',
++    args: '-Wl,--version-script=' + meson.current_source_dir()/'meson_test.map',
+     name: '-Wl,--version-script',
+ )
+ 
diff --git a/x11/libxkbcommon/files/patch-meson__test.map b/x11/libxkbcommon/files/patch-meson__test.map
new file mode 100644
index 000000000000..102e02a3534a
--- /dev/null
+++ b/x11/libxkbcommon/files/patch-meson__test.map
@@ -0,0 +1,4 @@
+--- meson_test.map.orig	2025-01-10 12:22:45 UTC
++++ meson_test.map
+@@ -0,0 +1 @@
++TEST {};
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C63834FC-6722-4A19-ABBE-3C5F195572F2>