From c205caead557aea92e319c85d0e974ca7b4830e1 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 18 Jan 2023 16:16:51 +0000 Subject: [PATCH] 8297851: Add devkit for RISC-V Reviewed-by: fyang, erikj --- make/conf/jib-profiles.js | 22 ++++++- make/devkit/Tools.gmk | 63 +++++++++++++------- make/devkit/patches/riscv64-gcc-11.3.0.patch | 14 +++++ 3 files changed, 76 insertions(+), 23 deletions(-) create mode 100644 make/devkit/patches/riscv64-gcc-11.3.0.patch diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 686ccdeeae9..420a8cc87e6 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -242,7 +242,8 @@ var getJibProfilesCommon = function (input, data) { common.main_profile_names = [ "linux-x64", "linux-x86", "macosx-x64", "macosx-aarch64", "windows-x64", "windows-x86", "windows-aarch64", - "linux-aarch64", "linux-arm32", "linux-ppc64le", "linux-s390x" + "linux-aarch64", "linux-arm32", "linux-ppc64le", "linux-s390x", + "linux-riscv64" ]; // These are the base settings for all the main build profiles. @@ -519,6 +520,17 @@ var getJibProfilesProfiles = function (input, common, data) { "--disable-warnings-as-errors" ], }, + + "linux-riscv64": { + target_os: "linux", + target_cpu: "riscv64", + build_cpu: "x64", + dependencies: ["devkit", "gtest", "build_devkit"], + configure_args: [ + "--openjdk-target=riscv64-linux-gnu", "--with-freetype=bundled", + "--disable-warnings-as-errors" + ], + }, }; // Add the base settings to all the main profiles @@ -714,7 +726,10 @@ var getJibProfilesProfiles = function (input, common, data) { }, "linux-s390x": { platform: "linux-s390x", - } + }, + "linux-riscv64": { + platform: "linux-riscv64", + }, } // Generate common artifacts for all main profiles Object.keys(artifactData).forEach(function (name) { @@ -1040,7 +1055,8 @@ var getJibProfilesDependencies = function (input, common) { linux_aarch64: "gcc11.2.0-OL7.6+1.0", linux_arm: "gcc8.2.0-Fedora27+1.0", linux_ppc64le: "gcc8.2.0-Fedora27+1.0", - linux_s390x: "gcc8.2.0-Fedora27+1.0" + linux_s390x: "gcc8.2.0-Fedora27+1.0", + linux_riscv64: "gcc11.3.0-Fedora_rawhide_68692+1.1" }; var devkit_platform = (input.target_cpu == "x86" diff --git a/make/devkit/Tools.gmk b/make/devkit/Tools.gmk index e94a74d0063..f882ca53375 100644 --- a/make/devkit/Tools.gmk +++ b/make/devkit/Tools.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -63,20 +63,28 @@ ifeq ($(BASE_OS), OL) LINUX_VERSION := OL6.4 endif else ifeq ($(BASE_OS), Fedora) - DEFAULT_OS_VERSION := 27 - ifeq ($(BASE_OS_VERSION), ) - BASE_OS_VERSION := $(DEFAULT_OS_VERSION) - endif - ifeq ($(filter x86_64 armhfp, $(ARCH)), ) - FEDORA_TYPE := fedora-secondary + ifeq ($(ARCH), riscv64) + DEFAULT_OS_VERSION := rawhide/68692 + ifeq ($(BASE_OS_VERSION), ) + BASE_OS_VERSION := $(DEFAULT_OS_VERSION) + endif + BASE_URL := http://fedora.riscv.rocks/repos-dist/$(BASE_OS_VERSION)/$(ARCH)/Packages/ else - FEDORA_TYPE := fedora/linux - endif - ARCHIVED := $(shell [ $(BASE_OS_VERSION) -lt $(DEFAULT_OS_VERSION) ] && echo true) - ifeq ($(ARCHIVED),true) - BASE_URL := https://archives.fedoraproject.org/pub/archive/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ - else - BASE_URL := https://dl.fedoraproject.org/pub/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ + DEFAULT_OS_VERSION := 27 + ifeq ($(BASE_OS_VERSION), ) + BASE_OS_VERSION := $(DEFAULT_OS_VERSION) + endif + ifeq ($(filter x86_64 armhfp, $(ARCH)), ) + FEDORA_TYPE := fedora-secondary + else + FEDORA_TYPE := fedora/linux + endif + ARCHIVED := $(shell [ $(BASE_OS_VERSION) -lt $(DEFAULT_OS_VERSION) ] && echo true) + ifeq ($(ARCHIVED),true) + BASE_URL := https://archives.fedoraproject.org/pub/archive/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ + else + BASE_URL := https://dl.fedoraproject.org/pub/$(FEDORA_TYPE)/releases/$(BASE_OS_VERSION)/Everything/$(ARCH)/os/Packages/ + endif endif LINUX_VERSION := Fedora_$(BASE_OS_VERSION) else @@ -87,8 +95,17 @@ endif # Define external dependencies # Latest that could be made to work. -GCC_VER := 11.2.0 -ifeq ($(GCC_VER), 11.2.0) +GCC_VER := 11.3.0 +ifeq ($(GCC_VER), 11.3.0) + gcc_ver := gcc-11.3.0 + binutils_ver := binutils-2.39 + ccache_ver := ccache-3.7.12 + mpfr_ver := mpfr-4.1.1 + gmp_ver := gmp-6.2.1 + mpc_ver := mpc-1.2.1 + gdb_ver := gdb-11.2 + REQUIRED_MIN_MAKE_MAJOR_VERSION := 4 +else ifeq ($(GCC_VER), 11.2.0) gcc_ver := gcc-11.2.0 binutils_ver := binutils-2.37 ccache_ver := ccache-3.7.12 @@ -189,7 +206,7 @@ RPM_LIST := \ libXi libXi-devel \ libXdmcp libXdmcp-devel \ libXau libXau-devel \ - libgcc \ + libgcc libxcrypt \ zlib zlib-devel \ libffi libffi-devel \ fontconfig fontconfig-devel \ @@ -245,7 +262,7 @@ define Download $$($(1)_CFG) : $$($(1)_FILE) mkdir -p $$(SRCDIR) tar -C $$(SRCDIR) -xf $$< - $$(foreach p,$$(abspath $$(wildcard patches/$$(notdir $$($(1)_DIR)).patch)), \ + $$(foreach p,$$(abspath $$(wildcard patches/$$(ARCH)-$$(notdir $$($(1)_DIR)).patch)), \ echo PATCHING $$(p) ; \ patch -d $$($(1)_DIR) -p1 -i $$(p) ; \ ) @@ -414,6 +431,12 @@ $(gcc) \ # wants. $(BUILDDIR)/$(binutils_ver)/Makefile : CONFIG += --enable-64-bit-bfd --libdir=$(PREFIX)/$(word 1,$(LIBDIRS)) +ifneq ($(ARCH), riscv64) + # gold is not available for riscv64 for some reason, + # and subsequent linking will fail if we try to enable it. + LINKER_CONFIG := --enable-gold=default +endif + # Makefile creation. Simply run configure in build dir. # Setting CFLAGS to -O2 generates a much faster ld. $(bfdmakes) \ @@ -426,11 +449,11 @@ $(BUILDDIR)/$(binutils_ver)/Makefile \ $(PATHPRE) $(ENVS) CFLAGS="-O2 $(CFLAGS)" \ $(BINUTILS_CFG) \ $(CONFIG) \ + $(LINKER_CONFIG) \ --with-sysroot=$(SYSROOT) \ --disable-nls \ --program-prefix=$(TARGET)- \ --enable-multilib \ - --enable-gold=default \ --enable-threads \ --enable-plugins \ ) > $(@D)/log.config 2>&1 @@ -494,7 +517,7 @@ ifeq ($(ARCH), armhfp) $(BUILDDIR)/$(gcc_ver)/Makefile : CONFIG += --with-float=hard endif -ifneq ($(filter ppc64 ppc64le s390x, $(ARCH)), ) +ifneq ($(filter riscv64 ppc64 ppc64le s390x, $(ARCH)), ) # We only support 64-bit on these platforms anyway CONFIG += --disable-multilib endif diff --git a/make/devkit/patches/riscv64-gcc-11.3.0.patch b/make/devkit/patches/riscv64-gcc-11.3.0.patch new file mode 100644 index 00000000000..911ab1683dc --- /dev/null +++ b/make/devkit/patches/riscv64-gcc-11.3.0.patch @@ -0,0 +1,14 @@ +diff -ur a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp 2022-11-30 12:25:37.363419659 +0100 ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp 2022-11-30 12:42:48.135412054 +0100 +@@ -59,7 +59,9 @@ + + #if !SANITIZER_ANDROID + #include +-#include ++// sys/mount.h conflicts with linux/fs.h in glibc 2.36+ ++// See https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E ++// This has been fixed elsewhere, but apparently not in Fedora riscv. + #include + #include + #endif