URL:
  <https://savannah.gnu.org/support/?111202>

                 Summary: Libtool strips -static flag from CFLAGS
                   Group: GNU Libtool
               Submitter: droopy4096
               Submitted: Thu 27 Feb 2025 11:30:40 PM UTC
                Category: None
                Priority: 5 - Normal
                Severity: 3 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 27 Feb 2025 11:30:40 PM UTC By: Droopy <droopy4096>
I'm working on building toolchain within Alpine linux container. As one
example - building `pkgconf` with `CFLAGS=-static` and `./configure
--disable-shared` still results in dynamically linked binary:

```
/src $ ldd /tmp/pkconf.default
        /lib/ld-musl-x86_64.so.1 (0x7fbf5b4af000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fbf5b4af000)
```

when I try to force static binary generation via `LDFLAGS=-Wl,-static` I get
"broken" binary as libtool ends up assembling binary without an entry point
(crt1.o) as far as I can tell. 

Issue is really visible here:

```
/bin/sh ./libtool  --tag=CC   --mode=link clang
-DPERSONALITY_PATH=\"/opt/gitlab/bootstrap/share/pkgconfig/personality.d:/opt/gitlab/bootstrap/etc/pkgconfig/personality.d\"
-DPKG_DEFAULT_PATH=\"/opt/gitlab/bootstrap/lib64/pkgconfig:/opt/gitlab/bootstrap/share/pkgconfig\"
-DSYSTEM_INCLUDEDIR=\"/opt/gitlab/bootstrap/include\"
-DSYSTEM_LIBDIR=\"/opt/gitlab/bootstrap/lib64\" -fuse-ld=lld
--rtlib=compiler-rt -static -no-pie  -L/opt/gitlab/bootstrap/lib64 -lc
-L/usr/lib -o bomtool cli/bomtool/bomtool-main.o cli/bomtool-getopt_long.o
libpkgconf.la
libtool: link: clang
"-DPERSONALITY_PATH=\"/opt/gitlab/bootstrap/share/pkgconfig/personality.d:/opt/gitlab/bootstrap/etc/pkgconfig/personality.d\""
"-DPKG_DEFAULT_PATH=\"/opt/gitlab/bootstrap/lib64/pkgconfig:/opt/gitlab/bootstrap/share/pkgconfig\""
"-DSYSTEM_INCLUDEDIR=\"/opt/gitlab/bootstrap/include\""
"-DSYSTEM_LIBDIR=\"/opt/gitlab/bootstrap/lib64\"" -fuse-ld=lld
--rtlib=compiler-rt -no-pie -o bomtool cli/bomtool/bomtool-main.o
cli/bomtool-getopt_long.o  -L/opt/gitlab/bootstrap/lib64 -L/usr/lib
./.libs/libpkgconf.a -lc
```

note that second line is **missing** `-static`. Same command *with* `-static`
flag produces proper binary.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/support/?111202>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to