diff mbox series

[1/2] package/glibc: add support for ARC700

Message ID 20221115235235.74897-2-abrodkin@synopsys.com
State Changes Requested
Headers show
Series Enable (or rather fix) glibc for ARC700 | expand

Commit Message

Alexey Brodkin Nov. 15, 2022, 11:52 p.m. UTC
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

Comments

Thomas Petazzoni Nov. 16, 2022, 7:54 a.m. UTC | #1
On Wed, 16 Nov 2022 00:52:34 +0100
Alexey Brodkin <Alexey.Brodkin@synopsys.com> wrote:

> 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.

Hmm, this commit only adds one patch. Also, what is the upstream status
of this patch? In order to make sure we can easily update glibc, I'm
not too fan to have patches that are not upstream.

Thomas
Alexey Brodkin Nov. 16, 2022, 3:33 p.m. UTC | #2
Hi Thomas,

> > 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.
> 
> Hmm, this commit only adds one patch.

Correct, because that's all what's needed for ARC700 to be supported by glibc
as good as ARC HS processors are. Seriously, there're just a couple of
instructions which need to be changed (like use "trap0" instead of "trap_s 0")
and dynamic loader name is different ("/lib/ld-linux-arc700.so.2"). All the
rest is some configuration/infrastructural nonsense.

> Also, what is the upstream status of this patch?

As it is said in the patch itself, we decided to not officially maintain ARC700 
in glibc due to very strict rules in the upstream glibc community for supported
architectures and ABI's. But given minimal differences compared to ARCv2
(read "ARC HS") port, IMHO it's practical to have ARC700 support "downstream"
with a bit more relaxed requirements on maintenance activities... which doesn't
mean I'd like to throw stuff over the wall and never do anything about it.

> In order to make sure we can easily update glibc, I'm not too fan to have
> patches that are not upstream.

That's understood, but for many releases that change was equally applicable to
newer glibc versions (as we touch code which is rarely being modified) and even
now I re-based or refreshed this patch from 2.34 to 2.36 automatically with
only changes of hunk offsets (for the record, even before refresh, the patch
got applied to the current glibc in Buildroot only showing patch warnings
related to offsets).

That said, if you're not comfortable with the current maintenance status of
glibc for ARC700, we may drop it and limit ARC700 to only uClibc, otherwise
let's keep that patch until it seriously get in the way on glibc upgrade etc.

-Alexey
Arnout Vandecappelle Nov. 24, 2022, 11:49 a.m. UTC | #3
On 16/11/2022 16:33, Alexey Brodkin via buildroot wrote:
> Hi Thomas,
> 
>>> 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.

  This sounds very much like we should use uClibc in snps_arc700_axs101_defconfig.

>>>
>>> On the other hand adding ARC700 glibc support still can be useful for
>>> development and testing purposes. This commit adds two glibc patches

  "Development and testing purposes" is really not making a strong case... It 
sounds like the only reason to keep those glibc patches is to be able to test 
glibc, but you don't want to commit to really fully support glibc, so what is 
the point then?

>>> that enable ARC700 support.

  The cover letter says that it fixes something, then the commit message should 
contain a Fixes: line so it's clear that this patch is for master, not next.

>>
>> Hmm, this commit only adds one patch.
> 
> Correct, because that's all what's needed for ARC700 to be supported by glibc
> as good as ARC HS processors are. Seriously, there're just a couple of
> instructions which need to be changed (like use "trap0" instead of "trap_s 0")
> and dynamic loader name is different ("/lib/ld-linux-arc700.so.2"). All the
> rest is some configuration/infrastructural nonsense.
> 
>> Also, what is the upstream status of this patch?
> 
> As it is said in the patch itself, we decided to not officially maintain ARC700
> in glibc due to very strict rules in the upstream glibc community for supported
> architectures and ABI's. But given minimal differences compared to ARCv2
> (read "ARC HS") port, IMHO it's practical to have ARC700 support "downstream"
> with a bit more relaxed requirements on maintenance activities... which doesn't
> mean I'd like to throw stuff over the wall and never do anything about it.

  Yeah, what you're saying is: fully supporting it is a lot of effort because 
you have to run all the tests every time glibc is updated (and there are 
probably tests that will fail because they're somewhat fragile). While just 
carrying those patches is probably going to work for most people.

> 
>> In order to make sure we can easily update glibc, I'm not too fan to have
>> patches that are not upstream.
> 
> That's understood, but for many releases that change was equally applicable to
> newer glibc versions (as we touch code which is rarely being modified) and even
> now I re-based or refreshed this patch from 2.34 to 2.36 automatically with
> only changes of hunk offsets (for the record, even before refresh, the patch
> got applied to the current glibc in Buildroot only showing patch warnings
> related to offsets).
> 
> That said, if you're not comfortable with the current maintenance status of
> glibc for ARC700, we may drop it and limit ARC700 to only uClibc, otherwise
> let's keep that patch until it seriously get in the way on glibc upgrade etc.

  I don't see much advantage for Synopsys to spend any effort at all in 
maintaining glibc for ARC700. So I'd simply limit ARC700 to uClibc. If in the 
future you encounter a real use case for supporting glibc, then I think we can 
carry those glibc patches - as you said, they should still apply. But until 
then, I wouldn't bother.

  Regards,
  Arnout


> 
> -Alexey
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

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
+