From ecb09ca417a9719c59c7247fd77237b275e277e3 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Wed, 16 May 2018 13:52:43 +0300 Subject: ARC: Add multilib support for Linux in GCC We never bothered to build multilibbed Linux toolchains for ARC and so we ended-up with no support of multilib for arc*-*-linux-* targets in GCC. That is now fixed in upstream by the following commit: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0eacfbcb2bf1834294f468a2bb41fe5d5e8d3883 Once the fix mentioned above is applied on top of GCC 8.1.0 we may easily build multilibbed uClibc toolchain for ARC. Note sice Glibc port for ARC is still in review process we cannot build any Glibc toolchains for ARC with pure upstream components, for that we eiter need Glibc sources from our Github repo or apply a set of patches on top of Glibc 2.27 - we'll try to address this later though. Signed-off-by: Alexey Brodkin diff --git a/packages/gcc/8.1.0/0019-ARC-Add-multilib-support-for-linux-targets.patch b/packages/gcc/8.1.0/0019-ARC-Add-multilib-support-for-linux-targets.patch new file mode 100644 index 0000000..6151067 --- /dev/null +++ b/packages/gcc/8.1.0/0019-ARC-Add-multilib-support-for-linux-targets.patch @@ -0,0 +1,76 @@ +From 0eacfbcb2bf1834294f468a2bb41fe5d5e8d3883 Mon Sep 17 00:00:00 2001 +From: claziss +Date: Mon, 21 May 2018 09:56:57 +0000 +Subject: [PATCH] [ARC] Add multilib support for linux targets + +We used to build baremetal (AKA Elf32) multilibbed toolchains for years +now but never made that for Linux targets since there were problems with +uClibc n multilib setup. Now with help of Crosstool-NG it is finally +possible to create uClibc-based multilibbed toolchains and so we add +relevant CPUs for multilib in case of configuration for "arc*-*-linux*". + +This will be essentially useful for glibc-based multilibbbed toolchains +in the future. + +gcc/ +2018-05-16 Alexey Brodkin + + * config.gcc: Add arc/t-multilib-linux to tmake_file for + arc*-*-linux*. + * config/arc/t-multilib-linux: Specify MULTILIB_OPTIONS and + MULTILIB_DIRNAMES + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260434 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + gcc/config.gcc | 2 +- + gcc/config/arc/t-multilib-linux | 25 +++++++++++++++++++++++++ + 2 files changed, 26 insertions(+), 1 deletion(-) + create mode 100644 gcc/config/arc/t-multilib-linux + +diff --git a/gcc/config.gcc b/gcc/config.gcc +index 96ae6a88a0db..d73e2cbc99a1 100644 +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -1061,7 +1061,7 @@ arc*-*-elf*) + ;; + arc*-*-linux*) + tm_file="arc/arc-arch.h dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arc/linux.h ${tm_file}" +- tmake_file="${tmake_file} arc/t-arc" ++ tmake_file="${tmake_file} arc/t-multilib-linux arc/t-arc" + extra_gcc_objs="driver-arc.o" + if test "x$with_cpu" != x; then + tm_defines="${tm_defines} TARGET_CPU_BUILD=PROCESSOR_$with_cpu" +diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux +new file mode 100644 +index 000000000000..f357cfc3f926 +--- /dev/null ++++ b/gcc/config/arc/t-multilib-linux +@@ -0,0 +1,25 @@ ++# Copyright (C) 2018 Free Software Foundation, Inc. ++# ++# This file is part of GCC. ++# ++# GCC is free software; you can redistribute it and/or modify it under ++# the terms of the GNU General Public License as published by the Free ++# Software Foundation; either version 3, or (at your option) any later ++# version. ++# ++# GCC is distributed in the hope that it will be useful, but WITHOUT ANY ++# WARRANTY; without even the implied warranty of MERCHANTABILITY or ++# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++# for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . ++ ++MULTILIB_OPTIONS = mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400 ++ ++MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400 ++ ++# Aliases: ++MULTILIB_MATCHES += mcpu?arc700=mA7 ++MULTILIB_MATCHES += mcpu?arc700=mARC700 +-- +2.17.0 + -- cgit v0.10.2-6-g49f6 From b078bb09dd3e460788d914a07adf3f4f53c86494 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Tue, 15 May 2018 18:36:24 +0300 Subject: ARC: Add Linux uClibc multilib sample Signed-off-by: Alexey Brodkin diff --git a/samples/arc-multilib-linux-uclibc/crosstool.config b/samples/arc-multilib-linux-uclibc/crosstool.config new file mode 100644 index 0000000..b56c8a8 --- /dev/null +++ b/samples/arc-multilib-linux-uclibc/crosstool.config @@ -0,0 +1,7 @@ +CT_ARCH_ARC=y +CT_TARGET_ALIAS="arc-linux" +CT_TARGET_CFLAGS="-matomic" +CT_TARGET_VENDOR="multilib" +CT_KERNEL_LINUX=y +CT_LIBC_UCLIBC=y +CT_MULTILIB=y diff --git a/samples/arc-multilib-linux-uclibc/reported.by b/samples/arc-multilib-linux-uclibc/reported.by new file mode 100644 index 0000000..59fc53a --- /dev/null +++ b/samples/arc-multilib-linux-uclibc/reported.by @@ -0,0 +1,3 @@ +reporter_name="Alexey Brodkin" +reporter_url="http://embarc.org" +reporter_comment="ARC multilib uClibc Linux toolchain" -- cgit v0.10.2-6-g49f6 From 0a64056dd3d094503a1ef1d23d2636bcd9708b2f Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Mon, 21 May 2018 14:03:59 +0300 Subject: ARC: Disable CONFIG_ARC_HAS_ATOMICS in uClibc if building without -matomics In case we build for ARC core which has no support of atomic ops among other things we need to configure libc to use Linux kernel helper to emulate HS atomic ops. This is done with disabling of CONFIG_ARC_HAS_ATOMICS in uClibc. Currently we __remove__ this option from .config but this makes no sense as its default state is "y" so we need to explicitly disable it instead. Signed-off-by: Alexey Brodkin diff --git a/scripts/build/arch/arc.sh b/scripts/build/arch/arc.sh index fb9d93b..2b48e4b 100644 --- a/scripts/build/arch/arc.sh +++ b/scripts/build/arch/arc.sh @@ -22,7 +22,7 @@ CT_DoArchUClibcCflags() { local cflags="${2}" local f - CT_KconfigDeleteOption "CONFIG_ARC_HAS_ATOMICS" "${cfg}" + CT_KconfigDisableOption "CONFIG_ARC_HAS_ATOMICS" "${cfg}" for f in ${cflags}; do case "${f}" in -- cgit v0.10.2-6-g49f6 From 409046f91d18f4f80f044f2e9c08c0e9e04eeb92 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Mon, 21 May 2018 13:33:50 +0300 Subject: ARC: Update Linux samples There's no point in keeping samples which are in its essense just a sub-set of multilib toolchain. But still we'd like to cover quite unusual but really existing case - ARC750, i.e. ARC700 with MMU but without so-called atomic instructions (LLOCK/SCOND). To support this HW variation we need: 1) Compile all target binaries without "-matomics" or even better "-mno-atomics" so that's even future-proof (as we may decide to enable "-matomics" by default for Linux targets which is a recommented setup). 2) Configure libc such that it uses Linux-kernel-assisted implementation of atomic operation via "arc_usr_cmpxchg" syscall, see https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=b985fa069187e4c5a7ee84213d9fbead2f219ce5 Signed-off-by: Alexey Brodkin diff --git a/samples/arc-arc700-linux-uclibc/crosstool.config b/samples/arc-arc700-linux-uclibc/crosstool.config index e7b298b..66a0b52 100644 --- a/samples/arc-arc700-linux-uclibc/crosstool.config +++ b/samples/arc-arc700-linux-uclibc/crosstool.config @@ -1,6 +1,6 @@ CT_ARCH_ARC=y CT_TARGET_ALIAS="arc-linux" -CT_TARGET_CFLAGS="-matomic" +CT_TARGET_CFLAGS="-mno-atomic" CT_TARGET_VENDOR="snps" CT_KERNEL_LINUX=y CT_LIBC_UCLIBC=y diff --git a/samples/arc-arc700-linux-uclibc/reported.by b/samples/arc-arc700-linux-uclibc/reported.by index 9019567..a493696 100644 --- a/samples/arc-arc700-linux-uclibc/reported.by +++ b/samples/arc-arc700-linux-uclibc/reported.by @@ -1,3 +1,3 @@ reporter_name="Alexey Brodkin" reporter_url="http://embarc.org" -reporter_comment="ARCompact default Linux toolchain" +reporter_comment="ARCompact uClibc Linux toolchain without atomics" diff --git a/samples/arc-archs-linux-uclibc/crosstool.config b/samples/arc-archs-linux-uclibc/crosstool.config deleted file mode 100644 index b1792e1..0000000 --- a/samples/arc-archs-linux-uclibc/crosstool.config +++ /dev/null @@ -1,7 +0,0 @@ -CT_ARCH_ARC=y -CT_TARGET_ALIAS="arc-linux" -CT_TARGET_CFLAGS="-matomic" -CT_TARGET_VENDOR="snps" -CT_KERNEL_LINUX=y -CT_LIBC_UCLIBC=y -CT_ARCH_CPU="hs38" diff --git a/samples/arc-archs-linux-uclibc/reported.by b/samples/arc-archs-linux-uclibc/reported.by deleted file mode 100644 index 59f194c..0000000 --- a/samples/arc-archs-linux-uclibc/reported.by +++ /dev/null @@ -1,3 +0,0 @@ -reporter_name="Alexey Brodkin" -reporter_url="http://embarc.org" -reporter_comment="ARCv2 default Linux toolchain" -- cgit v0.10.2-6-g49f6