On Wed, 14 Sep 2022 22:29:15 +0200, Jeremie Courreges-Anglas wrote:
> On Tue, Sep 13 2022, Jeremie Courreges-Anglas <jca@wxcvbn.org> wrote:
> > On Sun, Sep 11 2022, Jeremie Courreges-Anglas <jca@wxcvbn.org> wrote:
> >> On Fri, Sep 09 2022, Pascal Stumpf <pascal@stumpf.co> wrote:
> >>> OK as soon as the lld patch is in. Great work!
> >>
> >> This involved a fair amount of headdesks, thanks for your kind words. :)
> >>
> >> It might be doable to work around the lld problem within the gcc ports.
> >> Thay may be sufficient given that not many C++ ports will be built with
> >> ports-gcc on riscv64. I'm gonna work on this next.
> >
> > The diff below (for lang/gcc/8 only this time) includes the workaround
> > for the ld.lld error.
> >
> >> Meanwhile, I fixed the lang/gcc/11 build with what I learnt from
> >> lang/gcc/8, diff below.
> >>
> >>> On Fri, 09 Sep 2022 00:34:21 +0200, Jeremie Courreges-Anglas wrote:
> >>>>
> >>>> With the diff below I can build ports-gcc on riscv64. PIE is disabled
> >>>> by default because I hit crashes at build time. Since not many ports
> >>>> require ports-gcc for for C or C++ code I believe that's okay for now.
> >>>> Trying to forcefully disable PIE led to some dubious patches, I'm not
> >>>> sure yet why they are actually needed (see the comments). The rest of
> >>>> the patches are as riscv64-specific as possible.
> >>>>
> >>>> One patch which isn't included here is for ld.lld in base, which I have
> >>>> yet to submit.
> >>>>
> >>>> With this I can build blas, lapack, numpy with fortran support... more
> >>>> to come.
> >>>>
> >>>> Thoughts? oks?
> >>>>
> >>>> PS: I have yet to backport my recent fixes to lang/gcc/11, crossing
> >>>> fingers...
> >>>>
> >>>> PPS: the ONLY_FOR_ARCHS and GCC49_ARCHS changes aren't included for now
> >>>> but they're trivial
> >>
> >> (This time with riscv64 added to ONLY_FOR_ARCHS.)
> >
> > Updated diff for lang/gcc/8. I only have dim memories and don't have
> > notes about the errors I hit when hacking on this during k2k21 and
> > h2k21. But it seems that only ssp is currently a problem, and I can
> > enable PIE by default. Since ld.lld in base actually defaults to PIE,
> > this lets me drop most initial patches and hacks, and build eg math/hdf5
> > without hitting errors.
> >
> > lang/gcc/11 is still building with a similarly simplified diff.
> > I intend to commit the lang/gcc/8 part this evening, review/ok still
> > welcome.
>
> I have committed the tweaked version of lang/gcc/8 along with a missing
> PFRAG (sorry about that). A bulk is running and gfortran has already
> been used to build a few ports.
>
> Here's an updated diff for lang/gcc/11.
>
> ok?
If this builds fine, OK.
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/lang/gcc/11/Makefile,v
> retrieving revision 1.14
> diff -u -p -r1.14 Makefile
> --- Makefile 24 Jul 2022 09:52:45 -0000 1.14
> +++ Makefile 13 Sep 2022 12:05:16 -0000
> @@ -6,7 +6,7 @@ BROKEN-sparc64 = ICE during selftests
>
> # tested: aarch64 amd64 arm hppa i386 powerpc
> ONLY_FOR_ARCHS = aarch64 alpha amd64 arm hppa i386 mips64 mips64el \
> - powerpc powerpc64 sparc64
> + powerpc powerpc64 riscv64 sparc64
>
> ONLY_FOR_ARCHS-ada = amd64 i386 mips64 powerpc
> ONLY_FOR_ARCHS-dlang = aarch64 amd64 arm i386 powerpc powerpc64
> @@ -68,7 +68,8 @@ EXTRACT_ONLY = ${DISTNAME}.tar.xz
> BUILD_DEPENDS += devel/bison
>
> .if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "arm" || \
> - ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
> + ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" || \
> + ${MACHINE_ARCH} == "riscv64"
> # would be helpful on i386/amd64 too, but some ports also need the old
> # ld.bfd in base which can't cope with new gas.
> BUILD_DEPENDS += devel/gas
> @@ -153,10 +154,15 @@ CONFIGURE_ARGS += \
> --with-gmp="${LOCALBASE}" \
> --enable-languages=${LANGS} \
> --disable-libstdcxx-pch \
> - --enable-default-ssp \
> --enable-default-pie \
> --without-isl
>
> +# Enable the stack protector by default where supported
> +.if ${MACHINE_ARCH} != "riscv64"
> +CONFIGURE_ARGS += \
> + --enable-default-ssp
> +.endif
> +
> # This is needed, as internal cpp is no longer compatible with the
> # visible beast
> CONFIGURE_ARGS += --enable-cpp
> @@ -231,6 +237,13 @@ LIB_DEPENDS-libs =
>
> .if ${MACHINE_ARCH:Mamd64}
> CONFIG = x86_64-unknown-openbsd${OSREV}
> +.endif
> +
> +.if ${MACHINE_ARCH} == "riscv64"
> +# lld complains about .gcc_except_table referencing
> +# symbols in discarded sections. Tell gcc to split .gcc_except_table
> +# so that its unused parts can also be discarded.
> +EXTRA_ENV += PORTS_FORCE_SPLIT_SECTIONS="-ffunction-sections -fdata-sections"
> .endif
>
> post-extract:
> Index: patches/patch-gcc_config_gcc
> ===================================================================
> RCS file: /cvs/ports/lang/gcc/11/patches/patch-gcc_config_gcc,v
> retrieving revision 1.3
> diff -u -p -r1.3 patch-gcc_config_gcc
> --- patches/patch-gcc_config_gcc 11 Mar 2022 19:28:58 -0000 1.3
> +++ patches/patch-gcc_config_gcc 12 Sep 2022 07:30:26 -0000
> @@ -109,7 +109,27 @@ Index: gcc/config.gcc
> i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu)
> # Intel 80386's running GNU/*
> # with ELF format using glibc 2
> -@@ -2891,6 +2929,18 @@ pdp11-*-*)
> +@@ -2532,6 +2570,19 @@ mips*-*-netbsd*) # NetBSD/mips, either endian.
> + tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h"
> + extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
> + ;;
> ++riscv64-*-openbsd*)
> ++ tm_file="${tm_file} dbxelf.h elfos.h"
> ++ tm_file="${tm_file} openbsd-stdint.h"
> ++ tm_file="${tm_file} openbsd.h riscv/openbsd.h openbsd-libpthread.h"
> ++ tmake_file="${tmake_file} riscv/t-riscv"
> ++ extra_options="${extra_options} openbsd.opt"
> ++ # Force .init_array support. The configure script cannot always
> ++ # automatically detect that GAS supports it, yet we require it.
> ++ gcc_cv_initfini_array=yes
> ++ # Also force this, shouldn't hurt...
> ++ gnu_ld=yes
> ++ gas=yes
> ++ ;;
> + mips*-img-linux*)
> + tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h mips/linux-common.h mips/mti-linux.h"
> + extra_options="${extra_options} linux-android.opt"
> +@@ -2891,6 +2942,18 @@ pdp11-*-*)
> # tmake_file="${tmake_file} rs6000/t-fprules"
> # extra_headers=
> # ;;
> @@ -128,7 +148,7 @@ Index: gcc/config.gcc
> powerpc-*-darwin*)
> extra_options="${extra_options} ${cpu_type}/darwin.opt"
> case ${target} in
> -@@ -3452,10 +3502,10 @@ sparc64-*-netbsd*)
> +@@ -3452,10 +3515,10 @@ sparc64-*-netbsd*)
> tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64"
> ;;
> sparc64-*-openbsd*)
> @@ -140,7 +160,7 @@ Index: gcc/config.gcc
> gas=yes gnu_ld=yes
> with_cpu=ultrasparc
> tmake_file="${tmake_file} sparc/t-sparc"
> -@@ -3682,6 +3732,12 @@ case ${target} in
> +@@ -3682,6 +3745,12 @@ case ${target} in
> else
> arch=i386
> fi
> Index: patches/patch-gcc_config_riscv_openbsd_h
> ===================================================================
> RCS file: patches/patch-gcc_config_riscv_openbsd_h
> diff -N patches/patch-gcc_config_riscv_openbsd_h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-gcc_config_riscv_openbsd_h 13 Sep 2022 12:07:42 -0000
> @@ -0,0 +1,125 @@
> +Index: gcc/config/riscv/openbsd.h
> +--- gcc/config/riscv/openbsd.h.orig
> ++++ gcc/config/riscv/openbsd.h
> +@@ -0,0 +1,121 @@
> ++/* Definitions of target machine for GNU compiler, OpenBSD/riscv64 ELF version.
> ++ Copyright (C) 2002 Free Software Foundation, Inc.
> ++
> ++This file is part of GNU CC.
> ++
> ++GNU CC is free software; you can redistribute it and/or modify
> ++it under the terms of the GNU General Public License as published by
> ++the Free Software Foundation; either version 2, or (at your option)
> ++any later version.
> ++
> ++GNU CC is distributed in the hope that it will be useful,
> ++but WITHOUT ANY WARRANTY; without even the implied warranty of
> ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> ++GNU General Public License for more details.
> ++
> ++You should have received a copy of the GNU General Public License
> ++along with GNU CC; see the file COPYING. If not, write to
> ++the Free Software Foundation, 59 Temple Place - Suite 330,
> ++Boston, MA 02111-1307, USA. */
> ++
> ++/* This defaults us to little-endian. */
> ++#ifndef TARGET_ENDIAN_DEFAULT
> ++#define TARGET_ENDIAN_DEFAULT 0
> ++
No comments:
Post a Comment