Compare commits

...

21 Commits

Author SHA1 Message Date
David Abdurachmanov a24fb4f7f1
Enable bootstrap again
linker segfaulted trying to link libphobos

BUILDSTDERR: collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
BUILDSTDERR: /usr/bin/ld: core/.libs/atomic.o: relocation R_RISCV_HI20 against `gdc.dso_initialized' can not be used when making a shared object; recompile with -fPIC
(for multiple files from libphobos)

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-24 12:07:18 +01:00
David Abdurachmanov d28e028a04
Disable bootstrap to speed up testing
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-24 08:57:14 +01:00
David Abdurachmanov b5c8f89da0
Fix inline asm
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-24 08:54:22 +01:00
David Abdurachmanov 13ae10ca88
Bump Release
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-23 21:47:54 +01:00
David Abdurachmanov 0c8a514f2f
Add RISCV{32,64} defines in libphobos
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-23 21:47:22 +01:00
David Abdurachmanov 84da12b304
Add support for RISC-V in libphobos math
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-23 11:07:37 +01:00
David Abdurachmanov f12d80983f
Enable D front-end and modify libphobos asserts
The patch was suggestion from Iain Buclaw (D maintainer from GCC).

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-23 00:01:17 +01:00
David Abdurachmanov 86300223a1 Merge remote-tracking branch 'up/master' into private-davidlt 2019-01-22 23:56:30 +01:00
David Abdurachmanov df0cbdcb5d
Disable GDC (D front-end) on riscv64 until we figure out -latomic
libphobos fails because it cannot detect atomic support (-lpthread
used instead of -pthread in conftest).

libphobos/libdruntime/core/atomic.d:1447:9: error: static assert  "atomicStore() not supported on this architecture"

We need to figure out how to approach it.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-22 11:05:11 +01:00
David Abdurachmanov 2376be8a2a Merge remote-tracking branch 'up/master' into master-riscv64 2019-01-22 11:04:44 +01:00
David Abdurachmanov 948d611882
Enable libphobos for RISC-V (riscv64)
libphobos gained support for RISC-V in Dec 2018 (before GCC 9 was
released): https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00021.html

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-21 22:47:41 +01:00
David Abdurachmanov d9a688a462
Clean up RISC-V for GCC 9
- We have working GDB now, thus enable BR for gdb;
- Remove all RISC-V (riscv64) patches (everything is upstream);
- Enable D (GDC);
- Keep Ada disabled, but we know it works in GCC 9 (we need Ada
  compiler to compiler Ada).

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-21 11:14:44 +01:00
David Abdurachmanov a27065ed2b
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-01-21 11:07:37 +01:00
David Abdurachmanov a26c9756d6 Merge remote-tracking branch 'up/master' into master-riscv64 2019-01-11 11:35:30 +02:00
David Abdurachmanov 61087a9352 Merge remote-tracking branch 'up/master' into master-riscv64 2018-12-19 07:50:02 +02:00
David Abdurachmanov 10e63a9ab4 Merge remote-tracking branch 'up/master' into master-riscv64 2018-11-22 11:04:58 +01:00
David Abdurachmanov 8d1ed6b2bc Merge remote-tracking branch 'up/master' into master-riscv64 2018-08-02 16:01:41 +03:00
David Abdurachmanov 0e0bb97508 Merge commit '7df147abddc0089c45e3b4ebe79adc24323beef2' into master-riscv64 2018-08-01 10:57:16 +03:00
David Abdurachmanov 24bb58f8b3 Merge commit 'c0d3a20ab37333fa576c7476e8831c9f91673092' into master-riscv64 2018-06-28 13:39:13 +02:00
David Abdurachmanov 273a6e3e21 libcc1.so* are now installed in /usr/lib/../lib64/lp64d by default
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2018-05-05 07:56:15 +02:00
David Abdurachmanov b840e5963d Add support for riscv64 (RISC-V 64-bit)
We only support one configuration in Fedora: RV64GC (arch) + LP64D (abi).
Note that RISC-V paths by default feel like multi-lib. We are compiling
with multi-lib enabled, but only one ABI selected (LP64D). This allows
us to get desired install paths.

All extra patches were already posted to gcc-patches and are pending
review.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2018-05-04 18:35:36 +02:00
4 changed files with 234 additions and 6 deletions

View File

@ -0,0 +1,156 @@
From 35ced3822a12415f7bf7307f43c503736aa4b8e8 Mon Sep 17 00:00:00 2001
From: David Abdurachmanov <david.abdurachmanov@gmail.com>
Date: Wed, 23 Jan 2019 21:45:01 +0100
Subject: [PATCH] Add RISCV support in libphobos
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
---
.../allocator/building_blocks/region.d | 3 +-
libphobos/src/std/math.d | 61 +++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/libphobos/src/std/experimental/allocator/building_blocks/region.d b/libphobos/src/std/experimental/allocator/building_blocks/region.d
index 80157aee7e6..ad90d17df00 100644
--- a/libphobos/src/std/experimental/allocator/building_blocks/region.d
+++ b/libphobos/src/std/experimental/allocator/building_blocks/region.d
@@ -390,7 +390,8 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment)
else version (PPC) enum growDownwards = Yes.growDownwards;
else version (PPC64) enum growDownwards = Yes.growDownwards;
else version (MIPS32) enum growDownwards = Yes.growDownwards;
- else version (MIPS64) enum growDownwards = Yes.growDownwards;
+ else version (RISCV32) enum growDownwards = Yes.growDownwards;
+ else version (RISCV64) enum growDownwards = Yes.growDownwards;
else version (SPARC) enum growDownwards = Yes.growDownwards;
else version (SystemZ) enum growDownwards = Yes.growDownwards;
else static assert(0, "Dunno how the stack grows on this architecture.");
diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d
index 7bb4d7c23db..ba9b03c4da9 100644
--- a/libphobos/src/std/math.d
+++ b/libphobos/src/std/math.d
@@ -160,6 +160,8 @@ version (MIPS32) version = MIPS_Any;
version (MIPS64) version = MIPS_Any;
version (AArch64) version = ARM_Any;
version (ARM) version = ARM_Any;
+version (RISCV32) version = RISCV_Any;
+version (RISCV64) version = RISCV_Any;
version (D_InlineAsm_X86)
{
@@ -4654,6 +4656,7 @@ private:
// The Pentium SSE2 status register is 32 bits.
// The ARM and PowerPC FPSCR is a 32-bit register.
// The SPARC FSR is a 32bit register (64 bits for SPARC 7 & 8, but high bits are uninteresting).
+ // The RISC-V (32 & 64 bit) are 32-bit register.
uint flags;
version (CRuntime_Microsoft)
@@ -4725,6 +4728,15 @@ private:
return result;
}
}
+ else version (RISCV_Any)
+ {
+ uint result = void;
+ asm pure nothrow @nogc
+ {
+ "frflags %0" : "=r" (result);
+ }
+ return result;
+ }
else
assert(0, "Not yet supported");
}
@@ -4799,6 +4811,15 @@ private:
}
}
}
+ else version (RISCV_Any)
+ {
+ uint oldValues = void;
+ uint newValues = 0x0;
+ asm pure nothrow @nogc
+ {
+ "fsflags %0 %1" : "=r" (oldValues) : "r" (newValues);
+ }
+ }
else
assert(0, "Not yet supported");
}
@@ -4968,6 +4989,10 @@ else version (PPC_Any)
{
version = IeeeFlagsSupport;
}
+else version (RISCV_Any)
+{
+ version = IeeeFlagsSupport;
+}
else version (MIPS_Any)
{
version = IeeeFlagsSupport;
@@ -5162,6 +5187,21 @@ struct FloatingPointControl
| inexactException,
}
}
+ else version (RISCV_Any)
+ {
+ enum : ExceptionMask
+ {
+ inexactException = 0x01,
+ divByZeroException = 0x02,
+ underflowException = 0x04,
+ overflowException = 0x08,
+ invalidException = 0x10,
+ severeExceptions = overflowException | divByZeroException
+ | invalidException,
+ allExceptions = severeExceptions | underflowException
+ | inexactException,
+ }
+ }
else version (SPARC64)
{
enum : ExceptionMask
@@ -5292,6 +5332,10 @@ private:
{
alias ControlState = uint;
}
+ else version (RISCV_Any)
+ {
+ alias ControlState = uint;
+ }
else version (SPARC64)
{
alias ControlState = ulong;
@@ -5359,6 +5403,15 @@ private:
}
return cont;
}
+ else version (RISCV_Any)
+ {
+ ControlState cont;
+ asm pure nothrow @nogc
+ {
+ "frcsr %0" : "=r" (cont);
+ }
+ return cont;
+ }
else
assert(0, "Not yet supported");
}
@@ -5444,6 +5497,14 @@ private:
}
}
}
+ else version (RISCV_Any)
+ {
+ uint oldState = void;
+ asm pure nothrow @nogc
+ {
+ "fscsr %0, %1;" : "=r" (oldState) : "r" (newState);
+ }
+ }
else
assert(0, "Not yet supported");
}
--
2.20.1

View File

@ -28,12 +28,12 @@
%global build_ada 0
%endif
%global build_objc 1
%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
%endif
%ifarch %{ix86} x86_64 %{arm} %{mips}
%ifarch %{ix86} x86_64 %{arm} %{mips} riscv64
%global build_d 1
%else
%global build_d 0
@ -64,7 +64,7 @@
%else
%global build_libubsan 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_libatomic 1
%else
%global build_libatomic 0
@ -101,7 +101,7 @@
Summary: Various compilers (C, C++, Objective-C, ...)
Name: gcc
Version: %{gcc_version}
Release: %{gcc_release}%{?dist}
Release: %{gcc_release}.davidlt.4%{?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
@ -265,6 +265,10 @@ Patch16: gcc9-pr88904.patch
Patch17: gcc9-pr88905.patch
Patch18: gcc9-pr88906.patch
Patch30: libphobos-enable-riscv.patch
Patch31: libphobos-asserts.patch
Patch32: 0001-Enable-RISC-V-in-libphobos-especially-math.d.patch
Patch1000: nvptx-tools-no-ptxas.patch
Patch1001: nvptx-tools-build.patch
Patch1002: nvptx-tools-glibc.patch
@ -850,6 +854,10 @@ to NVidia PTX capable devices if available.
%patch17 -p0 -b .pr88905~
%patch18 -p0 -b .pr88906~
%patch30 -p1 -b .libphobos-riscv~
%patch31 -p1 -b .libphobos-asserts~
%patch32 -p1 -b .libphobos-riscv-math~
cd nvptx-tools-%{nvptx_tools_gitrev}
%patch1000 -p1 -b .nvptx-tools-no-ptxas~
%patch1001 -p1 -b .nvptx-tools-build~
@ -974,7 +982,7 @@ CONFIGURE_OPTS="\
%ifarch ppc64le
--enable-targets=powerpcle-linux \
%endif
%ifarch ppc64le %{mips} riscv64
%ifarch ppc64le %{mips}
--disable-multilib \
%else
--enable-multilib \
@ -1076,6 +1084,9 @@ CONFIGURE_OPTS="\
%ifarch mips64 mips64el
--with-arch=mips64r2 --with-abi=64 \
%endif
%ifarch riscv64
--with-arch=rv64gc --with-abi=lp64d --with-multilib-list=lp64d \
%endif
%ifnarch sparc sparcv9 ppc
--build=%{gcc_target_platform} \
%endif
@ -1089,7 +1100,7 @@ CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
--enable-languages=c,c++,fortran${enablelobjc}${enablelada}${enablelgo}${enableld},lto \
$CONFIGURE_OPTS
%ifarch sparc sparcv9 sparc64
%ifarch sparc sparcv9 sparc64 riscv64
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap
%else
make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap
@ -1190,6 +1201,17 @@ find rpm.doc -name \*ChangeLog\* | xargs bzip2 -9
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
# 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/
%ifarch riscv64
for d in %{buildroot}%{_libdir} %{buildroot}/%{_lib} %{buildroot}%{_datadir}/gdb/auto-load/%{_prefix}/%{_lib} %{buildroot}%{_prefix}/include/c++/%{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}
@ -1332,6 +1354,8 @@ find %{buildroot} -name \*.la | xargs rm -f
mv %{buildroot}%{_prefix}/%{_lib}/libgfortran.spec $FULLPATH/
%if %{build_d}
find %{buildroot} -name libgphobos.spec
find %{buildroot}
mv %{buildroot}%{_prefix}/%{_lib}/libgphobos.spec $FULLPATH/
%endif
%if %{build_libitm}
@ -2531,6 +2555,10 @@ fi
%dir %{_datadir}/gdb/auto-load
%dir %{_datadir}/gdb/auto-load/%{_prefix}
%dir %{_datadir}/gdb/auto-load/%{_prefix}/%{_lib}/
# Package symlink to keep compatibility
%ifarch riscv64
%{_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}

31
libphobos-asserts.patch Normal file
View File

@ -0,0 +1,31 @@
diff --git a/libphobos/libdruntime/core/atomic.d b/libphobos/libdruntime/core/atomic.d
index 0b39cddb6..5a6c4b854 100644
--- a/libphobos/libdruntime/core/atomic.d
+++ b/libphobos/libdruntime/core/atomic.d
@@ -1353,7 +1353,7 @@ else version (GNU)
private bool casImpl(T,V1,V2)( shared(T)* here, V1 ifThis, V2 writeThis ) pure nothrow @nogc @trusted
{
- static assert(GNU_Have_Atomics, "cas() not supported on this architecture");
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "cas() not supported on this architecture");
bool res = void;
static if (T.sizeof == byte.sizeof)
@@ -1406,7 +1406,7 @@ else version (GNU)
{
static assert(ms != MemoryOrder.rel, "Invalid MemoryOrder for atomicLoad");
static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
- static assert(GNU_Have_Atomics, "atomicLoad() not supported on this architecture");
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "atomicLoad() not supported on this architecture");
static if (T.sizeof == ubyte.sizeof)
{
@@ -1444,7 +1444,7 @@ else version (GNU)
{
static assert(ms != MemoryOrder.acq, "Invalid MemoryOrder for atomicStore");
static assert(__traits(isPOD, T), "argument to atomicLoad() must be POD");
- static assert(GNU_Have_Atomics, "atomicStore() not supported on this architecture");
+ static assert(GNU_Have_Atomics || GNU_Have_LibAtomic, "atomicStore() not supported on this architecture");
static if (T.sizeof == ubyte.sizeof)
{

View File

@ -0,0 +1,13 @@
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 2b2a97468..f8775b712 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -30,6 +30,8 @@ case "${target}" in
;;
x86_64-*-linux* | i?86-*-linux*)
;;
+ riscv*-*-linux*)
+ ;;
*)
UNSUPPORTED=1
;;