Bug 31753 - FAIL: link-static-libc with GCC 6/7/8
Summary: FAIL: link-static-libc with GCC 6/7/8
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: 2.40
: P2 normal
Target Milestone: 2.40
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-18 02:52 UTC by H.J. Lu
Modified: 2024-05-19 23:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2024-05-18 02:52:32 UTC
link-static-libc failed with GCC 6/7/8:

/usr/gcc-7.4.1-x32/libexec/gcc/x86_64-pc-linux-gnu/7.4.1/collect2 -fno-lto --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o /dev/null -r /lib/../lib/crt1.o /lib/../lib/crti.o /usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/32/crtbegin.o -L/usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/32 -L/usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1 -L/usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/../../.. --whole-archive /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc.a -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/32/crtend.o /lib/../lib/crtn.o
/usr/local/bin/ld: /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc.a(dso_handle.o):/export/gnu/import/git/gitlab/x86-glibc/csu/dso_handle.c:20: multiple definition of `__dso_handle'; /usr/gcc-7.4.1-x32/lib/gcc/x86_64-pc-linux-gnu/7.4.1/32/crtbegin.o:(.data+0x0): first defined here
/usr/local/bin/ld: /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc.a(rcmd.o): in function `__checkhost_sa':
/export/gnu/import/git/gitlab/x86-glibc/inet/rcmd.c:682:(.text+0x563): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/bin/ld: /export/build/gnu/tools-build/glibc-32bit-gitlab/build-i686-linux/libc.a(dl-reloc-static-pie.o): in function `_dl_relocate_static_pie':
/export/gnu/import/git/gitlab/x86-glibc/elf/dl-reloc-static-pie.c:37: multiple definition of `_dl_relocate_static_pie'; /lib/../lib/crt1.o:(.text+0x40): first defined here
...

-nostdlib -nostartfiles is needed for -r with GCC 6/7/8.
Comment 1 Sourceware Commits 2024-05-19 23:29:16 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2be3352f0b1ebaa39596393fffe1062275186669

commit 2be3352f0b1ebaa39596393fffe1062275186669
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 17 20:00:38 2024 -0700

    Pass -nostdlib -nostartfiles together with -r [BZ #31753]
    
    Since -r in GCC 6/7/8 doesn't imply -nostdlib -nostartfiles, update the
    link-static-libc.out rule to also pass -nostdlib -nostartfiles.  This
    fixes BZ #31753.
    
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
    Reviewed-by: Florian Weimer <fweimer@redhat.com>
Comment 2 H.J. Lu 2024-05-19 23:30:59 UTC
Fixed.