From 05e2f9fcc036655631edfe1240ccf57cc6c5ab07 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 5 Mar 2022 18:03:37 +0100 Subject: [PATCH 1/6] gcc: use --enable-autolink-libatomic for platforms that often need atomics. As explained in #35992, gcc often generates code that needs libatomic on these platforms, so link to libatomic by default (as-needed). Patches taken from Alpine. --- ...-go-fix-build-error-with-SYS_SECCOMP.patch | 41 +++ srcpkgs/gcc/patches/libatomic-autolink.patch | 267 ++++++++++++++++++ srcpkgs/gcc/patches/libatomic-configure.patch | 58 ++++ srcpkgs/gcc/template | 14 +- 4 files changed, 373 insertions(+), 7 deletions(-) create mode 100644 srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch create mode 100644 srcpkgs/gcc/patches/libatomic-autolink.patch create mode 100644 srcpkgs/gcc/patches/libatomic-configure.patch diff --git a/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch b/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch new file mode 100644 index 0000000000000..db38df3b010ab --- /dev/null +++ b/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch @@ -0,0 +1,41 @@ +From 548720bca6bff21ebc9aba22249d9ce45bbd90c7 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Wed, 29 Jun 2022 15:32:04 -0700 +Subject: [PATCH] libgo: handle stat st_atim32 field and SYS_SECCOMP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Patches for musl support, from Sören Tempel. + +Fixes https://gcc.gnu.org/PR105225 + +Change-Id: If396877d4a4c7d27962226d7a6e3bb91b1344413 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415294 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor +--- + libgo/mksysinfo.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 5aa30915..ea1fa17d 100755 +--- a/libgo/mksysinfo.sh ++++ b/libgo/mksysinfo.sh +@@ -127,6 +127,7 @@ fi + + # The syscall numbers. We force the names to upper case. + grep '^const _SYS_' gen-sysinfo.go | \ ++ grep -v '^const _SYS_SECCOMP = ' | \ + sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ + while read sys; do + sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` +@@ -506,7 +507,7 @@ fi + + # For historical reasons Go uses the suffix "timespec" instead of "tim" for + # stat_t's time fields on NetBSD. +-st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' ++st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' + if test "${GOOS}" = "netbsd"; then + st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' + fi diff --git a/srcpkgs/gcc/patches/libatomic-autolink.patch b/srcpkgs/gcc/patches/libatomic-autolink.patch new file mode 100644 index 0000000000000..20cdc42308dc5 --- /dev/null +++ b/srcpkgs/gcc/patches/libatomic-autolink.patch @@ -0,0 +1,267 @@ +Add --enable-autolink-libatomic, to make gcc link -latomic by default. + +Taken from Alpine: https://git.alpinelinux.org/aports/tree/main/gcc/0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch + +From 573a66e4146c9a65d895af9081a4d3d49cfc9e7a Mon Sep 17 00:00:00 2001 +From: Drew DeVault +Date: Wed, 9 Dec 2020 16:07:26 +0000 +Subject: [PATCH] configure: Add --enable-autolink-libatomic, use in + LINK_GCC_C_SEQUENCE_SPEC [PR81358] + +This fixes issues with RISC-V. +--- + Makefile.in | 1 + + gcc/config.in | 6 ++++++ + gcc/config/gnu-user.h | 12 +++++++++++- + gcc/configure | 32 ++++++++++++++++++++++++++++++-- + gcc/configure.ac | 22 +++++++++++++++++++++- + gcc/doc/install.texi | 8 ++++++++ + gcc/doc/tm.texi | 8 +++++++- + gcc/doc/tm.texi.in | 8 +++++++- + gcc/gcc.cc | 12 +++++++++++- + 9 files changed, 102 insertions(+), 7 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index b564ddbf792..a95c7407d16 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -232,6 +232,7 @@ HOST_EXPORTS = \ + RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \ + READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \ + TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ ++ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \ + HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \ + GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \ + GMPINC="$(HOST_GMPINC)"; export GMPINC; \ +diff --git a/gcc/config.in b/gcc/config.in +index f0fbf123aa8..af84efc4f9e 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -118,6 +118,12 @@ + #endif + + ++/* Define if libatomic should always be linked. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_AUTOLINK_LIBATOMIC ++#endif ++ ++ + /* Define to 1 to specify that we are using the BID decimal floating point + format instead of DPD */ + #ifndef USED_FOR_TARGET +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index 8433e56c3e1..0347f10da8b 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \ +- "%{static|static-pie:--start-group} %G %{!nolibc:%L} \ ++ "%{static|static-pie:--start-group} %G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L} \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" + + #undef LINK_GCC_C_SEQUENCE_SPEC +diff --git a/gcc/configure b/gcc/configure +index 2f6b3265a6c..6dc65bf4ccb 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -981,6 +981,7 @@ with_changes_root_url + enable_languages + with_multilib_list + with_multilib_generator ++enable_autolink_libatomic + with_zstd + with_zstd_include + with_zstd_lib +@@ -1710,6 +1711,9 @@ Optional Features: + --disable-shared don't provide a shared libgcc + --disable-gcov don't provide libgcov and related host tools + --enable-languages=LIST specify which front-ends to build ++ --enable-autolink-libatomic ++ enable automatic linking of libatomic (ignored if ++ not built) + --disable-rpath do not hardcode runtime library paths + --enable-sjlj-exceptions + arrange to use setjmp/longjmp exception handling +@@ -8324,7 +8328,6 @@ else + fi + + +- + # Check whether --with-multilib-generator was given. + if test "${with_multilib_generator+set}" = set; then : + withval=$with_multilib_generator; : +@@ -8332,6 +8335,32 @@ else + with_multilib_generator=default + fi + ++# If libatomic is available, whether it should be linked automatically ++# Check whether --enable-autolink-libatomic was given. ++if test "${enable_autolink_libatomic+set}" = set; then : ++ enableval=$enable_autolink_libatomic; ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) as_fn_error $? "'$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'." "$LINENO" 5 ;; ++ esac ++ ++else ++ enable_autolink_libatomic='' ++fi ++ ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ ++$as_echo "#define ENABLE_AUTOLINK_LIBATOMIC 1" >>confdefs.h ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&5 ++$as_echo "$as_me: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&2;} ++ fi ++fi ++ + + # ------------------------- + # Checks for other programs +@@ -34296,4 +34325,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} + fi + +- +diff --git a/gcc/configure.ac b/gcc/configure.ac +index e683d3a7a5f..07c81c78336 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -1205,6 +1205,27 @@ AC_ARG_WITH(multilib-generator, + :, + with_multilib_generator=default) + ++# If libatomic is available, whether it should be linked automatically ++AC_ARG_ENABLE(autolink-libatomic, ++[AS_HELP_STRING([--enable-autolink-libatomic], ++ [enable automatic linking of libatomic (ignored if not built)])], ++[ ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) AC_MSG_ERROR(['$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'.]) ;; ++ esac ++], [enable_autolink_libatomic='']) ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ AC_DEFINE(ENABLE_AUTOLINK_LIBATOMIC, 1, ++ [Define if libatomic should always be linked.]) ++ else ++ AC_MSG_WARN([libatomic is not build for this target, --enable-autolink-libatomic ignored]) ++ fi ++fi ++ + # ------------------------- + # Checks for other programs + # ------------------------- +@@ -7839,4 +7860,3 @@ done + ], + [subdirs='$subdirs']) + AC_OUTPUT +- +diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi +index 48408d842db..c90be0ee750 100644 +--- a/gcc/doc/install.texi ++++ b/gcc/doc/install.texi +@@ -2295,6 +2295,14 @@ files, but these changed header paths may conflict with some compilation + environments. Enabled by default, and may be disabled using + @option{--disable-canonical-system-headers}. + ++@item --enable-autolink-libatomic ++@itemx --disable-autolink-libatomic ++Tell GCC that it should automatically link libatomic; if supported by ++the linker, the file is only linked as needed. This flag is ignored ++when libatomic is not built. Note that this conigure flag is in particular ++useful when building an offloading-target compiler; as for those, a ++user had to specify @code{-foffload=target=-latomic} otherwise. ++ + @item --with-glibc-version=@var{major}.@var{minor} + Tell GCC that when the GNU C Library (glibc) is used on the target it + will be version @var{major}.@var{minor} or later. Normally this can +diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi +index c5006afc00d..56b62c69ae8 100644 +--- a/gcc/doc/tm.texi ++++ b/gcc/doc/tm.texi +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in +index f869ddd5e5b..57c93f24ac3 100644 +--- a/gcc/doc/tm.texi.in ++++ b/gcc/doc/tm.texi.in +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/gcc.cc b/gcc/gcc.cc +index 735b2b1bba1..f10f3c91aa7 100644 +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -987,13 +987,23 @@ proper position among the other output files. */ + # define ASM_DEBUG_OPTION_SPEC "" + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + /* Here is the spec for running the linker, after compiling all files. */ + + /* This is overridable by the target in case they need to specify the + -lgcc and -lc order specially, yet not require them to override all + of LINK_COMMAND_SPEC. */ + #ifndef LINK_GCC_C_SEQUENCE_SPEC +-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" ++#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}" + #endif + + #ifdef ENABLE_DEFAULT_SSP diff --git a/srcpkgs/gcc/patches/libatomic-configure.patch b/srcpkgs/gcc/patches/libatomic-configure.patch new file mode 100644 index 0000000000000..232de555155fe --- /dev/null +++ b/srcpkgs/gcc/patches/libatomic-configure.patch @@ -0,0 +1,58 @@ +Fix gcc check to build libatomic properly with --enable-autolink-libatomic. + +Taken from Alpine: https://git.alpinelinux.org/aports/tree/main/gcc/0036-configure-fix-detection-of-atomic-builtins-in-libato.patch + +From 4baaeb9661fa4015d9701e3616ce1ad4e8a07fd8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 29 Aug 2021 09:45:27 +0200 +Subject: [PATCH] configure: fix detection of atomic builtins in libatomic + configure script + +Alpine's --enable-autolink-libatomic (which is enabled for riscv64 by +default) causes the libatomic configure script to incorrectly detect +which builtins are available on riscv64. This then causes incorrect code +generation for libatomic since it assumes compiler builtins to be +available which are not actually available on riscv64. + +This commit fixes this issue by disabling linking of libatomic configure +test code entirely, thereby preventing linking against libatomic. + +See: + +* https://gitlab.alpinelinux.org/alpine/aports/-/issues/12948 +* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c6 +--- + libatomic/configure.tgt | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt +index 33f8c91ce77..3999db2cf8a 100644 +--- a/libatomic/configure.tgt ++++ b/libatomic/configure.tgt +@@ -30,6 +30,26 @@ + # on ${target_cpu}. For example to allow proper use of multilibs. + configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}" + ++# The libatomic configure script performs several checks to determine ++# whether builtins for atomic operations are available. When compiling ++# with --enable-autolink-libatomic the test code compiled by the ++# configure script is also linked against libatomic. This causes it ++# to think that builtins are available, even if there are not, since ++# the tested symbols are provided by libatomic. ++# ++# This is a hack to ensure that we don't link against libatomic by not ++# linking any configure test code at all when --enable-autolink-libatomic ++# is given. ++# ++# See: ++# ++# * https://gitlab.alpinelinux.org/alpine/aports/-/issues/12817 ++# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c4 ++# ++if test x$enable_autolink_libatomic = xyes; then ++ gcc_no_link=yes ++fi ++ + case "${target_cpu}" in + alpha*) + # fenv.c needs this option to generate inexact exceptions. diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template index 7b8bf456ebbae..fc97d56b88ae7 100644 --- a/srcpkgs/gcc/template +++ b/srcpkgs/gcc/template @@ -195,17 +195,17 @@ do_configure() { _hash=gnu case "$XBPS_TARGET_MACHINE" in - mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;; - mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;; - mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";; - mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";; - armv5*) _args+=" --with-arch=armv5te --with-float=soft";; - armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";; + mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;; + mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft --enable-autolink-libatomic"; _hash=sysv;; + mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic";; + mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft --enable-autolink-libatomic";; + armv5*) _args+=" --with-arch=armv5te --with-float=soft --enable-autolink-libatomic";; + armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-autolink-libatomic";; armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";; aarch64*) _args+=" --with-arch=armv8-a";; ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";; ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";; - ppc*) _args+=" --enable-secureplt";; + ppc*) _args+=" --enable-secureplt --enable-autolink-libatomic";; esac # on ppc64le-musl and all big endian ppc64 From 3a62ddbd2e93f9d143375141fd3862c4a82261dc Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 18 Jul 2019 11:30:56 +0200 Subject: [PATCH 2/6] gcc: add riscv. --- srcpkgs/gcc/template | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template index fc97d56b88ae7..2751c3d69282d 100644 --- a/srcpkgs/gcc/template +++ b/srcpkgs/gcc/template @@ -4,7 +4,7 @@ pkgname=gcc version=12.2.0 -revision=2 +revision=3 _minorver="${version%.*}" _majorver="${_minorver%.*}" _gmp_version=6.2.1 @@ -125,6 +125,8 @@ case "$XBPS_TARGET_MACHINE" in mipshf-musl) _triplet="mips-linux-muslhf";; mipsel-musl) _triplet="mipsel-linux-musl";; mipselhf-musl) _triplet="mipsel-linux-muslhf";; + riscv64) _triplet="riscv64-linux-gnu";; + riscv64-musl) _triplet="riscv64-linux-musl";; esac case "$XBPS_TARGET_MACHINE" in *-musl) depends+=" musl-devel";; @@ -143,6 +145,7 @@ case "$XBPS_TARGET_MACHINE" in esac case "$XBPS_TARGET_MACHINE" in mips*) ;; + riscv*) ;; x86_64*|i686) subpackages+=" libitm libitm-devel";; *) subpackages+=" libitm libitm-devel";; esac From 98c15e302a631d0c98a72b20cc66024b4b3ddbdb Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 6 Mar 2022 02:00:57 +0100 Subject: [PATCH 3/6] cross-arm-linux-gnueabihf: use --enable-autolink-libatomic. --- srcpkgs/cross-arm-linux-gnueabihf/template | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srcpkgs/cross-arm-linux-gnueabihf/template b/srcpkgs/cross-arm-linux-gnueabihf/template index 1a04ad3713af3..2c055324e8524 100644 --- a/srcpkgs/cross-arm-linux-gnueabihf/template +++ b/srcpkgs/cross-arm-linux-gnueabihf/template @@ -6,9 +6,10 @@ _linux_version=5.10.4 _glibc_patchver="72-g0f90d6204d" pkgname=cross-arm-linux-gnueabihf version=0.35 -revision=4 +revision=5 build_style=void-cross -configure_args="--with-arch=armv6 --with-fpu=vfp --with-float=hard" +configure_args="--with-arch=armv6 --with-fpu=vfp --with-float=hard + --enable-autolink-libatomic" hostmakedepends="texinfo tar gcc-objc gcc-go flex perl python3 pkg-config" makedepends="isl-devel libmpc-devel gmp-devel mpfr-devel zlib-devel libzstd-devel" From 0e208ed3a6be70ef4e9fea60164e9274f834ace5 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 21 Jul 2023 23:12:12 +0200 Subject: [PATCH 4/6] New package: cross-riscv64-linux-gnu-0.35 --- common/build-profiles/riscv64.sh | 7 ++++ common/build-style/void-cross.sh | 3 -- common/cross-profiles/riscv64.sh | 12 ++++++ common/shlibs | 1 + srcpkgs/cross-riscv64-linux-gnu-libc | 1 + srcpkgs/cross-riscv64-linux-gnu/template | 51 ++++++++++++++++++++++++ 6 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 common/build-profiles/riscv64.sh create mode 100644 common/cross-profiles/riscv64.sh create mode 120000 srcpkgs/cross-riscv64-linux-gnu-libc create mode 100644 srcpkgs/cross-riscv64-linux-gnu/template diff --git a/common/build-profiles/riscv64.sh b/common/build-profiles/riscv64.sh new file mode 100644 index 0000000000000..02ef7f85f5219 --- /dev/null +++ b/common/build-profiles/riscv64.sh @@ -0,0 +1,7 @@ +XBPS_TARGET_CFLAGS="-march=rv64imafdc" +XBPS_TARGET_CXXFLAGS="$XBPS_TARGET_CFLAGS" +XBPS_TARGET_FFLAGS="$XBPS_TARGET_CFLAGS" +XBPS_TRIPLET="riscv64-unknown-linux-gnu" +XBPS_RUST_TARGET="riscv64gc-unknown-linux-gnu" +XBPS_ZIG_TARGET="riscv64-linux-gnu" +XBPS_ZIG_CPU="baseline" diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh index 02bd1f5557416..d7da998ba354b 100644 --- a/common/build-style/void-cross.sh +++ b/common/build-style/void-cross.sh @@ -641,9 +641,6 @@ do_install() { ln -sf libgnat-${gcc_major}.so ${DESTDIR}/${sysroot}/usr/lib/libgnat.so rm -vf ${DESTDIR}/${adalib}/libgna{rl,t}.so - # Remove unnecessary libatomic which is only built for gccgo - rm -rf ${DESTDIR}/${sysroot}/usr/lib/libatomic.* - # If libquadmath was forced (needed for gfortran on some platforms) # then remove it because it conflicts with libquadmath package rm -rf ${DESTDIR}/${sysroot}/usr/lib/libquadmath.* diff --git a/common/cross-profiles/riscv64.sh b/common/cross-profiles/riscv64.sh new file mode 100644 index 0000000000000..18103d0bab5de --- /dev/null +++ b/common/cross-profiles/riscv64.sh @@ -0,0 +1,12 @@ +# Cross build profile for riscv64 and Musl libc. + +XBPS_TARGET_MACHINE="riscv64" +XBPS_TARGET_QEMU_MACHINE="riscv64" +XBPS_CROSS_TRIPLET="riscv64-linux-gnu" +XBPS_CROSS_CFLAGS="-march=rv64imafdc" +XBPS_CROSS_CXXFLAGS="$XBPS_CROSS_CFLAGS" +XBPS_CROSS_FFLAGS="$XBPS_CROSS_CFLAGS" +XBPS_CROSS_RUSTFLAGS="--sysroot=${XBPS_CROSS_BASE}/usr" +XBPS_CROSS_RUST_TARGET="riscv64gc-unknown-linux-gnu" +XBPS_CROSS_ZIG_TARGET="riscv64-linux-gnu" +XBPS_CROSS_ZIG_CPU="baseline" diff --git a/common/shlibs b/common/shlibs index dc2e91141d95c..2dfe481664466 100644 --- a/common/shlibs +++ b/common/shlibs @@ -26,6 +26,7 @@ ld-linux-x86-64.so.2 glibc-2.36_1 x86_64 ld-linux.so.2 glibc-2.36_1 i686 ld-linux.so.3 glibc-2.36_1 armv5tel ld-linux-aarch64.so.1 glibc-2.36_1 aarch64 +ld-linux-riscv64-lp64d.so.1 glibc-2.36_1 riscv64 ld64.so.2 glibc-2.36_1 ppc64 ld.so.1 glibc-2.36_1 mips ld.so.1 glibc-2.36_1 ppc diff --git a/srcpkgs/cross-riscv64-linux-gnu-libc b/srcpkgs/cross-riscv64-linux-gnu-libc new file mode 120000 index 0000000000000..e8371ddf3e4de --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-gnu-libc @@ -0,0 +1 @@ +cross-riscv64-linux-gnu \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-gnu/template b/srcpkgs/cross-riscv64-linux-gnu/template new file mode 100644 index 0000000000000..2eb8a05eded18 --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-gnu/template @@ -0,0 +1,51 @@ +# Template file for 'cross-riscv64-linux-gnu' +_binutils_version=2.39 +_gcc_version=12.2.0 +_glibc_version=2.36 +_glibc_patchver="72-g0f90d6204d" +_linux_version=5.10.4 +pkgname=cross-riscv64-linux-gnu +version=0.35 +revision=3 +build_style=void-cross +configure_args="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic --disable-multilib" +hostmakedepends="texinfo tar gcc-objc gcc-go flex perl python3 pkg-config" +makedepends="isl-devel libmpc-devel gmp-devel mpfr-devel + zlib-devel libzstd-devel" +depends="${pkgname}-libc-${version}_${revision}" +short_desc="Void cross toolchain for ${pkgname/cross-}" +maintainer="John " +license="GPL-2.0-or-later, GPL-3.0-or-later, LGPL-2.1-or-later" +homepage="https://www.voidlinux.org/" +distfiles="${GNU_SITE}/binutils/binutils-${_binutils_version}.tar.xz" +distfiles+=" ${GNU_SITE}/gcc/gcc-${_gcc_version}/gcc-${_gcc_version}.tar.xz" +# distfiles+=" ${GNU_SITE}/glibc/glibc-${_glibc_version}.tar.xz" +distfiles+=" https://vasilek.cz/paste/glibc-${_glibc_version}-${_glibc_patchver}.tar.xz" +distfiles+=" ${KERNEL_SITE}/kernel/v5.x/linux-${_linux_version}.tar.xz" +checksum="645c25f563b8adc0a81dbd6a41cffbf4d37083a382e02d5d3df4f65c09516d00 + e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff + 656200722d5ba968b4888a2d2950719d72c86290fd0479f61897d25b7db2cb57 + 904e396c26e9992a16cd1cc989460171536bed7739bf36049f6eb020ee5d56ec" +nocross=yes + +cross_glibc_cflags="-O2" + +if [ "$XBPS_TARGET_MACHINE" = "riscv64" ]; then + broken="Can't build crosstoolchain to itself" +fi + +case "$XBPS_MACHINE" in + ppc64*) ;; + ppc*|mips*) broken="no gccgo support";; +esac + +cross-riscv64-linux-gnu-libc_package() { + short_desc+=" - glibc files" + nostrip=yes + noshlibprovides=yes + noverifyrdeps=yes + + pkg_install() { + vmove usr/${sourcepkg/cross-} + } +} From 11803ce76a9593c45311387ea42985d16be4eafc Mon Sep 17 00:00:00 2001 From: John Date: Fri, 21 Jul 2023 23:12:14 +0200 Subject: [PATCH 5/6] New package: cross-riscv64-linux-musl-0.35 --- srcpkgs/cross-riscv64-linux-musl-libc | 1 + .../files/fix-cxxflags-passing.patch | 1 + .../files/invalid_tls_model.patch | 1 + .../files/libgnarl-musl.patch | 1 + .../files/musl-ada.patch | 1 + .../files/non-nullness.patch | 1 + srcpkgs/cross-riscv64-linux-musl/template | 53 +++++++++++++++++++ 7 files changed, 59 insertions(+) create mode 120000 srcpkgs/cross-riscv64-linux-musl-libc create mode 120000 srcpkgs/cross-riscv64-linux-musl/files/fix-cxxflags-passing.patch create mode 120000 srcpkgs/cross-riscv64-linux-musl/files/invalid_tls_model.patch create mode 120000 srcpkgs/cross-riscv64-linux-musl/files/libgnarl-musl.patch create mode 120000 srcpkgs/cross-riscv64-linux-musl/files/musl-ada.patch create mode 120000 srcpkgs/cross-riscv64-linux-musl/files/non-nullness.patch create mode 100644 srcpkgs/cross-riscv64-linux-musl/template diff --git a/srcpkgs/cross-riscv64-linux-musl-libc b/srcpkgs/cross-riscv64-linux-musl-libc new file mode 120000 index 0000000000000..29a94c9a7433d --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl-libc @@ -0,0 +1 @@ +cross-riscv64-linux-musl \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/files/fix-cxxflags-passing.patch b/srcpkgs/cross-riscv64-linux-musl/files/fix-cxxflags-passing.patch new file mode 120000 index 0000000000000..4a8c831e615dc --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/files/fix-cxxflags-passing.patch @@ -0,0 +1 @@ +../../gcc/patches/fix-cxxflags-passing.patch \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/files/invalid_tls_model.patch b/srcpkgs/cross-riscv64-linux-musl/files/invalid_tls_model.patch new file mode 120000 index 0000000000000..8f276dc053855 --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/files/invalid_tls_model.patch @@ -0,0 +1 @@ +../../gcc/patches/invalid_tls_model.patch \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/files/libgnarl-musl.patch b/srcpkgs/cross-riscv64-linux-musl/files/libgnarl-musl.patch new file mode 120000 index 0000000000000..33ccc9789f93f --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/files/libgnarl-musl.patch @@ -0,0 +1 @@ +../../gcc/files/libgnarl-musl.patch \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/files/musl-ada.patch b/srcpkgs/cross-riscv64-linux-musl/files/musl-ada.patch new file mode 120000 index 0000000000000..64906d48ecbf6 --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/files/musl-ada.patch @@ -0,0 +1 @@ +../../gcc/patches/musl-ada.patch \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/files/non-nullness.patch b/srcpkgs/cross-riscv64-linux-musl/files/non-nullness.patch new file mode 120000 index 0000000000000..c8b653748fe84 --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/files/non-nullness.patch @@ -0,0 +1 @@ +../../gcc/patches/non-nullness.patch \ No newline at end of file diff --git a/srcpkgs/cross-riscv64-linux-musl/template b/srcpkgs/cross-riscv64-linux-musl/template new file mode 100644 index 0000000000000..d20751fd9fdb6 --- /dev/null +++ b/srcpkgs/cross-riscv64-linux-musl/template @@ -0,0 +1,53 @@ +# Template file for 'cross-riscv64-linux-musl' +_binutils_version=2.39 +_gcc_version=12.2.0 +_musl_version=1.1.24 +_linux_version=5.10.4 +_libucontext_version=1.0 +pkgname=cross-riscv64-linux-musl +version=0.35 +revision=2 +build_style=void-cross +configure_args="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic --disable-multilib" +hostmakedepends="texinfo tar gcc-objc gcc-go flex perl python3 pkg-config" +makedepends="isl-devel libmpc-devel gmp-devel mpfr-devel + zlib-devel libzstd-devel" +depends="${pkgname}-libc-${version}_${revision}" +short_desc="Void cross toolchain for ${pkgname/cross-}" +maintainer="Orphaned " +license="GPL-2.0-or-later, GPL-3.0-or-later, MIT" +homepage="https://www.voidlinux.org/" +distfiles=" + ${GNU_SITE}/binutils/binutils-${_binutils_version}.tar.xz + ${GNU_SITE}/gcc/gcc-${_gcc_version}/gcc-${_gcc_version}.tar.xz + https://musl.libc.org/releases/musl-${_musl_version}.tar.gz + ${KERNEL_SITE}/kernel/v5.x/linux-${_linux_version}.tar.xz + https://github.com/kaniini/libucontext/archive/libucontext-${_libucontext_version}.tar.gz" +checksum="645c25f563b8adc0a81dbd6a41cffbf4d37083a382e02d5d3df4f65c09516d00 + e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff + 1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3 + 904e396c26e9992a16cd1cc989460171536bed7739bf36049f6eb020ee5d56ec + 23714e99a87f6dea82e8a073c526325161dd65462459820b16a6162be91955bb" +nocross=yes + +cross_musl_cflags="-O0" + +if [ "$XBPS_TARGET_MACHINE" = "riscv64-musl" ]; then + broken="Can't build crosstoolchain to itself" +fi + +case "$XBPS_MACHINE" in + ppc64*) ;; + ppc*|mips*) broken="no gccgo support";; +esac + +cross-riscv64-linux-musl-libc_package() { + short_desc+=" - libc files" + nostrip=yes + noshlibprovides=yes + noverifyrdeps=yes + + pkg_install() { + vmove usr/${sourcepkg/cross-} + } +} From 9e7c0fd96d6449d2dd6777c12aa9e14b393a7dea Mon Sep 17 00:00:00 2001 From: John Date: Fri, 21 Jul 2023 23:14:56 +0200 Subject: [PATCH 6/6] cross-vpkg-dummy: provide libatomic --- srcpkgs/cross-vpkg-dummy/template | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/srcpkgs/cross-vpkg-dummy/template b/srcpkgs/cross-vpkg-dummy/template index baf92e2560c3a..e1332e9d299a3 100644 --- a/srcpkgs/cross-vpkg-dummy/template +++ b/srcpkgs/cross-vpkg-dummy/template @@ -13,6 +13,8 @@ provides=" binutils-9999_1 libada-9999_1 libada-devel-9999_1 + libatomic-9999_1 + libatomic-devel-9999_1 libgcc-9999_1 libgcc-devel-9999_1 libstdc++-9999_1 @@ -36,6 +38,8 @@ conflicts=" binutils>=0 libada>=0 libada-devel>=0 + libatomic>=0 + libatomic-devel>=0 libgcc>=0 libgcc-devel>=0 libstdc++>=0 @@ -55,6 +59,7 @@ conflicts=" gcc-objc>=0 gcc-objc++>=0" shlib_provides=" + libatomic.so.1 libgcc_s.so.1 libgnat-12.so libgnarl-12.so @@ -75,4 +80,5 @@ else shlib_provides+=" ld-linux.so.2 ld-linux.so.3 ld-linux-x86-64.so.2" shlib_provides+=" ld-linux-armhf.so.3 ld-linux-aarch64.so.1" shlib_provides+=" ld64.so.2 ld.so.1 libthread_db.so.1" + shlib_provides+=" ld-linux-riscv64-lp64d.so.1" fi