* util-linux-2.41 breaks static build of btrfs-progs
@ 2025-04-20 19:24 Stanislav Brabec
2025-05-05 9:34 ` Karel Zak
2025-05-13 9:41 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Stanislav Brabec @ 2025-04-20 19:24 UTC (permalink / raw)
To: util-linux
Static build of btrfs-progs fails with util-linux-2.41 with a simple
problem:
Symbol parse_range becomes visible in libblkid.a, breaking parse-utils.c
in btrfs-progs, using the same symbol.
The question is:
Should be this fixed by util-linux by prefixing of ul_ to all symbols
that are not declared as static?
Or should it be fixed by btrfs-progs?
Or could there be applied any type of symbol hiding in the static library?
/usr/lib64/gcc/x86_64-suse-linux/14/../../../../x86_64-suse-linux/bin/ld:
/usr/lib64/gcc/x86_64-suse-linux/14/../../../../lib64/libblkid.a(libcommon_la-strutils.o):
in function `parse_range':
[ 29s]
/home/abuild/rpmbuild/BUILD/util-linux-2.41-build/util-linux-2.41/lib/strutils.c:867:
multiple definition of `parse_range'; common/parse-utils.static.o
(symbol from plugin):(.text+0x0): first defined here
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa) tel: +420 284 084 060
186 00 Praha 8-Karlín fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: util-linux-2.41 breaks static build of btrfs-progs
2025-04-20 19:24 util-linux-2.41 breaks static build of btrfs-progs Stanislav Brabec
@ 2025-05-05 9:34 ` Karel Zak
2025-05-05 9:50 ` Karel Zak
2025-05-13 9:41 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2025-05-05 9:34 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: util-linux
On Sun, Apr 20, 2025 at 09:24:43PM +0200, Stanislav Brabec wrote:
> Static build of btrfs-progs fails with util-linux-2.41 with a simple
> problem:
> Symbol parse_range becomes visible in libblkid.a, breaking parse-utils.c in
> btrfs-progs, using the same symbol.
>
> The question is:
> Should be this fixed by util-linux by prefixing of ul_ to all symbols that
> are not declared as static?
I think the ul_ prefix should be used for all generic names like
parse_range(). I'm not sure if I want to use it strictly for all
functions, as the set of functions is large and such conflicts are
very rare.
ChatGPT has an interesting suggestion: add the prefix to the .a
library using "objcopy --redefine-syms" for all non-API and non-static
functions.
#!/bin/bash
PREFIX=foo_
# Extract all global (non-static) function symbols from the .a file
nm -g --defined-only libmylib.a | awk '{print $3}' | grep -v "^$PREFIX" | sort -u > tmp.syms
# Generate rename list: <old> <new>
awk -v pfx="$PREFIX" '{print $1 " " pfx $1}' tmp.syms > rename.syms
# Apply symbol renaming
objcopy --redefine-syms=rename.syms libmylib.a libmylib_prefixed.a
Maybe it's elegant way to go. Not sure, not tested :-)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: util-linux-2.41 breaks static build of btrfs-progs
2025-05-05 9:34 ` Karel Zak
@ 2025-05-05 9:50 ` Karel Zak
0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2025-05-05 9:50 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: util-linux
On Mon, May 05, 2025 at 11:34:11AM +0200, Karel Zak wrote:
> On Sun, Apr 20, 2025 at 09:24:43PM +0200, Stanislav Brabec wrote:
> > Static build of btrfs-progs fails with util-linux-2.41 with a simple
> > problem:
> > Symbol parse_range becomes visible in libblkid.a, breaking parse-utils.c in
> > btrfs-progs, using the same symbol.
> >
> > The question is:
> > Should be this fixed by util-linux by prefixing of ul_ to all symbols that
> > are not declared as static?
>
> I think the ul_ prefix should be used for all generic names like
> parse_range(). I'm not sure if I want to use it strictly for all
> functions, as the set of functions is large and such conflicts are
> very rare.
>
> ChatGPT has an interesting suggestion: add the prefix to the .a
> library using "objcopy --redefine-syms" for all non-API and non-static
> functions.
>
> #!/bin/bash
> PREFIX=foo_
>
> # Extract all global (non-static) function symbols from the .a file
> nm -g --defined-only libmylib.a | awk '{print $3}' | grep -v "^$PREFIX" | sort -u > tmp.syms
Note that the list of symbols should also be filtered according to
libblkid.sym to keep the API functions unmodified.
> # Generate rename list: <old> <new>
> awk -v pfx="$PREFIX" '{print $1 " " pfx $1}' tmp.syms > rename.syms
>
> # Apply symbol renaming
> objcopy --redefine-syms=rename.syms libmylib.a libmylib_prefixed.a
Updated, not tested version:
#!/bin/bash
set -e
LIB=libfoo.a
VERSION_SCRIPT=libfoo.sym
PREFIX=foo_
TMPDIR=$(mktemp -d)
RENAME_SYMS="$TMPDIR/rename.syms"
# 1. Get all defined global symbols in the .a (non-static functions/vars)
nm -g --defined-only "$LIB" | awk '{print $3}' | sort -u > "$TMPDIR/all_syms.txt"
# 2. Extract exported (API) symbols from the version script
awk '/global:/{flag=1; next} /local:/{flag=0} flag' "$VERSION_SCRIPT" | \
tr -d '; \t' | grep -v '^$' | sort -u > "$TMPDIR/exported_syms.txt"
# 3. Compute symbols to rename (non-exported global ones)
comm -23 "$TMPDIR/all_syms.txt" "$TMPDIR/exported_syms.txt" | \
awk -v pfx="$PREFIX" '{print $1 " " pfx $1}' > "$RENAME_SYMS"
# 4. Apply renaming to the archive
cp "$LIB" "${LIB%.a}_prefixed.a"
objcopy --redefine-syms="$RENAME_SYMS" "${LIB%.a}_prefixed.a"
echo "Renamed library created: ${LIB%.a}_prefixed.a"
echo "Renamed symbols:"
cat "$RENAME_SYMS"
# 5. Optional cleanup
# rm -r "$TMPDIR"
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: util-linux-2.41 breaks static build of btrfs-progs
2025-04-20 19:24 util-linux-2.41 breaks static build of btrfs-progs Stanislav Brabec
2025-05-05 9:34 ` Karel Zak
@ 2025-05-13 9:41 ` Karel Zak
2025-05-29 15:43 ` Stanislav Brabec
1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2025-05-13 9:41 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: util-linux
On Sun, Apr 20, 2025 at 09:24:43PM +0200, Stanislav Brabec wrote:
> The question is:
> Should be this fixed by util-linux by prefixing of ul_ to all symbols that
> are not declared as static?
I have added the "ul_" prefix to some functions to make the names less
generic: https://github.com/util-linux/util-linux/pull/3569
I'm going to backport it to stable/v2.41 too.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: util-linux-2.41 breaks static build of btrfs-progs
2025-05-13 9:41 ` Karel Zak
@ 2025-05-29 15:43 ` Stanislav Brabec
0 siblings, 0 replies; 5+ messages in thread
From: Stanislav Brabec @ 2025-05-29 15:43 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
Karel Zak wrote:
> On Sun, Apr 20, 2025 at 09:24:43PM +0200, Stanislav Brabec wrote:
>> The question is:
>> Should be this fixed by util-linux by prefixing of ul_ to all symbols that
>> are not declared as static?
> I have added the "ul_" prefix to some functions to make the names less
> generic: https://github.com/util-linux/util-linux/pull/3569
>
> I'm going to backport it to stable/v2.41 too.
Done:
https://github.com/util-linux/util-linux/pull/3603
btrfs-progs-v6.14 static build works again out of the box.
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa) tel: +420 284 084 060
186 00 Praha 8-Karlín fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-29 15:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-20 19:24 util-linux-2.41 breaks static build of btrfs-progs Stanislav Brabec
2025-05-05 9:34 ` Karel Zak
2025-05-05 9:50 ` Karel Zak
2025-05-13 9:41 ` Karel Zak
2025-05-29 15:43 ` Stanislav Brabec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox