Bug 106271 - Bootstrap on RISC-V on Ubuntu 22.04 LTS: bits/libc-header-start.h: No such file or directory
Summary: Bootstrap on RISC-V on Ubuntu 22.04 LTS: bits/libc-header-start.h: No such fi...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2022-07-12 17:53 UTC by Thomas Koenig
Modified: 2025-02-07 09:52 UTC (History)
8 users (show)

See Also:
Host: riscv64-unknown-linux-gnu
Target: riscv64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-07-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2022-07-12 17:53:35 UTC
I thought I would give the new gcc92 machine a spin and tried
bootstrapping gcc on it.

Configure was done with

../Gcc/configure --disable-multilib --prefix=$HOME --enable-languages=c,c++,fortran

and the last few lines of output were

/home/tkoenig/trunk-bin/./gcc/xgcc -B/home/tkoenig/trunk-bin/./gcc/ -B/home/tkoenig/riscv64-unknown-linux-gnu/bin/ -B/home/tkoenig/riscv64-unknown-linux-gnu/lib/ -isystem /home/tkoenig/riscv64-unknown-linux-gnu/include -isystem /home/tkoenig/riscv64-unknown-linux-gnu/sys-include   -fno-checking -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -fPIC -I. -I. -I../.././gcc -I../../../Gcc/libgcc -I../../../Gcc/libgcc/. -I../../../Gcc/libgcc/../gcc -I../../../Gcc/libgcc/../include  -DHAVE_CC_TLS   -o _ashrdi3.o -MT _ashrdi3.o -MD -MP -MF _ashrdi3.dep -DL_ashrdi3 -c ../../../Gcc/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../Gcc/libgcc/../gcc/tsystem.h:87,
                 from ../../../Gcc/libgcc/libgcc2.c:27:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
   27 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../../Gcc/libgcc/../gcc/tsystem.h:87,
                 from ../../../Gcc/libgcc/libgcc2.c:27:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
   27 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
compilation terminated.
In file included from ../../../Gcc/libgcc/../gcc/tsystem.h:87,
                 from ../../../Gcc/libgcc/libgcc2.c:27:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
   27 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:501: _negdi2.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [Makefile:501: _lshrdi3.o] Error 1
make[3]: *** [Makefile:501: _ashldi3.o] Error 1
In file included from ../../../Gcc/libgcc/../gcc/tsystem.h:87,
                 from ../../../Gcc/libgcc/libgcc2.c:27:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
   27 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:501: _ashrdi3.o] Error 1
