Hello,

I'm sorry if I'm contacting the wrong channel but I'm looking for help.
I'm building a Linux distro that doesn't have dynamic linking at all or at
least no dynamically linked libc, so the whole /lib is gone, and all
packages are built with static linking.
I'm sorry if something I say will be wrong. I'm leaning as I go.

Here comes the issue I am facing if the project I'm trying to build is
using libtool for some reason libtool does not pass -static to the final
linking step not matter what I attempt.
but if I copy the line manually add -static to it and run it the binary
comes out statically linked. but doing this manually for everything is
incredibly tedious.

I'm using musl-c as my libc and gcc-14.2.0.
Also I do have -static in my CFLAGS, CXXFLAGS and LDGLAGS.

for example trying to build GNU gmp-6.3.0
I download the source tarball extract it with tar, navigate to the
directory, make a new directory called build navigate into in and run this
configure line:
`../configure --prefix=/usr --disable-shared --enable-static`
After that I just make and gen-bases and other executables come out
statically linked.
but trying to run make check t-bswap and other tests come out build
dynamically linked.

so I've navigated to the tests directory ran `make clean` and `make V=1
check 2>&1 | tee output.txt` and found the line that is wrong

- these lines I think build the t-bswap:
gcc -DHAVE_CONFIG_H -I. -I../../tests -I..  -I../..   -I/usr/include
-static -c -o t-bswap.o ../../tests/t-bsw    ap.c
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -I/usr/include -static
-no-install -L/usr/lib -static -o t-bsw    ap t-bswap.o libtests.la ../
libgmp.la
libtool: link: gcc -I/usr/include -o t-bswap t-bswap.o  -L/usr/lib
./.libs/libtests.a /root/project/source/gmp-6.3.0/build/.libs/libgmp.a
../.libs/libgmp.a
- this last line that says libtool: link: gcc does not have -static in it
`t-bswap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped`

- if I copy the line add -static to it it builds a static t-bswap
`gcc -I/usr/include -o t-bswap t-bswap.o  -L/usr/lib ./.libs/libtests.a
/root/project/source/gmp-6.3.0/build/.libs/libgmp.a ../.libs/libgmp.a
-static`
`t-bswap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically
linked, not stripped`

Is there something that I'm doing wrong, or is this a bug in libtool, cause
I've built other tools that don't use libtool and they build statically
without an issue.
Also this doesn't only happen in gmp tests.
I face the same issue building file-5.46 and flex-2.6.4.
probably many others.

Reply via email to