sys-libs/glibc: Add support for building RISC-V headers
authorPalmer Dabbelt <palmer@dabbelt.com>
Tue, 3 Apr 2018 20:10:41 +0000 (13:10 -0700)
committerSergei Trofimovich <slyfox@gentoo.org>
Tue, 3 Apr 2018 20:21:18 +0000 (21:21 +0100)
The RISC-V GCC port defines some extra preprocessor macros that glibc
uses to determine which RISC-V target is being compiled for.  Since
crossdev doesn't use a RISC-V compiler to build the headers, this blows
up.  These checks don't matter for building the headers because they're
the same on all RISC-V targets, so we just hack up the glibc build to
elide the check.

sys-libs/glibc/glibc-2.27-r1.ebuild

index b281c00fac39c60db358eead67f0cfd7d60a5ccb..588eebae7f2d620c662716f7b6e631cadf2cc7b7 100644 (file)
@@ -762,6 +762,23 @@ src_prepare() {
                        sed -i '/CPPFLAGS=.*-mabi/s|.*|:|' ports/sysdeps/mips/preconfigure || die
                        find ports/sysdeps/mips/ -name Makefile -exec sed -i '/^CC.*-mabi=/s:-mabi=.*:-D_MIPS_SZPTR=32:' {} +
                fi
+               if [[ -e sysdeps/riscv/preconfigure ]] ; then
+                       # RISC-V interrogates the compiler to determine which target to
+                       # build.  If building the headers then we don't strictly need a
+                       # RISC-V compiler, so the built-in definitions that are provided
+                       # along with all RISC-V compiler might not exist.  This causes
+                       # glibc's RISC-V preconfigure script to blow up.  Since we're just
+                       # building the headers any value will actually work here, so just
+                       # pick the standard one (rv64g/lp64d) to make the build scripts
+                       # happy for now -- the headers are all the same anyway so it
+                       # doesn't matter.
+                       sed -i 's/^    xlen=.*/    xlen=64/g' sysdeps/riscv/preconfigure || die
+                       sed -i 's/^    flen=.*/    flen=64/g' sysdeps/riscv/preconfigure || die
+                       sed -i 's/^    float_abi=.*/    float_abi=double/g' sysdeps/riscv/preconfigure || die
+                       sed -i 's/^    atomic=.*/    atomic=__riscv_atomic/g' sysdeps/riscv/preconfigure || die
+                       sed -i 's/^libc_cv_riscv_float_abi=no/libc_cv_riscv_float_abi=d/g' sysdeps/unix/sysv/linux/riscv/configure.ac || die
+                       sed -i 's/^libc_cv_riscv_float_abi=no/libc_cv_riscv_float_abi=d/g' sysdeps/unix/sysv/linux/riscv/configure || die
+               fi
        fi
 
        default