--- gcc.spec.orig 2018-03-06 08:45:33.160000000 +0000 +++ gcc.spec 2018-03-07 20:46:17.492000000 +0000 @@ -21,7 +21,7 @@ %else %global build_ada 0 %endif -%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips} +%ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips} riscv64 %global build_go 1 %else %global build_go 0 @@ -67,7 +67,7 @@ %global build_libmpx 0 %endif %global build_isl 1 -%global build_libstdcxx_docs 1 +%global build_libstdcxx_docs 0 %ifarch %{ix86} x86_64 ppc ppc64 ppc64le ppc64p7 s390 s390x %{arm} aarch64 %{mips} %global attr_ifunc 1 %else @@ -93,7 +93,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}%{?dist} +Release: %{gcc_release}.0.riscv64%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -135,7 +135,7 @@ # -static is used several times. BuildRequires: glibc-static BuildRequires: zlib-devel, gettext, dejagnu, bison, flex, sharutils -BuildRequires: texinfo, texinfo-tex, /usr/bin/pod2man +BuildRequires: texinfo, /usr/bin/pod2man BuildRequires: systemtap-sdt-devel >= 1.3 BuildRequires: gmp-devel >= 4.1.2-8, mpfr-devel >= 2.2.1, libmpc-devel >= 0.8.1 BuildRequires: python2-devel, python3-devel @@ -143,8 +143,11 @@ %if %{build_go} BuildRequires: hostname, procps %endif +# riscv64 does not have GDB port at this point +%ifnarch riscv64 # For VTA guality testing BuildRequires: gdb +%endif # Make sure pthread.h doesn't contain __thread tokens # Make sure glibc supports stack protector # Make sure glibc supports DT_GNU_HASH @@ -235,6 +238,14 @@ Patch10: gcc8-foffload-default.patch Patch11: gcc8-Wno-format-security.patch Patch12: gcc8-rh1512529-aarch64.patch +# TODO: Remove after --with-multilib-list=list support for riscv64 is added +Patch13: gcc8-riscv64-multilib.patch +# TODO: Remove after next gcc bump; the patch is already in trunk +Patch14: gcc8-pr-go-84484.patch +# See: https://github.com/libffi/libffi/pull/281 +Patch15: gcc8-libffi-add-riscv64.patch +Patch16: gcc8-libffi-regen.patch +Patch17: gcc8-libffi-riscv64-def-FFI_ALIGN.patch Patch1000: nvptx-tools-no-ptxas.patch Patch1001: nvptx-tools-build.patch @@ -794,6 +805,11 @@ %patch10 -p0 -b .foffload-default~ %patch11 -p0 -b .Wno-format-security~ %patch12 -p0 -b .rh1512529-aarch64~ +%patch13 -p1 -b .riscv64-multilib~ +%patch14 -p1 -b .libgo-add-riscv64~ +%patch15 -p1 -b .libffi-add-riscv64~ +%patch16 -p1 -b .libffi-regen~ +%patch17 -p1 -b .libffi-ffi_align~ cd nvptx-tools-%{nvptx_tools_gitrev} %patch1000 -p1 -b .nvptx-tools-no-ptxas~ @@ -911,7 +927,7 @@ %ifarch ppc64le --enable-targets=powerpcle-linux \ %endif -%ifarch ppc64le %{mips} riscv64 +%ifarch ppc64le %{mips} --disable-multilib \ %else --enable-multilib \ @@ -1021,12 +1037,12 @@ CXXFLAGS="`echo " $OPT_FLAGS " | sed 's/ -Wall / /g;s/ -fexceptions / /g' \ | sed 's/ -Wformat-security / -Wformat -Wformat-security /'`" \ XCFLAGS="$OPT_FLAGS" TCFLAGS="$OPT_FLAGS" \ - ../configure --enable-bootstrap \ + ../configure --disable-bootstrap \ --enable-languages=c,c++,objc,obj-c++,fortran${enablelada}${enablelgo},lto \ $CONFIGURE_OPTS -%ifarch sparc sparcv9 sparc64 -make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap +%ifarch sparc sparcv9 sparc64 riscv64 +make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" %else make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap %endif @@ -1115,6 +1131,17 @@ %install rm -rf %{buildroot} +mkdir -p %{buildroot} + +%ifarch riscv64 +# RISC-V ABI wants to install everything in /lib64/lp64d or /usr/lib64/lp64d. +# Make these be symlinks to /lib64 or /usr/lib64 respectively. See: +# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/DRHT5YTPK4WWVGL3GIN5BF2IKX2ODHZ3/ +for d in %{buildroot}%{_libdir} %{buildroot}/%{_lib} %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib} %{buildroot}%{_prefix}/include/++/%{gcc_major}/%{gcc_target_platform}/%{_lib}; do + mkdir -p $d + (cd $d && ln -sf . lp64d) +done +%endif %if %{build_offload_nvptx} cd nvptx-tools-%{nvptx_tools_gitrev} @@ -1168,6 +1195,13 @@ ln -sf gcc %{buildroot}%{_prefix}/bin/gnatgcc mkdir -p %{buildroot}%{_fmoddir} +%ifarch riscv64 +# libcc1.so is ELF 64-bit binary thus we move it to _libdir +# It's only used by GDB for on-demand compilation and code injection support +# GDB will use dlopen() to load libcc1.so +mv %{buildroot}%{_prefix}/lib/libcc1.so* %{buildroot}%{_libdir} +%endif + %if %{build_go} mv %{buildroot}%{_prefix}/bin/go{,.gcc} mv %{buildroot}%{_prefix}/bin/gofmt{,.gcc} @@ -2467,6 +2501,10 @@ %dir %{_datadir}/gdb/auto-load %dir %{_datadir}/gdb/auto-load/%{_prefix} %dir %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/ +%ifarch riscv64 +# Package symlink to keep compatibility +%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/lp64d +%endif %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/libstdc*gdb.py* %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/__pycache__ %dir %{_prefix}/share/gcc-%{gcc_major}