Re: git: 3a39de445275 - main - devel/jansson: Update to 2.15.1
- Reply: Dag-Erling_Smørgrav : "Re: git: 3a39de445275 - main - devel/jansson: Update to 2.15.1"
- Reply: Dag-Erling_Smørgrav : "Re: git: 3a39de445275 - main - devel/jansson: Update to 2.15.1"
- In reply to: Dag-Erling_Smørgrav : "Re: git: 3a39de445275 - main - devel/jansson: Update to 2.15.1"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 08 Jul 2026 22:17:23 UTC
On 7 Jul 2026, at 15:21, Dag-Erling Smørgrav <des@FreeBSD.org> wrote:
>
> Dag-Erling Smørgrav <des@FreeBSD.org> writes:
>> This broke pretty much every downstream port as libjansson.so is no
>> longer versioned. I'm pretty sure that was not intentional, but if it
>> was, the major version should be bumped.
>
> Apparently FreeBSD 15 and 16 are fine, but CMake fails to enable symbol
> versioning on FreeBSD 14. It tries to compile a minimal C program
> (basically `int main(void){}`) with the following version script:
>
> JANSSON_4 {
> global:
> json_*;
> jansson_*;
> local:
> *;
> };
>
> Prior to 2.15.1, the script looked like this instead:
>
> JANSSON_4 {
> global:
> *;
> };
>
> On FreeBSD 14, linking with the new script fails:
>
> Building C object CMakeFiles/cmTC_4f85b.dir/src.c.o
> /usr/bin/cc -DVSCRIPT_WORKS -Wno-format-truncation -MD -MT CMakeFiles/cmTC_4f85b.dir/src.c.o -MF CMakeFiles/cmTC_4f85b.dir/src.c.o.d -o CMakeFiles/cmTC_4f85b.dir/src.c.o -c /home/des/src/jansson/CMakeFiles/CMakeScratch/TryCompile-aWSDVV/src.c
> Linking C executable cmTC_4f85b
> /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4f85b.dir/link.txt --verbose=1
> 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)
> /usr/bin/cc -Wno-format-truncation CMakeFiles/cmTC_4f85b.dir/src.c.o -o cmTC_4f85b -Wl,--version-script,/home/des/src/jansson/jansson.symwith the following
> errors:
>
> With the old version script, it succeeded:
>
> Building C object CMakeFiles/cmTC_710a9.dir/src.c.o
> /usr/bin/cc -DVSCRIPT_WORKS -Wno-format-truncation -MD -MT CMakeFiles/cmTC_710a9.dir/src.c.o -MF CMakeFiles/cmTC_710a9.dir/src.c.o.d -o CMakeFiles/cmTC_710a9.dir/src.c.o -c /home/des/src/jansson/CMakeFiles/CMakeScratch/TryCompile-BxJxKD/src.c
> Linking C executable cmTC_710a9
> /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_710a9.dir/link.txt --verbose=1
> /usr/bin/cc -Wno-format-truncation CMakeFiles/cmTC_710a9.dir/src.c.o -o cmTC_710a9 -Wl,--version-script,/home/des/src/jansson/jansson.sym
>
> I've verified this on releng/14.3 (ld.lld 19.1.7) and stable/14 (ld.lld
> 21.1.8).
>
> I see no difference in how environ or __progname are exported or
> referenced in FreeBSD 14, 15, 16:
>
> % objdump -t /usr/lib/crt1.o | egrep -w 'environ|__progname'
> 0000000000000000 g O .data 0000000000000008 __progname
> 0000000000000000 g O .bss 0000000000000008 environ
> % objdump -T /lib/libc.so.7 | egrep -w 'environ|__progname'
> 0000000000000000 D *UND* 0000000000000000 environ
> 0000000000000000 D *UND* 0000000000000000 __progname
>
> Perhaps Dimitry will be able to shed some light.
At the moment my only explanation is that the error is somehow suppressed on 15 and 16. If you try the same script with ld.bfd, it will error out on all versions, so the "local: *" construct should really not be used.
Bugs similar to these have been reported many times in ports. It seems that many authors copy this bad example from Samba (or that is where I believe it came from), and since it only fails on FreeBSD, it is never noticed.
-Dimitry