libtool doesn't pass -static when linking executable
KoleckO LP <[email protected]> Sun, 8 Jun 2025 14:12:52 +0200
| Newsgroups | gmane.comp.gnu.libtool.general |
|---|---|
| Message-ID | <CAOUzQxsVqBQ2RgVARMEkumGwf2Brr5SBJOx1vZnqE1dRWk=77w@mail.gmail.com> |
--000000000000b3e0ce06370e62a5 Content-Type: text/plain; charset="UTF-8" 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. --000000000000b3e0ce06370e62a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello,<br><br>I'm sorry if I'm contacting the wron= g channel but I'm looking for help.<div>I'm building a Linux distro= that doesn't have dynamic linking at all or at least no dynamically li= nked libc, so the whole /lib is gone, and all packages are built with stati= c linking.<div>I'm sorry if something I say will be wrong. I'm lean= ing as I go.</div><div><br></div><div>Here comes the issue I am facing if t= he 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.= <br>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 inc= redibly tedious.<br><br>I'm using musl-c as my libc and gcc-14.2.0.<br>= Also I do have -static in my CFLAGS, CXXFLAGS and LDGLAGS.</div><div><br></= div><div>for example trying to build GNU gmp-6.3.0<br>I download the source= tarball extract it with tar, navigate to the directory, make a new directo= ry called build navigate into in and run this configure line:<br>`../config= ure --prefix=3D/usr --disable-shared --enable-static`<br>After that I just = make and gen-bases and other executables come out statically linked.<br>but= trying to run make check t-bswap and other tests come out build dynamicall= y linked.<br><br>so I've navigated to the tests directory ran `make cle= an` and `make V=3D1 check 2>&1 | tee output.txt` and found the line = that is wrong<br><br>- these lines I think build the t-bswap:<br>gcc -DHAVE= _CONFIG_H -I. -I../../tests -I.. =C2=A0-I../.. =C2=A0 -I/usr/include -stati= c -c -o t-bswap.o ../../tests/t-bsw =C2=A0 =C2=A0ap.c<br>/bin/sh ../libtool= =C2=A0--tag=3DCC =C2=A0 --mode=3Dlink gcc =C2=A0-I/usr/include -static -no= -install -L/usr/lib -static -o t-bsw =C2=A0 =C2=A0ap t-bswap.o <a href=3D"h= ttp://libtests.la">libtests.la</a> ../<a href=3D"http://libgmp.la">libgmp.l= a</a><br>libtool: link: gcc -I/usr/include -o t-bswap t-bswap.o =C2=A0-L/us= r/lib ./.libs/libtests.a /root/project/source/gmp-6.3.0/build/.libs/libgmp.= a ../.libs/libgmp.a<br>- this last line that says libtool: link: gcc does n= ot have -static in it</div><div>`t-bswap: ELF 64-bit LSB executable, x86-64= , version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.= 1, not stripped`<br><br>- if I copy the line add -static to it it builds a = static t-bswap<br>`gcc -I/usr/include -o t-bswap t-bswap.o =C2=A0-L/usr/lib= ./.libs/libtests.a /root/project/source/gmp-6.3.0/build/.libs/libgmp.a ../= .libs/libgmp.a -static`<br>`t-bswap: ELF 64-bit LSB executable, x86-64, ver= sion 1 (SYSV), statically linked, not stripped`<br><br>Is there something t= hat 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.<br>Also this doesn't only happen in gmp tests.<br>I face the sa= me issue building file-5.46 and flex-2.6.4.<br>probably many others.<br></d= iv></div><div><br></div></div> --000000000000b3e0ce06370e62a5--