Bug 24577 - 'make install-headers' fails for riscv64-unknown-linux-gnu: sysdeps/riscv/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported"
Summary: 'make install-headers' fails for riscv64-unknown-linux-gnu: sysdeps/riscv/bit...
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-18 19:22 UTC by Sergei Trofimovich
Modified: 2019-09-01 16:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
glibc-2.28-cppflags.patch (521 bytes, patch)
2019-05-18 19:26 UTC, Sergei Trofimovich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2019-05-18 19:22:32 UTC
Gentoo bootstraps gcc cross-compilers in the following way:

1. build cross-binutils:
2. Install system headers (kernel headers and libc headers):
3. build minimal GCC without libc support (not able to link final
4. build complete libc (gcc will need crt.o files)
5. build full GCC (able to link final binaries for C and C++)

This bug is about build failure on [2.] step. Note: we don't have a cross-compiler there.

More build failure details are at: https://bugs.gentoo.org/686248
The summary of it is failure to preprocess target files with host compiler:

x86_64-pc-linux-gnu-gcc -E -dM -MD -MP -MF /tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers/bits/stdio_lim.dT -MT '/tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers/bits/stdio_lim.h /tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers/bits/stdio_lim.d'    \
       -I../include -I/tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers/stdio-common  -I/tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers  -I../sysdeps/unix/sysv/linux/riscv/rv64  -I../sysdeps/unix/sysv/linux/riscv  -I../sysdeps/riscv/nptl  -I../sysdeps/unix/sysv/linux/generic  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/riscv/rv64/rvd  -I../sysdeps/riscv/rv64/rvf  -I../sysdeps/riscv/rvf  -I../sysdeps/riscv/rvd  -I../sysdeps/riscv/rv64  -I../sysdeps/riscv  -I../sysdeps/init_array  -I../sysdeps/ieee754/ldbl-128  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include-fixed -isystem /usr/riscv64-unknown-linux-gnu/usr/include -xc - -o /tmp/portage/cross-riscv64-unknown-linux-gnu/glibc-2.28-r6/work/build-default-riscv64-unknown-linux-gnu-headers/bits/stdio_lim.hT
In file included from ../posix/bits/posix1_lim.h:27,
                 from <stdin>:1:
../sysdeps/riscv/bits/wordsize.h:22:3: error: #error unsupported ABI
   22 | # error unsupported ABI
      |   ^~~~~
../sysdeps/riscv/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported"
   28 | # error "rv32i-based targets are not supported"
      |   ^~~~~
Comment 1 Sergei Trofimovich 2019-05-18 19:26:48 UTC
Created attachment 11784 [details]
glibc-2.28-cppflags.patch

glibc-2.28-cppflags.patch allows passing CPPFLAGS to depend generation to workaround the failure.

This way Gentoo work failure around by calling ./configure as:

CC=x86_64-pc-linux-gnu-gcc CPPFLAGS='-U_FORTIFY_SOURCE -D__riscv_xlen=64 -D__riscv_flen=64 -D__riscv_float_abi_double=1 -D__riscv_atomic=1' ./configure  --build=x86_64-pc-linux-gnu --host=risc v64-unknown-linux-gnu --with-headers=/usr/riscv64-unknown-linux-gnu/usr/include --prefix=/usr ...

Looks like riscv is the only target that requires CPPFLAGS workaround. Should glibc headers (or sysdeps/riscv/preconfigure) be restructures to inject these automatically?

Thank you!
Comment 2 jsm-csl@polyomino.org.uk 2019-05-20 17:05:41 UTC
Minimal GCC (C only, static libgcc only, built --with-newlib 
--without-headers where --with-newlib is how you tell GCC to define 
inhibit_libc for the libgcc build) does not need libc headers.  I 
recommend removing libc header installation from step 2.  Since around 
glibc 2.16, glibc should fully support being built with such a minimal 
GCC, with the stripped glibc binaries being identical to those you get if 
you build it using the full GCC.  (Running the glibc testsuite requires 
building glibc using the full GCC, however.  And there are other bugs 
noting that when building glibc with the minimal GCC, you still need to 
set CXX to point to the (nonexistent) C++ compiler for the configuration 
for which you're building glibc, as otherwise configure may pick up a 
native C++ compiler and cause trouble later in the build process.)

See build-many-glibcs.py for more details of a modern bootstrap process 
known to work for all glibc configurations.
Comment 3 Sergei Trofimovich 2019-05-20 18:07:49 UTC
Thank you! We'll migrate to installation without headers.
Comment 4 Sergei Trofimovich 2019-09-01 16:20:12 UTC
Apparently attempt to add CPPFLAGS earlier also introduces scary "error-looking" warning:

  ...
  /sys-libs/glibc-2.29-r4/work/build-x86-x86_64-pc-linux-gnu-nptl/bits/stdio_lim.hT
  42570:cc1: fatal error: /var/tmp/portage/sys-libs/glibc-2.29-r4/work/build-x86-x86_64-pc-linux-gnu-nptl/libc-modules.h: No such file or directory

https://bugs.gentoo.org/692052

I'm assuming glibc does not support headers-only installation without present cross-compiler and it's not just a riscv ports' deficiency.

If that is the case I suggest removing 'install-headers' make target.

Closing as INVALID.