Build with static libzstd (was: Re: GDB: How does configure with with config.cache??)
Paul Smith
psmith@gnu.org
Thu Sep 12 15:56:07 GMT 2024
On Wed, 2024-09-11 at 18:10 -0400, Paul Smith via Gdb wrote:
> Can someone explain to me how the GDB top-level configure script
> works? It's driving me bananas.
OK, as might be expected most of this was my fault and my
misunderstanding: my build tool accidentally was not deleting a
previous build directory. After I got some sleep last night the
gremlins I was fighting all left town.
The thing that is wrong now is that I build libzstd as a static library
with multithreaded support, and I want to link it statically but this
doesn't work well.
I am configuring GDB with --enable-static --disable-shared (but this is
probably related to GDB itself not its prerequisites).
The problem is that when the GDB configure uses pkg-config to get
details about the libzstd package, it doesn't pass the --static option
and so the resulting link options don't contain -pthread:
$ pkg-config --libs libzstd
-L/data/src/zstd/Linux-Release-make/dist/lib -lzstd
$ pkg-config --libs --static libzstd
-L/data/src/zstd/Linux-Release-make/dist/lib -lzstd -pthread
Because -pthread is missing in the first case, the configure test
programs that try to link code fail; for example:
configure:27555: checking for ELF support in BFD
configure:27575: ./libtool --quiet --mode=link x86_64-rl84-linux-gnu-gcc -o conftest -I/data/src/gdb/gdb-15.1/gdb/../include -I../bfd -I/data/src/gdb/gdb-15.1/gdb/../bfd -O2 -fPIC -static-libgcc -I/data/src/xxhash/Linux-Release-make/dist/include -L../bfd -L../libiberty conftest.c -lbfd -liberty -lncurses -lm -ldl >&5
/data/src/zstd/Linux-Release-make/dist/lib/libzstd.a(pool.c.o):pool.c:function POOL_free:(.text+0x15f): error: undefined reference to 'pthread_join'
/data/src/zstd/Linux-Release-make/dist/lib/libzstd.a(pool.c.o):pool.c:function POOL_create_advanced:(.text+0x3a9): error: undefined reference to 'pthread_create'
/data/src/zstd/Linux-Release-make/dist/lib/libzstd.a(pool.c.o):pool.c:function POOL_resize:(.text+0x689): error: undefined reference to 'pthread_create'
collect2: error: ld returned 1 exit status
configure:27585: result: no
This is obviously problematic since gcore-elf.c is not included in GDB
and the build fails.
I'm not really sure what the right answer is here. I could of course
force -pthread always by adding LIBS=-pthread to the configure command.
Or maybe the problem is that the libzstd.pc file is wrong: since I
don't have a libzstd.so but only libzstd.a maybe the pc file should
include -pthread in the Libs variable and not just in the Libs.private
variable?
I'll move forward with some kind of workaround, locally.
More information about the Gdb
mailing list