public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thomas.petazzoni@free-electrons.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/107728] New: with -O0, libgcc in the first stage compiler has reference to libc functions
Date: Wed, 16 Nov 2022 21:43:23 +0000	[thread overview]
Message-ID: <bug-107728-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107728

            Bug ID: 107728
           Summary: with -O0, libgcc in the first stage compiler has
                    reference to libc functions
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thomas.petazzoni@free-electrons.com
  Target Milestone: ---

We've started doing builds with -O0 in Buildroot, and we get build failures in
glibc that look like this:


/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `__register_frame':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:138:
undefined reference to `malloc'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `__register_frame_table':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:186:
undefined reference to `malloc'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `__deregister_frame_info_bases':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:246:
undefined reference to `free'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `__deregister_frame':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:260:
undefined reference to `free'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `start_fde_sort':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:449:
undefined reference to `malloc'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:449:
undefined reference to `malloc'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `end_fde_sort':
/home/autobuild/autobuild/instance-11/output-1/build/host-gcc-initial-11.3.0/build/sh4eb-buildroot-linux-gnu/libgcc/../../../libgcc/unwind-dw2-fde.c:629:
undefined reference to `free'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/librtld.os:
in function `abort':
(.text+0x2345c): undefined reference to `__pthread_mutex_lock'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
(.text+0x23464): undefined reference to `__pthread_mutex_unlock'
/home/autobuild/autobuild/instance-11/output-1/host/lib/gcc/sh4eb-buildroot-linux-gnu/11.3.0/../../../../sh4eb-buildroot-linux-gnu/bin/ld:
(.text+0x2346c): undefined reference to `__pthread_mutex_lock'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:1339:
/home/autobuild/autobuild/instance-11/output-1/build/glibc-2.36-66-ga1dc0be03c9dd850b864bd7a9c03cf8e396eb7ca/build/elf/ld.so]
Error 1

See
http://autobuild.buildroot.net/results/7df/7df2d0648dd666dd07845614b34f59d6afba96c1/build-end.log
for a more complete build log.

The reason is that a number of functions in libgcc/unwind-dw2-fde.c call into C
library functions. With an optimization level of -O1 at least, these functions
get compiled out, and there is no problem. But at -O0, the code of those
functions is kept, causing the above build failure.

To reproduce:

$ git clone https://gitlab.com/buildroot.org/buildroot.git
$ cd buildroot
$ cat > .config <<EOF
BR2_sh=y
BR2_sh4eb=y
BR2_KERNEL_HEADERS_4_14=y
BR2_GCC_VERSION_12_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
# BR2_STRIP_strip is not set
BR2_OPTIMIZE_0=y
EOF
$ make olddefconfig
$ make

(and wait)

             reply	other threads:[~2022-11-16 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 21:43 thomas.petazzoni@free-electrons.com [this message]
2022-11-16 21:54 ` [Bug bootstrap/107728] " pinskia at gcc dot gnu.org
2022-11-16 22:09 ` pinskia at gcc dot gnu.org
2022-11-16 22:51 ` thomas.petazzoni@free-electrons.com
2022-11-24 16:49 ` arnout at mind dot be
2022-11-24 17:29 ` arnout at mind dot be
2022-11-24 17:31 ` [Bug libgcc/107728] _umoddi3.o has reference to the unwinder at -O0 pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107728-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).