From: Alexey Brodkin via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
Sergey Matyukevich <geomatsi@gmail.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Sergey Matyukevich <Sergey.Matyukevich@synopsys.com>
Subject: [Buildroot] [PATCH 1/2] package/glibc: add support for ARC700
Date: Wed, 16 Nov 2022 00:52:34 +0100 [thread overview]
Message-ID: <20221115235235.74897-2-abrodkin@synopsys.com> (raw)
In-Reply-To: <20221115235235.74897-1-abrodkin@synopsys.com>
From: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
Even though ARC700 glibc port is very close to ARCv2 port, it is formally
another ABI that requires appropriate maintenance. That includes running
extensive glibc test-suite and fixing discovered issues and regressions.
That effort was considered impractical due to ARCompact ISA reaching EOL.
Besides ARC700 processors are usually found on very resource constrained
devices that tend to use uClibc if they run Linux.
On the other hand adding ARC700 glibc support still can be useful for
development and testing purposes. This commit adds two glibc patches
that enable ARC700 support.
Fixes https://gitlab.com/buildroot.org/buildroot/-/jobs/3259666747 and
the likes.
Signed-off-by: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
.../glibc/0003-ARC-Synopsys-ARC700-support.patch | 208 +++++++++++++++++++++
1 file changed, 208 insertions(+)
create mode 100644 package/glibc/0003-ARC-Synopsys-ARC700-support.patch
diff --git a/package/glibc/0003-ARC-Synopsys-ARC700-support.patch b/package/glibc/0003-ARC-Synopsys-ARC700-support.patch
new file mode 100644
index 0000000000..187824da72
--- /dev/null
+++ b/package/glibc/0003-ARC-Synopsys-ARC700-support.patch
@@ -0,0 +1,208 @@
+From f835f30c15d55db42dbbdfa33e9560844d5bf071 Mon Sep 17 00:00:00 2001
+From: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
+Date: Wed, 16 Nov 2022 00:34:06 +0100
+Subject: [PATCH] ARC: Synopsys ARC700 support
+
+Synopsys ARC700 processors are not supported by glibc out of the box.
+Meanwhile ARC700 glibc port is very similar to ARCv2 port. Original
+glibc patch included both ARC700 and ARCv2:
+- https://sourceware.org/pipermail/libc-alpha/2020-March/111855.html
+
+For ARC700 specific changes see patches 5 and 8 from that series:
+- https://sourceware.org/pipermail/libc-alpha/2020-March/111851.html
+- https://sourceware.org/pipermail/libc-alpha/2020-March/111858.html
+
+However ARC700 changes have been dropped from the later revisions of
+ARCv2 glibc patch series. So they have not been added to mainline
+glibc together with ARCv2 port.
+
+This patch is based on the original ARC700 glibc work. It adds all
+the missing pieces required to make glibc work on ARC700. Besides,
+this patch adds specific loader name according to Linux target
+triplet for ARC700.
+
+Signed-off-by: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
+---
+ config.h.in | 3 +++
+ sysdeps/arc/atomic-machine.h | 4 ++++
+ sysdeps/arc/configure | 29 +++++++++++++++++++++++++++++
+ sysdeps/arc/configure.ac | 11 +++++++++++
+ sysdeps/unix/sysv/linux/arc/ldconfig.h | 8 +++++---
+ sysdeps/unix/sysv/linux/arc/shlib-versions | 8 ++++++++
+ sysdeps/unix/sysv/linux/arc/syscall.S | 5 +++++
+ sysdeps/unix/sysv/linux/arc/sysdep.h | 8 ++++++++
+ 8 files changed, 73 insertions(+), 3 deletions(-)
+
+diff --git a/config.h.in b/config.h.in
+index 43d32518ab..46863cc507 100644
+--- a/config.h.in
++++ b/config.h.in
+@@ -120,6 +120,9 @@
+ /* ARC big endian ABI */
+ #undef HAVE_ARC_BE
+
++/* ARC 700 */
++#undef HAVE_ARC700
++
+ /* C-SKY ABI version. */
+ #undef CSKYABI
+
+diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
+index 3d17f78990..35992f1540 100644
+--- a/sysdeps/arc/atomic-machine.h
++++ b/sysdeps/arc/atomic-machine.h
+@@ -52,6 +52,10 @@
+ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
+ mem, new, old, __ATOMIC_ACQUIRE)
+
++#ifdef __ARC700__
++#define atomic_full_barrier() ({ asm volatile ("sync":::"memory"); })
++#else
+ #define atomic_full_barrier() ({ asm volatile ("dmb 3":::"memory"); })
++#endif
+
+ #endif /* _ARC_BITS_ATOMIC_H */
+diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
+index 92050f44e3..e5916c9615 100644
+--- a/sysdeps/arc/configure
++++ b/sysdeps/arc/configure
+@@ -178,3 +178,32 @@ else
+ config_vars="$config_vars
+ default-abi = arcle"
+ fi
++
++# For ARC700 ABI, generate a symbol for shlib-versions
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for arc700" >&5
++$as_echo_n "checking for arc700... " >&6; }
++if ${libc_cv_arc700+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#ifdef __ARC700__
++ yes
++ #endif
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "yes" >/dev/null 2>&1; then :
++ libc_cv_arc700=yes
++else
++ libc_cv_arc700=no
++fi
++rm -f conftest*
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_arc700" >&5
++$as_echo "$libc_cv_arc700" >&6; }
++if test $libc_cv_arc700 = yes; then
++ $as_echo "#define HAVE_ARC700 1" >>confdefs.h
++
++fi
+diff --git a/sysdeps/arc/configure.ac b/sysdeps/arc/configure.ac
+index 619da4e088..3d10fbde6b 100644
+--- a/sysdeps/arc/configure.ac
++++ b/sysdeps/arc/configure.ac
+@@ -23,3 +23,14 @@ if test $libc_cv_arc_be = yes; then
+ else
+ LIBC_CONFIG_VAR([default-abi], [arcle])
+ fi
++
++# For ARC700 ABI, generate a symbol for shlib-versions
++AC_CACHE_CHECK([for arc700],
++ [libc_cv_arc700],
++ [AC_EGREP_CPP(yes,[#ifdef __ARC700__
++ yes
++ #endif
++ ], libc_cv_arc700=yes, libc_cv_arc700=no)])
++if test $libc_cv_arc700 = yes; then
++ AC_DEFINE(HAVE_ARC700)
++fi
+diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h b/sysdeps/unix/sysv/linux/arc/ldconfig.h
+index f673170e59..bb1f5eb64a 100644
+--- a/sysdeps/unix/sysv/linux/arc/ldconfig.h
++++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
+@@ -18,9 +18,11 @@
+
+ #include <sysdeps/generic/ldconfig.h>
+
+-#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+- { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 }, \
+- { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 },
++#define SYSDEP_KNOWN_INTERPRETER_NAMES \
++ { "/lib/ld-linux-arc.so.2", FLAG_ELF_LIBC6 }, \
++ { "/lib/ld-linux-arceb.so.2", FLAG_ELF_LIBC6 }, \
++ { "/lib/ld-linux-arc700.so.2", FLAG_ELF_LIBC6 }, \
++ { "/lib/ld-linux-arc700eb.so.2", FLAG_ELF_LIBC6 },
+
+ #define SYSDEP_KNOWN_LIBRARY_NAMES \
+ { "libc.so.6", FLAG_ELF_LIBC6 }, \
+diff --git a/sysdeps/unix/sysv/linux/arc/shlib-versions b/sysdeps/unix/sysv/linux/arc/shlib-versions
+index 343c0a0450..ab263bf2fb 100644
+--- a/sysdeps/unix/sysv/linux/arc/shlib-versions
++++ b/sysdeps/unix/sysv/linux/arc/shlib-versions
+@@ -1,7 +1,15 @@
+ DEFAULT GLIBC_2.32
+
++%ifdef HAVE_ARC700
++%ifdef HAVE_ARC_BE
++ld=ld-linux-arc700eb.so.2
++%else
++ld=ld-linux-arc700.so.2
++%endif
++%else
+ %ifdef HAVE_ARC_BE
+ ld=ld-linux-arceb.so.2
+ %else
+ ld=ld-linux-arc.so.2
+ %endif
++%endif
+diff --git a/sysdeps/unix/sysv/linux/arc/syscall.S b/sysdeps/unix/sysv/linux/arc/syscall.S
+index 2aa4d9d65a..63f76d00d3 100644
+--- a/sysdeps/unix/sysv/linux/arc/syscall.S
++++ b/sysdeps/unix/sysv/linux/arc/syscall.S
+@@ -24,8 +24,13 @@ ENTRY (syscall)
+ mov_s r1, r2
+ mov_s r2, r3
+ mov_s r3, r4
++#ifdef __ARC700__
++ mov r4, r5
++ mov r5, r6
++#else
+ mov_s r4, r5
+ mov_s r5, r6
++#endif
+
+ ARC_TRAP_INSN
+ brhi r0, -4096, L (call_syscall_err)
+diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h
+index d0c1a78381..a65d7b09a1 100644
+--- a/sysdeps/unix/sysv/linux/arc/sysdep.h
++++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
+@@ -128,7 +128,11 @@ L (call_syscall_err): ASM_LINE_SEP \
+ mov r8, __NR_##syscall_name ASM_LINE_SEP \
+ ARC_TRAP_INSN ASM_LINE_SEP
+
++# ifdef __ARC700__
++# define ARC_TRAP_INSN trap0
++# else
+ # define ARC_TRAP_INSN trap_s 0
++# endif
+
+ #else /* !__ASSEMBLER__ */
+
+@@ -137,7 +141,11 @@ extern long int __syscall_error (long int);
+ hidden_proto (__syscall_error)
+ # endif
+
++# ifdef __ARC700__
++# define ARC_TRAP_INSN "trap0 \n\t"
++# else
+ # define ARC_TRAP_INSN "trap_s 0 \n\t"
++#endif
+
+ # undef INTERNAL_SYSCALL_NCS
+ # define INTERNAL_SYSCALL_NCS(number, nr_args, args...) \
+--
+2.16.2
+
--
2.16.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2022-11-15 23:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 23:52 [Buildroot] [PATCH 0/2] Enable (or rather fix) glibc for ARC700 Alexey Brodkin via buildroot
2022-11-15 23:52 ` Alexey Brodkin via buildroot [this message]
2022-11-16 7:54 ` [Buildroot] [PATCH 1/2] package/glibc: add support " Thomas Petazzoni via buildroot
2022-11-16 15:33 ` Alexey Brodkin via buildroot
2022-11-24 11:49 ` Arnout Vandecappelle
2022-11-15 23:52 ` [Buildroot] [PATCH 2/2] configs/snps_arc700_nsim_defconfig: add ARC700 target for nSIM Alexey Brodkin via buildroot
2023-08-06 20:48 ` Thomas Petazzoni via buildroot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221115235235.74897-2-abrodkin@synopsys.com \
--to=buildroot@buildroot.org \
--cc=Alexey.Brodkin@synopsys.com \
--cc=Sergey.Matyukevich@synopsys.com \
--cc=geomatsi@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox