From 36f90e57f38fd5c691257ae88ce82f3313b61697 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 6 May 2019 18:18:21 +0200 Subject: [PATCH] riscv: tool chain 19.05 issue #3273 --- repos/ports/ports/binutils.hash | 2 +- repos/ports/ports/binutils.port | 2 + repos/ports/ports/gcc.hash | 2 +- .../src/noux-pkg/binutils/patches/riscv.patch | 21 ++++++ .../src/noux-pkg/binutils/patches/series | 1 + .../src/noux-pkg/gcc/patches/config.patch | 71 +++++++++++++++---- tool/tool_chain | 6 +- 7 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 repos/ports/src/noux-pkg/binutils/patches/riscv.patch diff --git a/repos/ports/ports/binutils.hash b/repos/ports/ports/binutils.hash index 476e30a96..89ce5dbd4 100644 --- a/repos/ports/ports/binutils.hash +++ b/repos/ports/ports/binutils.hash @@ -1 +1 @@ -a27882f8ecc8e71e9e0c1f6d74c6bea0253b335c +62d3090d2ac134787457839ec55cf45512817fe2 diff --git a/repos/ports/ports/binutils.port b/repos/ports/ports/binutils.port index d077f9963..df4f868c6 100644 --- a/repos/ports/ports/binutils.port +++ b/repos/ports/ports/binutils.port @@ -12,6 +12,8 @@ PATCHES := $(addprefix ${DIR(binutils)}/patches/, \ $(shell cat $(REP_DIR)/${DIR(binutils)}/patches/series)) PATCH_OPT := -p1 -d ${DIR(binutils)} +HASH_INPUT += $(REP_DIR)/${DIR(binutils)}/patches/series + AUTOCONF := autoconf $(call check_tool,$(AUTOCONF)) diff --git a/repos/ports/ports/gcc.hash b/repos/ports/ports/gcc.hash index e80ccf4c9..1ffe6771f 100644 --- a/repos/ports/ports/gcc.hash +++ b/repos/ports/ports/gcc.hash @@ -1 +1 @@ -8c08fffc2bffe76384cab49019d889ff4d3e086c +b6533ff19936e6aceac99a98b8a29779e5f8a393 diff --git a/repos/ports/src/noux-pkg/binutils/patches/riscv.patch b/repos/ports/src/noux-pkg/binutils/patches/riscv.patch new file mode 100644 index 000000000..f25edfefd --- /dev/null +++ b/repos/ports/src/noux-pkg/binutils/patches/riscv.patch @@ -0,0 +1,21 @@ +commit 55b4054cf95835fef2896e884cfc0069a0a14401 +Author: Sebastian Sumpf +Date: Thu Apr 25 11:02:51 2019 +0200 + + riscv: always enable shared library support + +diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh +index 5ac3b602..32b50682 100644 +--- a/ld/emulparams/elf32lriscv-defs.sh ++++ b/ld/emulparams/elf32lriscv-defs.sh +@@ -26,6 +26,10 @@ case "$target" in + ;; + esac + ++# always enable shared library support ++GENERATE_SHLIB_SCRIPT=yes ++GENERATE_PIE_SCRIPT=yes ++ + TEXT_START_ADDR=0x10000 + MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" + COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" diff --git a/repos/ports/src/noux-pkg/binutils/patches/series b/repos/ports/src/noux-pkg/binutils/patches/series index 8ed4f89fe..81e7941e7 100644 --- a/repos/ports/src/noux-pkg/binutils/patches/series +++ b/repos/ports/src/noux-pkg/binutils/patches/series @@ -1 +1,2 @@ arm.patch +riscv.patch diff --git a/repos/ports/src/noux-pkg/gcc/patches/config.patch b/repos/ports/src/noux-pkg/gcc/patches/config.patch index d197024d0..813d19d3c 100644 --- a/repos/ports/src/noux-pkg/gcc/patches/config.patch +++ b/repos/ports/src/noux-pkg/gcc/patches/config.patch @@ -1,18 +1,9 @@ config.patch From: Sebastian Sumpf - - --- - gcc/config.gcc | 2 +- - gcc/config/arm/arm.h | 4 ++-- - gcc/config/arm/unknown-elf.h | 16 ++++++++++++++++ - gcc/config/i386/x86-64.h | 23 +++++++++++++++++++++-- - libgcc/config.host | 16 ++++++++++++---- - 5 files changed, 52 insertions(+), 9 deletions(-) - diff --git a/gcc/config.gcc b/gcc/config.gcc -index 7af8e02..3c87dfb 100644 +index 7af8e028..3c87dfb0 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1184,7 +1184,7 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*) @@ -25,7 +16,7 @@ index 7af8e02..3c87dfb 100644 ;; arm*-*-fuchsia*) diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h -index 2809112..2476cb3 100644 +index 942bb4ca..c36b8eea 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -668,11 +668,11 @@ extern int arm_arch_cmse; @@ -43,7 +34,7 @@ index 2809112..2476cb3 100644 /* AAPCS requires that structure alignment is affected by bitfields. */ diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h -index 12dd093..ec0a72e 100644 +index 12dd0931..ec0a72e7 100644 --- a/gcc/config/arm/unknown-elf.h +++ b/gcc/config/arm/unknown-elf.h @@ -94,3 +94,19 @@ @@ -67,7 +58,7 @@ index 12dd093..ec0a72e 100644 +/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57699 */ +#define NO_IMPLICIT_EXTERN_C diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h -index e2a8306..1c5e2e1 100644 +index e2a8306c..1c5e2e15 100644 --- a/gcc/config/i386/x86-64.h +++ b/gcc/config/i386/x86-64.h @@ -37,10 +37,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see @@ -106,8 +97,60 @@ index e2a8306..1c5e2e1 100644 +/* Don't assume anything about the header files. */ +/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57699 */ +#define NO_IMPLICIT_EXTERN_C +diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h +index a8357bb6..cd33bb28 100644 +--- a/gcc/config/riscv/elf.h ++++ b/gcc/config/riscv/elf.h +@@ -17,10 +17,12 @@ You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + ++#ifndef LINK_SPEC + #define LINK_SPEC "\ + -melf" XLEN_SPEC "lriscv \ + %{mno-relax:--no-relax} \ + %{shared}" ++#endif + + /* Link against Newlib libraries, because the ELF backend assumes Newlib. + Handle the circular dependence between libc and libgloss. */ +diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h +index 62279ff2..fdf77645 100644 +--- a/gcc/config/riscv/riscv.h ++++ b/gcc/config/riscv/riscv.h +@@ -819,10 +819,10 @@ while (0) + #define ASM_COMMENT_START "#" + + #undef SIZE_TYPE +-#define SIZE_TYPE (POINTER_SIZE == 64 ? "long unsigned int" : "unsigned int") ++#define SIZE_TYPE (POINTER_SIZE == 64 ? "long unsigned int" : "long unsigned int") + + #undef PTRDIFF_TYPE +-#define PTRDIFF_TYPE (POINTER_SIZE == 64 ? "long int" : "int") ++#define PTRDIFF_TYPE (POINTER_SIZE == 64 ? "long int" : "long int") + + /* The maximum number of bytes copied by one iteration of a movmemsi loop. */ + +@@ -902,4 +902,17 @@ extern unsigned riscv_stack_boundary; + #define SWSP_REACH (4LL << C_SxSP_BITS) + #define SDSP_REACH (8LL << C_SxSP_BITS) + ++ /* genode.h */ ++ ++/* ++ * The 'LINK_SPEC' define comprises the rules of how the GCC frontend invokes ++ * the linker ++ */ ++#undef LINK_SPEC ++#define LINK_SPEC " \ ++-melf" XLEN_SPEC "lriscv \ ++ %{mno-relax:--no-relax} \ ++ %(shared:-shared) \ ++ %{!static:--eh-frame-hdr}" ++ + #endif /* ! GCC_RISCV_H */ diff --git a/libgcc/config.host b/libgcc/config.host -index 11b4aca..5e9cfa8 100644 +index 11b4acaf..5e9cfa86 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -312,7 +312,7 @@ case ${host} in diff --git a/tool/tool_chain b/tool/tool_chain index 14f28086e..d112efc35 100755 --- a/tool/tool_chain +++ b/tool/tool_chain @@ -194,7 +194,7 @@ TARGET_NAME_x86 = x86_64-pc-elf TARGET_NAME_arm = arm-none-eabi TARGET_NAME_riscv = riscv64-unknown-elf -GCC_CONFIG_riscv = --with-arch=rv64imac +GCC_CONFIG_riscv = --with-arch=rv64imac --with-abi=lp64 ifneq ($(VERBOSE),) CONFIG_QUIET = --quiet @@ -210,13 +210,11 @@ BINUTILS_BOOTSTRAP_CONFIG += $(COMMON_BOOTSTRAP_CONFIG) ifeq ($(PLATFORM),riscv) LANGUAGES = c,c++ -GDB_INSTALLED_BINARIES = LIB_GCC = cd $(INSTALL_LOCATION)/lib/gcc/riscv64-unknown-elf/$(GCC_VERSION)/rv64imac/lp64 && \ $(SUDO) ln -sf ../../include include INSTALL_ADA = else LANGUAGES = c,c++,ada -GDB_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-gdb LIB_GCC = INSTALL_ADA = $(SUDO) cp $(LOCAL_BOOTSTRAP_INSTALL_LOCATION)/bin/gnatmake $(INSTALL_LOCATION)/bin/genode-$(PLATFORM)-gnatmake endif @@ -331,7 +329,7 @@ BINUTILS_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-o GCC_BINARIES = $(BUILD_LOCATION)/$(PLATFORM)/gcc/gcc/g++-cross GCC_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-g++ GDB_BINARIES = $(BUILD_LOCATION)/$(PLATFORM)/gdb/gdb/gdb - +GDB_INSTALLED_BINARIES = $(LOCAL_INSTALL_LOCATION)/bin/genode-$(PLATFORM)-gdb build_all: $(GCC_INSTALLED_BINARIES) $(GDB_INSTALLED_BINARIES)