Comment 1 Andrew Pinski 2022-07-12 18:02:13 UTC
I suspect configure is not detecting multi-arch correctly or --disable-multilib interacting with multi-arch support which causes things to be broken.
OR multi-arch support is not in the riscv backend yet.
Comment 2 Thomas Koenig 2022-07-12 20:55:19 UTC
(In reply to Andrew Pinski from comment #1)
> I suspect configure is not detecting multi-arch correctly or
> --disable-multilib interacting with multi-arch support which causes things
> to be broken.
> OR multi-arch support is not in the riscv backend yet.

I get the same result without --disable-multilib.
Comment 3 Thomas Schwinge 2023-05-31 15:12:53 UTC
Gah, I ran into the same issue on gcc92.

I 'configure'd '--with-arch=rv64imafdc --with-abi=lp64d --enable-multilib'.

(In reply to Andrew Pinski from comment #1)
> OR multi-arch support is not in the riscv backend yet.

That seems to be the case indeed; at least I'm not seeing any 'if_multiarch' etc. in 'gcc/config/riscv/'.


    $ find /usr/include/ -name libc-header-start.h
    /usr/include/riscv64-linux-gnu/bits/libc-header-start.h

Also, do potentially further distribution packages have to be installed, for additional multilibs?  Like I have on an Ubuntu x86_64 GN/Linux system:

    $ find /usr/include/ -name libc-header-start.h
    /usr/include/i386-linux-gnu/bits/libc-header-start.h
    /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
    $ dpkg -S /usr/include/i386-linux-gnu/bits/libc-header-start.h /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
    libc6-dev:i386: /usr/include/i386-linux-gnu/bits/libc-header-start.h
    libc6-dev:amd64: /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
Comment 4 Thomas Schwinge 2023-05-31 15:17:59 UTC
..., and then I wondered: but how, then, are Debian/Ubuntu building GCC?

Per <https://packages.debian.org/experimental/gcc-13>, <http://deb.debian.org/debian/pool/main/g/gcc-13/gcc-13_13.1.0-3.debian.tar.xz>, there is a 'debian/patches/gcc-multiarch.diff' file, which contains "Remaining multiarch patches, not yet submitted upstream", which (amongst others) includes:

    --- a/src/gcc/config/riscv/t-linux
    +++ b/src/gcc/config/riscv/t-linux
    @@ -1,3 +1,5 @@
     # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
     MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
     MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
    +
    +MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
Comment 5 Thomas Schwinge 2023-05-31 15:42:05 UTC
With the latter hunk applied (plus manual 'rm gcc/s-mlib gcc/multilib.h' to regenerate the latter file), I find that this apparently does only address the '--disable-multilib' case, but not my '--enable-multilib'?
Comment 6 Thomas Schwinge 2023-08-30 08:16:29 UTC
I noticed recent commit r14-3387-g47f95bc4be4eb14730ab3eaaaf8f6e71fda47690 "RISC-V: Add multiarch support on riscv-linux-gnu" -- but can't tell off-hand whether that fixed all the issues here?
Comment 7 Thomas Koenig 2023-08-30 11:15:32 UTC
(In reply to Thomas Schwinge from comment #6)
> I noticed recent commit r14-3387-g47f95bc4be4eb14730ab3eaaaf8f6e71fda47690
> "RISC-V: Add multiarch support on riscv-linux-gnu" -- but can't tell
> off-hand whether that fixed all the issues here?

As soon as gcc92 is back up, we can test...

https://lists.tetaneutral.net/pipermail/cfarm-users/2023-August/000975.html
Comment 8 Jeffrey A. Law 2023-10-07 20:10:22 UTC
I wasn't aware of this BZ when I made the commit referenced in c#6.  But yes, the whole point of that commit was to fix this problem.
Comment 9 Matthias Klose 2023-10-12 06:12:49 UTC
yes, that's one which could be also backported. Let me submit the other bits upstream as well.
Comment 10 Rainer Orth 2025-02-07 09:32:11 UTC
There still seems to be something amiss here: I've recently tried bootstrapping
trunk on cfarm95: when configuring with just --enable-languages=c++, I got the
same error building the stage 1 libgcc:

In file included from /home/ro/gcc/src/master/libgcc/../gcc/tsystem.h:95,
                 from /home/ro/gcc/src/master/libgcc/libgcc2.c:27:
/usr/include/stdio.h:28:10: fatal error: bits/libc-header-start.h: No such file or directory
   28 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [Makefile:512: _negdi2.o] Error 1

Isn't this supposed to have been fixed in GCC 14?
Comment 11 Matthias Klose 2025-02-07 09:38:36 UTC
this is fixed in the 14 branch and in 15.
Comment 12 Matthias Klose 2025-02-07 09:39:58 UTC
also note that the Debian and Ubuntu builds are configured with --disable-multilib
Comment 13 ro@CeBiTec.Uni-Bielefeld.DE 2025-02-07 09:40:53 UTC
> --- Comment #11 from Matthias Klose <doko at gcc dot gnu.org> ---
> this is fixed in the 14 branch and in 15.

I know that's the claim; still the error happened when trying to build
trunk two days ago.
Comment 14 ro@CeBiTec.Uni-Bielefeld.DE 2025-02-07 09:42:29 UTC
> --- Comment #12 from Matthias Klose <doko at gcc dot gnu.org> ---
> also note that the Debian and Ubuntu builds are configured with
> --disable-multilib

While I hadn't passed that, the error occured when building the default
(64-bit) multilib.
Comment 15 Matthias Klose 2025-02-07 09:50:10 UTC
are you able to check this with 24.04 LTS as well?
Comment 16 ro@CeBiTec.Uni-Bielefeld.DE 2025-02-07 09:52:51 UTC
> --- Comment #15 from Matthias Klose <doko at gcc dot gnu.org> ---
> are you able to check this with 24.04 LTS as well?

No, the only RISC-V systems I have access to are in the cfarm, none of
which run Ubuntu 24.04 AFAICS (mostly Debian).