public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libgloss: arm: break newlib dependency
@ 2022-12-14  9:13 Mike Frysinger
  2022-12-19  9:34 ` Corinna Vinschen
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Mike Frysinger @ 2022-12-14  9:13 UTC (permalink / raw)
  To: newlib

The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, duplicate that
header here so we can keep libgloss independent as it's meant to be.
---
 libgloss/arm/Makefile.in   |   2 -
 libgloss/arm/acle-compat.h | 182 +++++++++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 2 deletions(-)
 create mode 100644 libgloss/arm/acle-compat.h

diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in
index 06fae10c1fca..d0d5ea89d62e 100644
--- a/libgloss/arm/Makefile.in
+++ b/libgloss/arm/Makefile.in
@@ -97,8 +97,6 @@ IQ80310_INSTALL	= install-iq80310
 # Host specific makefile fragment comes in here.
 @host_makefile_frag@
 
-INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi`
-
 #
 # build a test program for each target board. Just trying to get
 # it to link is a good test, so we ignore all the errors for now.
diff --git a/libgloss/arm/acle-compat.h b/libgloss/arm/acle-compat.h
new file mode 100644
index 000000000000..888ae2ea8afb
--- /dev/null
+++ b/libgloss/arm/acle-compat.h
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2014 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __ARM_ARCH
+
+/* ACLE standardises a set of pre-defines that describe the ARM architecture.
+   These were mostly implemented in GCC around GCC-4.8; older versions
+   have no, or only partial support.  To provide a level of backwards
+   compatibility we try to work out what the definitions should be, given
+   the older pre-defines that GCC did produce.  This isn't complete, but
+   it should be enough for use by routines that depend on this header.  */
+
+/* No need to handle ARMv8, GCC had ACLE support before that.  */
+
+# ifdef __ARM_ARCH_7__
+/* The common subset of ARMv7 in all profiles.  */
+#  define __ARM_ARCH 7
+#  define __ARM_ARCH_ISA_THUMB 2
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_LDREX 7
+#  define __ARM_FEATURE_UNALIGNED
+# endif
+
+# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
+#  define __ARM_ARCH 7
+#  define __ARM_ARCH_ISA_THUMB 2
+#  define __ARM_ARCH_ISA_ARM
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_SIMD32
+#  define __ARM_FEATURE_DSP
+#  define __ARM_FEATURE_QBIT
+#  define __ARM_FEATURE_SAT
+#  define __ARM_FEATURE_LDREX 15
+#  define __ARM_FEATURE_UNALIGNED
+#  ifdef __ARM_ARCH_7A__
+#   define __ARM_ARCH_PROFILE 'A'
+#  else
+#   define __ARM_ARCH_PROFILE 'R'
+#  endif
+# endif
+
+# ifdef __ARM_ARCH_7EM__
+#  define __ARM_ARCH 7
+#  define __ARM_ARCH_ISA_THUMB 2
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_SIMD32
+#  define __ARM_FEATURE_DSP
+#  define __ARM_FEATURE_QBIT
+#  define __ARM_FEATURE_SAT
+#  define __ARM_FEATURE_LDREX 7
+#  define __ARM_FEATURE_UNALIGNED
+#  define __ARM_ARCH_PROFILE 'M'
+# endif
+
+# ifdef __ARM_ARCH_7M__
+#  define __ARM_ARCH 7
+#  define __ARM_ARCH_ISA_THUMB 2
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_QBIT
+#  define __ARM_FEATURE_SAT
+#  define __ARM_FEATURE_LDREX 7
+#  define __ARM_FEATURE_UNALIGNED
+#  define __ARM_ARCH_PROFILE 'M'
+# endif
+
+# ifdef __ARM_ARCH_6T2__
+#  define __ARM_ARCH 6
+#  define __ARM_ARCH_ISA_THUMB 2
+#  define __ARM_ARCH_ISA_ARM
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_SIMD32
+#  define __ARM_FEATURE_DSP
+#  define __ARM_FEATURE_QBIT
+#  define __ARM_FEATURE_SAT
+#  define __ARM_FEATURE_LDREX 4
+#  define __ARM_FEATURE_UNALIGNED
+# endif
+
+# ifdef __ARM_ARCH_6M__
+#  define __ARM_ARCH 6
+#  define __ARM_ARCH_ISA_THUMB 1
+#  define __ARM_ARCH_PROFILE 'M'
+# endif
+
+# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
+  || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
+  || defined (__ARM_ARCH_6ZK__)
+#  define __ARM_ARCH 6
+#  define __ARM_ARCH_ISA_THUMB 1
+#  define __ARM_ARCH_ISA_ARM
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_SIMD32
+#  define __ARM_FEATURE_DSP
+#  define __ARM_FEATURE_QBIT
+#  define __ARM_FEATURE_SAT
+#  define __ARM_FEATURE_UNALIGNED
+#  ifndef __thumb__
+#   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
+#    define __ARM_FEATURE_LDREX 15
+#   else
+#    define __ARM_FEATURE_LDREX 4
+#   endif
+#  endif
+# endif
+
+# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
+#  define __ARM_ARCH 5
+#  define __ARM_ARCH_ISA_ARM
+#  ifdef __ARM_ARCH_5TE__
+#   define __ARM_ARCH_ISA_THUMB 1
+#  endif
+#  define __ARM_FEATURE_CLZ
+#  define __ARM_FEATURE_DSP
+# endif
+
+# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
+#  define __ARM_ARCH 5
+#  define __ARM_ARCH_ISA_ARM
+#  ifdef __ARM_ARCH_5TE__
+#   define __ARM_ARCH_ISA_THUMB 1
+#  endif
+#  define __ARM_FEATURE_CLZ
+# endif
+
+# ifdef __ARM_ARCH_4T__
+#  define __ARM_ARCH 4
+#  define __ARM_ARCH_ISA_ARM
+#  define __ARM_ARCH_ISA_THUMB 1
+# endif
+
+# ifdef __ARM_ARCH_4__
+#  define __ARM_ARCH 4
+#  define __ARM_ARCH_ISA_ARM
+# endif
+
+# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
+#  define __ARM_ARCH 3
+#  define __ARM_ARCH_ISA_ARM
+# endif
+
+# ifdef __ARM_ARCH_2__
+#  define __ARM_ARCH 2
+#  define __ARM_ARCH_ISA_ARM
+# endif
+
+# ifdef __ARMEB__
+#  define __ARM_BIG_ENDIAN
+# endif
+
+/* If we still don't know what the target architecture is, then we're
+   probably not using GCC.  */
+# ifndef __ARM_ARCH
+#  error Unable to determine architecture version.
+# endif
+
+#endif /* __ARM_ARCH  */
+
-- 
2.38.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-14  9:13 [PATCH] libgloss: arm: break newlib dependency Mike Frysinger
@ 2022-12-19  9:34 ` Corinna Vinschen
  2022-12-19 10:08 ` Richard Earnshaw
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2022-12-19  9:34 UTC (permalink / raw)
  To: newlib

On Dec 14 04:13, Mike Frysinger wrote:
> The libgloss port has been reaching back into newlib internals for a
> single header whose contents have been frozen for almost a decade.
> To break this backwards libgloss->newlib dependency, duplicate that
> header here so we can keep libgloss independent as it's meant to be.

LGTM,
Corinna


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-14  9:13 [PATCH] libgloss: arm: break newlib dependency Mike Frysinger
  2022-12-19  9:34 ` Corinna Vinschen
@ 2022-12-19 10:08 ` Richard Earnshaw
  2022-12-21  1:47   ` Mike Frysinger
  2023-01-04  2:04 ` Mike Frysinger
  2023-01-11  6:01 ` [PATCH v3] " Mike Frysinger
  3 siblings, 1 reply; 15+ messages in thread
From: Richard Earnshaw @ 2022-12-19 10:08 UTC (permalink / raw)
  To: Mike Frysinger, newlib

On 14/12/2022 09:13, Mike Frysinger wrote:
> The libgloss port has been reaching back into newlib internals for a
> single header whose contents have been frozen for almost a decade.
> To break this backwards libgloss->newlib dependency, duplicate that
> header here so we can keep libgloss independent as it's meant to be.

This isn't really 'newlib internals', it's a header file that tries to 
provide ACLE[1] compatibility for older versions of GCC that lacked such 
support.  Having two copies of this is a maintenance burden, so I'm not 
entirely sure this is a great thing to do, even if the copies are 
supposed to be identical.

If we can agree on a common location in the source tree that both newlib 
and libgloss can pull this from, then I'm happy to move it if that would 
make you happier.

R.

[1] https://arm-software.github.io/acle/main/

> ---
>   libgloss/arm/Makefile.in   |   2 -
>   libgloss/arm/acle-compat.h | 182 +++++++++++++++++++++++++++++++++++++
>   2 files changed, 182 insertions(+), 2 deletions(-)
>   create mode 100644 libgloss/arm/acle-compat.h
> 
> diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in
> index 06fae10c1fca..d0d5ea89d62e 100644
> --- a/libgloss/arm/Makefile.in
> +++ b/libgloss/arm/Makefile.in
> @@ -97,8 +97,6 @@ IQ80310_INSTALL	= install-iq80310
>   # Host specific makefile fragment comes in here.
>   @host_makefile_frag@
>   
> -INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi`
> -
>   #
>   # build a test program for each target board. Just trying to get
>   # it to link is a good test, so we ignore all the errors for now.
> diff --git a/libgloss/arm/acle-compat.h b/libgloss/arm/acle-compat.h
> new file mode 100644
> index 000000000000..888ae2ea8afb
> --- /dev/null
> +++ b/libgloss/arm/acle-compat.h
> @@ -0,0 +1,182 @@
> +/*
> + * Copyright (c) 2014 ARM Ltd
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. The name of the company may not be used to endorse or promote
> + *    products derived from this software without specific prior written
> + *    permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
> + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef __ARM_ARCH
> +
> +/* ACLE standardises a set of pre-defines that describe the ARM architecture.
> +   These were mostly implemented in GCC around GCC-4.8; older versions
> +   have no, or only partial support.  To provide a level of backwards
> +   compatibility we try to work out what the definitions should be, given
> +   the older pre-defines that GCC did produce.  This isn't complete, but
> +   it should be enough for use by routines that depend on this header.  */
> +
> +/* No need to handle ARMv8, GCC had ACLE support before that.  */
> +
> +# ifdef __ARM_ARCH_7__
> +/* The common subset of ARMv7 in all profiles.  */
> +#  define __ARM_ARCH 7
> +#  define __ARM_ARCH_ISA_THUMB 2
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_LDREX 7
> +#  define __ARM_FEATURE_UNALIGNED
> +# endif
> +
> +# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
> +#  define __ARM_ARCH 7
> +#  define __ARM_ARCH_ISA_THUMB 2
> +#  define __ARM_ARCH_ISA_ARM
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_SIMD32
> +#  define __ARM_FEATURE_DSP
> +#  define __ARM_FEATURE_QBIT
> +#  define __ARM_FEATURE_SAT
> +#  define __ARM_FEATURE_LDREX 15
> +#  define __ARM_FEATURE_UNALIGNED
> +#  ifdef __ARM_ARCH_7A__
> +#   define __ARM_ARCH_PROFILE 'A'
> +#  else
> +#   define __ARM_ARCH_PROFILE 'R'
> +#  endif
> +# endif
> +
> +# ifdef __ARM_ARCH_7EM__
> +#  define __ARM_ARCH 7
> +#  define __ARM_ARCH_ISA_THUMB 2
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_SIMD32
> +#  define __ARM_FEATURE_DSP
> +#  define __ARM_FEATURE_QBIT
> +#  define __ARM_FEATURE_SAT
> +#  define __ARM_FEATURE_LDREX 7
> +#  define __ARM_FEATURE_UNALIGNED
> +#  define __ARM_ARCH_PROFILE 'M'
> +# endif
> +
> +# ifdef __ARM_ARCH_7M__
> +#  define __ARM_ARCH 7
> +#  define __ARM_ARCH_ISA_THUMB 2
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_QBIT
> +#  define __ARM_FEATURE_SAT
> +#  define __ARM_FEATURE_LDREX 7
> +#  define __ARM_FEATURE_UNALIGNED
> +#  define __ARM_ARCH_PROFILE 'M'
> +# endif
> +
> +# ifdef __ARM_ARCH_6T2__
> +#  define __ARM_ARCH 6
> +#  define __ARM_ARCH_ISA_THUMB 2
> +#  define __ARM_ARCH_ISA_ARM
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_SIMD32
> +#  define __ARM_FEATURE_DSP
> +#  define __ARM_FEATURE_QBIT
> +#  define __ARM_FEATURE_SAT
> +#  define __ARM_FEATURE_LDREX 4
> +#  define __ARM_FEATURE_UNALIGNED
> +# endif
> +
> +# ifdef __ARM_ARCH_6M__
> +#  define __ARM_ARCH 6
> +#  define __ARM_ARCH_ISA_THUMB 1
> +#  define __ARM_ARCH_PROFILE 'M'
> +# endif
> +
> +# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
> +  || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
> +  || defined (__ARM_ARCH_6ZK__)
> +#  define __ARM_ARCH 6
> +#  define __ARM_ARCH_ISA_THUMB 1
> +#  define __ARM_ARCH_ISA_ARM
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_SIMD32
> +#  define __ARM_FEATURE_DSP
> +#  define __ARM_FEATURE_QBIT
> +#  define __ARM_FEATURE_SAT
> +#  define __ARM_FEATURE_UNALIGNED
> +#  ifndef __thumb__
> +#   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
> +#    define __ARM_FEATURE_LDREX 15
> +#   else
> +#    define __ARM_FEATURE_LDREX 4
> +#   endif
> +#  endif
> +# endif
> +
> +# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
> +#  define __ARM_ARCH 5
> +#  define __ARM_ARCH_ISA_ARM
> +#  ifdef __ARM_ARCH_5TE__
> +#   define __ARM_ARCH_ISA_THUMB 1
> +#  endif
> +#  define __ARM_FEATURE_CLZ
> +#  define __ARM_FEATURE_DSP
> +# endif
> +
> +# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
> +#  define __ARM_ARCH 5
> +#  define __ARM_ARCH_ISA_ARM
> +#  ifdef __ARM_ARCH_5TE__
> +#   define __ARM_ARCH_ISA_THUMB 1
> +#  endif
> +#  define __ARM_FEATURE_CLZ
> +# endif
> +
> +# ifdef __ARM_ARCH_4T__
> +#  define __ARM_ARCH 4
> +#  define __ARM_ARCH_ISA_ARM
> +#  define __ARM_ARCH_ISA_THUMB 1
> +# endif
> +
> +# ifdef __ARM_ARCH_4__
> +#  define __ARM_ARCH 4
> +#  define __ARM_ARCH_ISA_ARM
> +# endif
> +
> +# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
> +#  define __ARM_ARCH 3
> +#  define __ARM_ARCH_ISA_ARM
> +# endif
> +
> +# ifdef __ARM_ARCH_2__
> +#  define __ARM_ARCH 2
> +#  define __ARM_ARCH_ISA_ARM
> +# endif
> +
> +# ifdef __ARMEB__
> +#  define __ARM_BIG_ENDIAN
> +# endif
> +
> +/* If we still don't know what the target architecture is, then we're
> +   probably not using GCC.  */
> +# ifndef __ARM_ARCH
> +#  error Unable to determine architecture version.
> +# endif
> +
> +#endif /* __ARM_ARCH  */
> +


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-19 10:08 ` Richard Earnshaw
@ 2022-12-21  1:47   ` Mike Frysinger
  2022-12-21  8:24     ` Corinna Vinschen
  0 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2022-12-21  1:47 UTC (permalink / raw)
  To: Richard Earnshaw; +Cc: newlib

[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]

On 19 Dec 2022 10:08, Richard Earnshaw wrote:
> On 14/12/2022 09:13, Mike Frysinger wrote:
> > The libgloss port has been reaching back into newlib internals for a
> > single header whose contents have been frozen for almost a decade.
> > To break this backwards libgloss->newlib dependency, duplicate that
> > header here so we can keep libgloss independent as it's meant to be.
> 
> This isn't really 'newlib internals', it's a header file that tries to 
> provide ACLE[1] compatibility for older versions of GCC that lacked such 
> support.  Having two copies of this is a maintenance burden, so I'm not 
> entirely sure this is a great thing to do, even if the copies are 
> supposed to be identical.

newlib already has 2 itself.  so this will be a 3rd.  i don't disagree with
the maintenance concern, but the fact the file hasn't changed in a decade,
and seems unlikely to ever change, makes me not worry about it.

> If we can agree on a common location in the source tree that both newlib 
> and libgloss can pull this from, then I'm happy to move it if that would 
> make you happier.

libgloss is supposed to be C library agnostic.  the C library (newlib) itself
relies on the output of libgloss (e.g. the crt and low level syscalls).  since
there is no other tree/project in play that i'm aware of, that means there are
really only three options:
* have the compiler provide it
* have libgloss provide it (and newlib uses that)
* duplicate the header

i know the libgloss/newlib separation is still pretty unclean due to the two
projects historically being one (i.e. everything in newlib), but i don't think
that's a good reason to keep it messy with libgloss depending on newlib.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-21  1:47   ` Mike Frysinger
@ 2022-12-21  8:24     ` Corinna Vinschen
  2022-12-22 22:03       ` Mike Frysinger
  0 siblings, 1 reply; 15+ messages in thread
From: Corinna Vinschen @ 2022-12-21  8:24 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Richard Earnshaw, newlib

On Dec 20 20:47, Mike Frysinger wrote:
> On 19 Dec 2022 10:08, Richard Earnshaw wrote:
> > On 14/12/2022 09:13, Mike Frysinger wrote:
> > > The libgloss port has been reaching back into newlib internals for a
> > > single header whose contents have been frozen for almost a decade.
> > > To break this backwards libgloss->newlib dependency, duplicate that
> > > header here so we can keep libgloss independent as it's meant to be.
> > 
> > This isn't really 'newlib internals', it's a header file that tries to 
> > provide ACLE[1] compatibility for older versions of GCC that lacked such 
> > support.  Having two copies of this is a maintenance burden, so I'm not 
> > entirely sure this is a great thing to do, even if the copies are 
> > supposed to be identical.
> 
> newlib already has 2 itself.  so this will be a 3rd.  i don't disagree with
> the maintenance concern, but the fact the file hasn't changed in a decade,
> and seems unlikely to ever change, makes me not worry about it.
> 
> > If we can agree on a common location in the source tree that both newlib 
> > and libgloss can pull this from, then I'm happy to move it if that would 
> > make you happier.
> 
> libgloss is supposed to be C library agnostic.  the C library (newlib) itself
> relies on the output of libgloss (e.g. the crt and low level syscalls).  since
> there is no other tree/project in play that i'm aware of, that means there are
> really only three options:
> * have the compiler provide it
> * have libgloss provide it (and newlib uses that)
> * duplicate the header
> 
> i know the libgloss/newlib separation is still pretty unclean due to the two
> projects historically being one (i.e. everything in newlib), but i don't think
> that's a good reason to keep it messy with libgloss depending on newlib.
> -mike

Why not just <toplevel>/include then?  It already contains target-specific
stuff in the opcodes subdir, or the xtensa headers.  Having to share them
between newlib and libgloss should be reason enough to move the file there.


Corinna


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-21  8:24     ` Corinna Vinschen
@ 2022-12-22 22:03       ` Mike Frysinger
  2023-01-03 14:56         ` Richard Earnshaw
  0 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2022-12-22 22:03 UTC (permalink / raw)
  To: Richard Earnshaw, newlib

[-- Attachment #1: Type: text/plain, Size: 2405 bytes --]

On 21 Dec 2022 09:24, Corinna Vinschen wrote:
> On Dec 20 20:47, Mike Frysinger wrote:
> > On 19 Dec 2022 10:08, Richard Earnshaw wrote:
> > > On 14/12/2022 09:13, Mike Frysinger wrote:
> > > > The libgloss port has been reaching back into newlib internals for a
> > > > single header whose contents have been frozen for almost a decade.
> > > > To break this backwards libgloss->newlib dependency, duplicate that
> > > > header here so we can keep libgloss independent as it's meant to be.
> > > 
> > > This isn't really 'newlib internals', it's a header file that tries to 
> > > provide ACLE[1] compatibility for older versions of GCC that lacked such 
> > > support.  Having two copies of this is a maintenance burden, so I'm not 
> > > entirely sure this is a great thing to do, even if the copies are 
> > > supposed to be identical.
> > 
> > newlib already has 2 itself.  so this will be a 3rd.  i don't disagree with
> > the maintenance concern, but the fact the file hasn't changed in a decade,
> > and seems unlikely to ever change, makes me not worry about it.
> > 
> > > If we can agree on a common location in the source tree that both newlib 
> > > and libgloss can pull this from, then I'm happy to move it if that would 
> > > make you happier.
> > 
> > libgloss is supposed to be C library agnostic.  the C library (newlib) itself
> > relies on the output of libgloss (e.g. the crt and low level syscalls).  since
> > there is no other tree/project in play that i'm aware of, that means there are
> > really only three options:
> > * have the compiler provide it
> > * have libgloss provide it (and newlib uses that)
> > * duplicate the header
> > 
> > i know the libgloss/newlib separation is still pretty unclean due to the two
> > projects historically being one (i.e. everything in newlib), but i don't think
> > that's a good reason to keep it messy with libgloss depending on newlib.
> 
> Why not just <toplevel>/include then?  It already contains target-specific
> stuff in the opcodes subdir, or the xtensa headers.  Having to share them
> between newlib and libgloss should be reason enough to move the file there.

the file is currently installed under machine/.  none of the installed headers
use it though, so maybe it doesn't really need to be installed.  if that's the
case, moving it into the top-level include/ would work.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2022-12-22 22:03       ` Mike Frysinger
@ 2023-01-03 14:56         ` Richard Earnshaw
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Earnshaw @ 2023-01-03 14:56 UTC (permalink / raw)
  To: Mike Frysinger, newlib



On 22/12/2022 22:03, Mike Frysinger wrote:
> On 21 Dec 2022 09:24, Corinna Vinschen wrote:
>> On Dec 20 20:47, Mike Frysinger wrote:
>>> On 19 Dec 2022 10:08, Richard Earnshaw wrote:
>>>> On 14/12/2022 09:13, Mike Frysinger wrote:
>>>>> The libgloss port has been reaching back into newlib internals for a
>>>>> single header whose contents have been frozen for almost a decade.
>>>>> To break this backwards libgloss->newlib dependency, duplicate that
>>>>> header here so we can keep libgloss independent as it's meant to be.
>>>>
>>>> This isn't really 'newlib internals', it's a header file that tries to
>>>> provide ACLE[1] compatibility for older versions of GCC that lacked such
>>>> support.  Having two copies of this is a maintenance burden, so I'm not
>>>> entirely sure this is a great thing to do, even if the copies are
>>>> supposed to be identical.
>>>
>>> newlib already has 2 itself.  so this will be a 3rd.  i don't disagree with
>>> the maintenance concern, but the fact the file hasn't changed in a decade,
>>> and seems unlikely to ever change, makes me not worry about it.
>>>
>>>> If we can agree on a common location in the source tree that both newlib
>>>> and libgloss can pull this from, then I'm happy to move it if that would
>>>> make you happier.
>>>
>>> libgloss is supposed to be C library agnostic.  the C library (newlib) itself
>>> relies on the output of libgloss (e.g. the crt and low level syscalls).  since
>>> there is no other tree/project in play that i'm aware of, that means there are
>>> really only three options:
>>> * have the compiler provide it
>>> * have libgloss provide it (and newlib uses that)
>>> * duplicate the header
>>>
>>> i know the libgloss/newlib separation is still pretty unclean due to the two
>>> projects historically being one (i.e. everything in newlib), but i don't think
>>> that's a good reason to keep it messy with libgloss depending on newlib.
>>
>> Why not just <toplevel>/include then?  It already contains target-specific
>> stuff in the opcodes subdir, or the xtensa headers.  Having to share them
>> between newlib and libgloss should be reason enough to move the file there.
> 
> the file is currently installed under machine/.  none of the installed headers
> use it though, so maybe it doesn't really need to be installed.  if that's the
> case, moving it into the top-level include/ would work.
> -mike

The file should not be installed, it's only for the build system.  If it 
is being installed, then that's a bug.

Moving it to <toplevel>/include is ok by me.   We'll need to sync it to 
the binutils repo (to support all-in-one build trees), but that's not a 
real issue as the file doesn't change often as you've already noted.

R.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] libgloss: arm: break newlib dependency
  2022-12-14  9:13 [PATCH] libgloss: arm: break newlib dependency Mike Frysinger
  2022-12-19  9:34 ` Corinna Vinschen
  2022-12-19 10:08 ` Richard Earnshaw
@ 2023-01-04  2:04 ` Mike Frysinger
  2023-01-04  2:17   ` Stefan Tauner
  2023-01-11  6:01 ` [PATCH v3] " Mike Frysinger
  3 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2023-01-04  2:04 UTC (permalink / raw)
  To: newlib; +Cc: Richard.Earnshaw

The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, move the acle
header to the srcroot include/ so everyone can use the same copy.
---
 .../arm-acle-compat.h                         |   0
 libgloss/arm/Makefile.in                      |   2 -
 libgloss/arm/arm.h                            |   2 +-
 libgloss/config/default.mh                    |   2 +-
 newlib/Makefile.am                            |   3 +-
 newlib/Makefile.in                            |   4 +-
 newlib/libc/machine/arm/aeabi_memcpy-armv7a.S |   2 +-
 newlib/libc/machine/arm/aeabi_memmove-thumb.S |   2 +-
 newlib/libc/machine/arm/aeabi_memset-thumb.S  |   2 +-
 newlib/libc/machine/arm/arm_asm.h             |   2 +-
 newlib/libc/machine/arm/machine/acle-compat.h | 182 ------------------
 newlib/libc/machine/arm/memchr-stub.c         |   2 +-
 newlib/libc/machine/arm/memchr.S              |   2 +-
 newlib/libc/machine/arm/memcpy-stub.c         |   2 +-
 newlib/libc/machine/arm/memcpy.S              |   2 +-
 newlib/libc/machine/arm/setjmp.S              |   2 +-
 newlib/libc/machine/arm/strcmp.S              |   2 +-
 newlib/libc/machine/arm/strlen-armv7.S        |   2 +-
 newlib/libc/machine/arm/strlen-thumb2-Os.S    |   2 +-
 newlib/libc/machine/arm/strlen.S              |   2 +-
 newlib/libc/sys/arm/arm.h                     |   2 +-
 21 files changed, 20 insertions(+), 203 deletions(-)
 rename newlib/libc/machine/arm/acle-compat.h => include/arm-acle-compat.h (100%)
 delete mode 100644 newlib/libc/machine/arm/machine/acle-compat.h

diff --git a/newlib/libc/machine/arm/acle-compat.h b/include/arm-acle-compat.h
similarity index 100%
rename from newlib/libc/machine/arm/acle-compat.h
rename to include/arm-acle-compat.h
diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in
index 06fae10c1fca..d0d5ea89d62e 100644
--- a/libgloss/arm/Makefile.in
+++ b/libgloss/arm/Makefile.in
@@ -97,8 +97,6 @@ IQ80310_INSTALL	= install-iq80310
 # Host specific makefile fragment comes in here.
 @host_makefile_frag@
 
-INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi`
-
 #
 # build a test program for each target board. Just trying to get
 # it to link is a good test, so we ignore all the errors for now.
diff --git a/libgloss/arm/arm.h b/libgloss/arm/arm.h
index 10e5b0509cf8..77fa1bd1f0e0 100644
--- a/libgloss/arm/arm.h
+++ b/libgloss/arm/arm.h
@@ -29,7 +29,7 @@
 #ifndef _LIBGLOSS_ARM_H
 #define _LIBGLOSS_ARM_H
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
    supporting Thumb-2 instructions, whether ARM instructions are available or
diff --git a/libgloss/config/default.mh b/libgloss/config/default.mh
index 4e7f106f9366..d9a9867a1713 100644
--- a/libgloss/config/default.mh
+++ b/libgloss/config/default.mh
@@ -1,7 +1,7 @@
 NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
 NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
 
-INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/..
+INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/.. -I$(srcroot)
 # Note that when building the library, ${MULTILIB} is not the way multilib
 # options are passed; they're passed in $(CFLAGS).
 CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 0108d8576b88..3bf054c2b847 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -63,13 +63,14 @@ AM_MAKEFLAGS = \
 
 FLAGS_TO_PASS=$(AM_MAKEFLAGS)
 
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 
 # These are useful for standalone object files like crt0.o.
 AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
-AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
+AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -I$(srcroot)
 
 toollib_LIBRARIES = libm.a \
 	libc.a
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 2d8bfadedb7c..60a50f511b49 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -3677,7 +3677,6 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
-runstatedir = @runstatedir@
 sbindir = @sbindir@
 shared_machine_dir = @shared_machine_dir@
 sharedstatedir = @sharedstatedir@
@@ -3751,13 +3750,14 @@ AM_MAKEFLAGS = \
 	"DESTDIR=$(DESTDIR)"
 
 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 
 # These are useful for standalone object files like crt0.o.
 AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
-AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
+AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -I$(srcroot)
 toollib_LIBRARIES = libm.a libc.a $(am__append_72)
 @HAVE_MULTISUBDIR_TRUE@BUILD_MULTISUBDIR = $(builddir)$(MULTISUBDIR)
 toollib_DATA = $(CRT0) $(CRT1)
diff --git a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
index 95f2dcd00207..2adc999efa00 100644
--- a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
+++ b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 /* NOTE: This ifdef MUST match the one in aeabi_memcpy.c.  */
 #if defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED) && \
diff --git a/newlib/libc/machine/arm/aeabi_memmove-thumb.S b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
index fadeb9a3b735..6955a69b4f55 100644
--- a/newlib/libc/machine/arm/aeabi_memmove-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 	.thumb
 	.syntax unified
diff --git a/newlib/libc/machine/arm/aeabi_memset-thumb.S b/newlib/libc/machine/arm/aeabi_memset-thumb.S
index ed6ce88605a3..dcba9d7b485f 100644
--- a/newlib/libc/machine/arm/aeabi_memset-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memset-thumb.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 	.thumb
 	.syntax unified
diff --git a/newlib/libc/machine/arm/arm_asm.h b/newlib/libc/machine/arm/arm_asm.h
index 2708057deb3a..88b5f2aacd3e 100644
--- a/newlib/libc/machine/arm/arm_asm.h
+++ b/newlib/libc/machine/arm/arm_asm.h
@@ -29,7 +29,7 @@
 #ifndef ARM_ASM__H
 #define ARM_ASM__H
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #if __ARM_ARCH >= 7 && defined (__ARM_ARCH_ISA_ARM)
 # define _ISA_ARM_7
diff --git a/newlib/libc/machine/arm/machine/acle-compat.h b/newlib/libc/machine/arm/machine/acle-compat.h
deleted file mode 100644
index 888ae2ea8afb..000000000000
--- a/newlib/libc/machine/arm/machine/acle-compat.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2014 ARM Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __ARM_ARCH
-
-/* ACLE standardises a set of pre-defines that describe the ARM architecture.
-   These were mostly implemented in GCC around GCC-4.8; older versions
-   have no, or only partial support.  To provide a level of backwards
-   compatibility we try to work out what the definitions should be, given
-   the older pre-defines that GCC did produce.  This isn't complete, but
-   it should be enough for use by routines that depend on this header.  */
-
-/* No need to handle ARMv8, GCC had ACLE support before that.  */
-
-# ifdef __ARM_ARCH_7__
-/* The common subset of ARMv7 in all profiles.  */
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-# endif
-
-# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 15
-#  define __ARM_FEATURE_UNALIGNED
-#  ifdef __ARM_ARCH_7A__
-#   define __ARM_ARCH_PROFILE 'A'
-#  else
-#   define __ARM_ARCH_PROFILE 'R'
-#  endif
-# endif
-
-# ifdef __ARM_ARCH_7EM__
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# ifdef __ARM_ARCH_7M__
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# ifdef __ARM_ARCH_6T2__
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 4
-#  define __ARM_FEATURE_UNALIGNED
-# endif
-
-# ifdef __ARM_ARCH_6M__
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 1
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
-  || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
-  || defined (__ARM_ARCH_6ZK__)
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 1
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_UNALIGNED
-#  ifndef __thumb__
-#   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
-#    define __ARM_FEATURE_LDREX 15
-#   else
-#    define __ARM_FEATURE_LDREX 4
-#   endif
-#  endif
-# endif
-
-# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
-#  define __ARM_ARCH 5
-#  define __ARM_ARCH_ISA_ARM
-#  ifdef __ARM_ARCH_5TE__
-#   define __ARM_ARCH_ISA_THUMB 1
-#  endif
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_DSP
-# endif
-
-# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
-#  define __ARM_ARCH 5
-#  define __ARM_ARCH_ISA_ARM
-#  ifdef __ARM_ARCH_5TE__
-#   define __ARM_ARCH_ISA_THUMB 1
-#  endif
-#  define __ARM_FEATURE_CLZ
-# endif
-
-# ifdef __ARM_ARCH_4T__
-#  define __ARM_ARCH 4
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_ARCH_ISA_THUMB 1
-# endif
-
-# ifdef __ARM_ARCH_4__
-#  define __ARM_ARCH 4
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
-#  define __ARM_ARCH 3
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# ifdef __ARM_ARCH_2__
-#  define __ARM_ARCH 2
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# ifdef __ARMEB__
-#  define __ARM_BIG_ENDIAN
-# endif
-
-/* If we still don't know what the target architecture is, then we're
-   probably not using GCC.  */
-# ifndef __ARM_ARCH
-#  error Unable to determine architecture version.
-# endif
-
-#endif /* __ARM_ARCH  */
-
diff --git a/newlib/libc/machine/arm/memchr-stub.c b/newlib/libc/machine/arm/memchr-stub.c
index 5c7881b9c82d..fd1fc3c280b4 100644
--- a/newlib/libc/machine/arm/memchr-stub.c
+++ b/newlib/libc/machine/arm/memchr-stub.c
@@ -27,7 +27,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memchr.S.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #if defined (__ARM_NEON__) || defined (__ARM_NEON)
 /* Defined in memchr.S.  */
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index 1a4c6512c857..95bcaf306d05 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -75,7 +75,7 @@
 
 	.syntax unified
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 @ NOTE: This ifdef MUST match the one in memchr-stub.c
 #if defined (__ARM_NEON__) || defined (__ARM_NEON)
diff --git a/newlib/libc/machine/arm/memcpy-stub.c b/newlib/libc/machine/arm/memcpy-stub.c
index 6cd0e3b1d4d5..51bb05c54516 100644
--- a/newlib/libc/machine/arm/memcpy-stub.c
+++ b/newlib/libc/machine/arm/memcpy-stub.c
@@ -27,7 +27,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memcpy.S.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
 # include "../../string/memcpy.c"
diff --git a/newlib/libc/machine/arm/memcpy.S b/newlib/libc/machine/arm/memcpy.S
index 77bd2a606e4b..5f2eea3b5656 100644
--- a/newlib/libc/machine/arm/memcpy.S
+++ b/newlib/libc/machine/arm/memcpy.S
@@ -29,7 +29,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memcpy-stub.c.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
   /* Defined in memcpy-stub.c.  */
diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
index d814afea8cd1..8908d68ef3f5 100644
--- a/newlib/libc/machine/arm/setjmp.S
+++ b/newlib/libc/machine/arm/setjmp.S
@@ -2,7 +2,7 @@
 
    Nick Clifton, Cygnus Solutions, 13 June 1997.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 /* ANSI concatenation macros.  */
 #define CONCAT(a, b)  CONCAT2(a, b)
diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S
index 137f44969257..2626806adad8 100644
--- a/newlib/libc/machine/arm/strcmp.S
+++ b/newlib/libc/machine/arm/strcmp.S
@@ -28,7 +28,7 @@
 
 /* Wrapper for the various implementations of strcmp.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #ifdef __ARM_BIG_ENDIAN
 #define S2LO lsl
diff --git a/newlib/libc/machine/arm/strlen-armv7.S b/newlib/libc/machine/arm/strlen-armv7.S
index f3dda0d60e89..0c90c16687fd 100644
--- a/newlib/libc/machine/arm/strlen-armv7.S
+++ b/newlib/libc/machine/arm/strlen-armv7.S
@@ -58,7 +58,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 	.macro def_fn f p2align=0
 	.text
diff --git a/newlib/libc/machine/arm/strlen-thumb2-Os.S b/newlib/libc/machine/arm/strlen-thumb2-Os.S
index 961f41a0a227..382bead0a470 100644
--- a/newlib/libc/machine/arm/strlen-thumb2-Os.S
+++ b/newlib/libc/machine/arm/strlen-thumb2-Os.S
@@ -24,7 +24,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 	.macro def_fn f p2align=0
 	.text
diff --git a/newlib/libc/machine/arm/strlen.S b/newlib/libc/machine/arm/strlen.S
index 0435fb2de848..29468e2301f9 100644
--- a/newlib/libc/machine/arm/strlen.S
+++ b/newlib/libc/machine/arm/strlen.S
@@ -24,7 +24,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 #if defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED
 #if __ARM_ARCH_ISA_THUMB == 2
diff --git a/newlib/libc/sys/arm/arm.h b/newlib/libc/sys/arm/arm.h
index 10e5b0509cf8..77fa1bd1f0e0 100644
--- a/newlib/libc/sys/arm/arm.h
+++ b/newlib/libc/sys/arm/arm.h
@@ -29,7 +29,7 @@
 #ifndef _LIBGLOSS_ARM_H
 #define _LIBGLOSS_ARM_H
 
-#include "acle-compat.h"
+#include "include/arm-acle-compat.h"
 
 /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
    supporting Thumb-2 instructions, whether ARM instructions are available or
-- 
2.39.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2023-01-04  2:04 ` Mike Frysinger
@ 2023-01-04  2:17   ` Stefan Tauner
  2023-01-04  3:06     ` Mike Frysinger
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Tauner @ 2023-01-04  2:17 UTC (permalink / raw)
  To: newlib

Hi,

wouldn't it make sense to add the "include" directory itself to the
build process(es) as include directory instead of prepending it to all
#include statements?

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2023-01-04  2:17   ` Stefan Tauner
@ 2023-01-04  3:06     ` Mike Frysinger
  2023-01-09 10:29       ` Corinna Vinschen
  0 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2023-01-04  3:06 UTC (permalink / raw)
  To: Stefan Tauner; +Cc: newlib

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On 04 Jan 2023 03:17, Stefan Tauner wrote:
> wouldn't it make sense to add the "include" directory itself to the
> build process(es) as include directory instead of prepending it to all
> #include statements?

the include/ dir has headers that conflict with standard headers like
getopt.h.  this causes build failures.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2023-01-04  3:06     ` Mike Frysinger
@ 2023-01-09 10:29       ` Corinna Vinschen
  2023-01-10  2:07         ` Mike Frysinger
  0 siblings, 1 reply; 15+ messages in thread
From: Corinna Vinschen @ 2023-01-09 10:29 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Stefan Tauner, newlib

On Jan  3 22:06, Mike Frysinger wrote:
> On 04 Jan 2023 03:17, Stefan Tauner wrote:
> > wouldn't it make sense to add the "include" directory itself to the
> > build process(es) as include directory instead of prepending it to all
> > #include statements?
> 
> the include/ dir has headers that conflict with standard headers like
> getopt.h.  this causes build failures.
> -mike

What about using -idirafter instead?


Corinna


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2023-01-09 10:29       ` Corinna Vinschen
@ 2023-01-10  2:07         ` Mike Frysinger
  2023-01-10  8:43           ` Corinna Vinschen
  0 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2023-01-10  2:07 UTC (permalink / raw)
  To: Stefan Tauner, newlib

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

On 09 Jan 2023 11:29, Corinna Vinschen wrote:
> On Jan  3 22:06, Mike Frysinger wrote:
> > On 04 Jan 2023 03:17, Stefan Tauner wrote:
> > > wouldn't it make sense to add the "include" directory itself to the
> > > build process(es) as include directory instead of prepending it to all
> > > #include statements?
> > 
> > the include/ dir has headers that conflict with standard headers like
> > getopt.h.  this causes build failures.
> 
> What about using -idirafter instead?

that should work.  newlib isn't using it today, so i didn't think we
wanted to start.  if you're fine with it, i can try it.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] libgloss: arm: break newlib dependency
  2023-01-10  2:07         ` Mike Frysinger
@ 2023-01-10  8:43           ` Corinna Vinschen
  0 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2023-01-10  8:43 UTC (permalink / raw)
  To: newlib

On Jan  9 21:07, Mike Frysinger wrote:
> On 09 Jan 2023 11:29, Corinna Vinschen wrote:
> > On Jan  3 22:06, Mike Frysinger wrote:
> > > On 04 Jan 2023 03:17, Stefan Tauner wrote:
> > > > wouldn't it make sense to add the "include" directory itself to the
> > > > build process(es) as include directory instead of prepending it to all
> > > > #include statements?
> > > 
> > > the include/ dir has headers that conflict with standard headers like
> > > getopt.h.  this causes build failures.
> > 
> > What about using -idirafter instead?
> 
> that should work.  newlib isn't using it today, so i didn't think we
> wanted to start.  if you're fine with it, i can try it.
> -mike

No problems.  It exists for just such an opportunity and we're already
using it in the winsup/utils branch.


Corinna


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3] libgloss: arm: break newlib dependency
  2022-12-14  9:13 [PATCH] libgloss: arm: break newlib dependency Mike Frysinger
                   ` (2 preceding siblings ...)
  2023-01-04  2:04 ` Mike Frysinger
@ 2023-01-11  6:01 ` Mike Frysinger
  2023-01-11  9:14   ` Corinna Vinschen
  3 siblings, 1 reply; 15+ messages in thread
From: Mike Frysinger @ 2023-01-11  6:01 UTC (permalink / raw)
  To: newlib

The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, move the acle
header to the srcroot include/ so everyone can use the same copy.
---
v3
- use -idirafter with srcroot

 .../arm-acle-compat.h                         |   0
 libgloss/Makefile.am                          |   3 +
 libgloss/Makefile.in                          |   2 +
 libgloss/arm/Makefile.in                      |   2 -
 libgloss/arm/arm.h                            |   2 +-
 libgloss/config/default.mh                    |   2 +-
 newlib/Makefile.am                            |   3 +-
 newlib/Makefile.in                            |   4 +-
 newlib/libc/machine/arm/aeabi_memcpy-armv7a.S |   2 +-
 newlib/libc/machine/arm/aeabi_memmove-thumb.S |   2 +-
 newlib/libc/machine/arm/aeabi_memset-thumb.S  |   2 +-
 newlib/libc/machine/arm/arm_asm.h             |   2 +-
 newlib/libc/machine/arm/machine/acle-compat.h | 182 ------------------
 newlib/libc/machine/arm/memchr-stub.c         |   2 +-
 newlib/libc/machine/arm/memchr.S              |   2 +-
 newlib/libc/machine/arm/memcpy-stub.c         |   2 +-
 newlib/libc/machine/arm/memcpy.S              |   2 +-
 newlib/libc/machine/arm/setjmp.S              |   2 +-
 newlib/libc/machine/arm/strcmp.S              |   2 +-
 newlib/libc/machine/arm/strlen-armv7.S        |   2 +-
 newlib/libc/machine/arm/strlen-thumb2-Os.S    |   2 +-
 newlib/libc/machine/arm/strlen.S              |   2 +-
 newlib/libc/sys/arm/arm.h                     |   2 +-
 23 files changed, 25 insertions(+), 203 deletions(-)
 rename newlib/libc/machine/arm/acle-compat.h => include/arm-acle-compat.h (100%)
 delete mode 100644 newlib/libc/machine/arm/machine/acle-compat.h

diff --git a/newlib/libc/machine/arm/acle-compat.h b/include/arm-acle-compat.h
similarity index 100%
rename from newlib/libc/machine/arm/acle-compat.h
rename to include/arm-acle-compat.h
diff --git a/libgloss/Makefile.am b/libgloss/Makefile.am
index 5b5f0fd541ae..18b32fad2b7a 100644
--- a/libgloss/Makefile.am
+++ b/libgloss/Makefile.am
@@ -11,6 +11,7 @@ PHONY =
 
 SUBDIRS = @subdirs@ .
 
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(target_alias)
 
 multilibtooldir = $(tooldir)/lib$(MULTISUBDIR)
@@ -23,6 +24,8 @@ includetool_DATA =
 includesystooldir = $(tooldir)/include/sys
 includesystool_DATA =
 
+AM_CPPFLAGS = -idirafter $(srcroot)/include
+
 # A fake library so automake will generate rules for plain objects that we want
 # to install (e.g. our crt0.o objects).
 noinst_LIBRARIES = libobjs.a
diff --git a/libgloss/Makefile.in b/libgloss/Makefile.in
index cd60857d1fe1..77bb9b027bbd 100644
--- a/libgloss/Makefile.in
+++ b/libgloss/Makefile.in
@@ -657,6 +657,7 @@ info_TEXINFOS = $(am__append_1)
 CLEANFILES = $(am__append_4)
 PHONY = 
 SUBDIRS = @subdirs@ .
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(target_alias)
 multilibtooldir = $(tooldir)/lib$(MULTISUBDIR)
 multilibtool_DATA = $(am__append_3) $(am__append_7) $(am__append_9) \
@@ -669,6 +670,7 @@ includetooldir = $(tooldir)/include
 includetool_DATA = $(am__append_10)
 includesystooldir = $(tooldir)/include/sys
 includesystool_DATA = $(am__append_11)
+AM_CPPFLAGS = -idirafter $(srcroot)/include
 
 # A fake library so automake will generate rules for plain objects that we want
 # to install (e.g. our crt0.o objects).
diff --git a/libgloss/arm/Makefile.in b/libgloss/arm/Makefile.in
index 06fae10c1fca..d0d5ea89d62e 100644
--- a/libgloss/arm/Makefile.in
+++ b/libgloss/arm/Makefile.in
@@ -97,8 +97,6 @@ IQ80310_INSTALL	= install-iq80310
 # Host specific makefile fragment comes in here.
 @host_makefile_frag@
 
-INCLUDES += `if [ -d ${objroot}/newlib ]; then echo -I$(srcroot)/newlib/libc/machine/arm; fi`
-
 #
 # build a test program for each target board. Just trying to get
 # it to link is a good test, so we ignore all the errors for now.
diff --git a/libgloss/arm/arm.h b/libgloss/arm/arm.h
index 10e5b0509cf8..f3cd49308f77 100644
--- a/libgloss/arm/arm.h
+++ b/libgloss/arm/arm.h
@@ -29,7 +29,7 @@
 #ifndef _LIBGLOSS_ARM_H
 #define _LIBGLOSS_ARM_H
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
    supporting Thumb-2 instructions, whether ARM instructions are available or
diff --git a/libgloss/config/default.mh b/libgloss/config/default.mh
index 4e7f106f9366..81f0920f97a8 100644
--- a/libgloss/config/default.mh
+++ b/libgloss/config/default.mh
@@ -1,7 +1,7 @@
 NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
 NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
 
-INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/..
+INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/.. -idirafter $(srcroot)/include
 # Note that when building the library, ${MULTILIB} is not the way multilib
 # options are passed; they're passed in $(CFLAGS).
 CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 0108d8576b88..3bebf27ebd3b 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -63,13 +63,14 @@ AM_MAKEFLAGS = \
 
 FLAGS_TO_PASS=$(AM_MAKEFLAGS)
 
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 
 # These are useful for standalone object files like crt0.o.
 AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
-AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
+AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -idirafter $(srcroot)/include
 
 toollib_LIBRARIES = libm.a \
 	libc.a
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 2d8bfadedb7c..dea52b0f7e2c 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -3677,7 +3677,6 @@ pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
-runstatedir = @runstatedir@
 sbindir = @sbindir@
 shared_machine_dir = @shared_machine_dir@
 sharedstatedir = @sharedstatedir@
@@ -3751,13 +3750,14 @@ AM_MAKEFLAGS = \
 	"DESTDIR=$(DESTDIR)"
 
 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+srcroot = $(top_srcdir)/..
 tooldir = $(exec_prefix)/$(host_alias)
 toollibdir = $(tooldir)/lib$(MULTISUBDIR)
 
 # These are useful for standalone object files like crt0.o.
 AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
-AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
+AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -idirafter $(srcroot)/include
 toollib_LIBRARIES = libm.a libc.a $(am__append_72)
 @HAVE_MULTISUBDIR_TRUE@BUILD_MULTISUBDIR = $(builddir)$(MULTISUBDIR)
 toollib_DATA = $(CRT0) $(CRT1)
diff --git a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
index 95f2dcd00207..d2c8f389cd77 100644
--- a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
+++ b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 /* NOTE: This ifdef MUST match the one in aeabi_memcpy.c.  */
 #if defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED) && \
diff --git a/newlib/libc/machine/arm/aeabi_memmove-thumb.S b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
index fadeb9a3b735..4881d34cbca0 100644
--- a/newlib/libc/machine/arm/aeabi_memmove-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memmove-thumb.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 	.thumb
 	.syntax unified
diff --git a/newlib/libc/machine/arm/aeabi_memset-thumb.S b/newlib/libc/machine/arm/aeabi_memset-thumb.S
index ed6ce88605a3..087c188c0b93 100644
--- a/newlib/libc/machine/arm/aeabi_memset-thumb.S
+++ b/newlib/libc/machine/arm/aeabi_memset-thumb.S
@@ -26,7 +26,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 	.thumb
 	.syntax unified
diff --git a/newlib/libc/machine/arm/arm_asm.h b/newlib/libc/machine/arm/arm_asm.h
index 94fa77b4dad7..d75bb8e5b346 100644
--- a/newlib/libc/machine/arm/arm_asm.h
+++ b/newlib/libc/machine/arm/arm_asm.h
@@ -29,7 +29,7 @@
 #ifndef ARM_ASM__H
 #define ARM_ASM__H
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #if __ARM_ARCH >= 7 && defined (__ARM_ARCH_ISA_ARM)
 # define _ISA_ARM_7
diff --git a/newlib/libc/machine/arm/machine/acle-compat.h b/newlib/libc/machine/arm/machine/acle-compat.h
deleted file mode 100644
index 888ae2ea8afb..000000000000
--- a/newlib/libc/machine/arm/machine/acle-compat.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2014 ARM Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __ARM_ARCH
-
-/* ACLE standardises a set of pre-defines that describe the ARM architecture.
-   These were mostly implemented in GCC around GCC-4.8; older versions
-   have no, or only partial support.  To provide a level of backwards
-   compatibility we try to work out what the definitions should be, given
-   the older pre-defines that GCC did produce.  This isn't complete, but
-   it should be enough for use by routines that depend on this header.  */
-
-/* No need to handle ARMv8, GCC had ACLE support before that.  */
-
-# ifdef __ARM_ARCH_7__
-/* The common subset of ARMv7 in all profiles.  */
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-# endif
-
-# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 15
-#  define __ARM_FEATURE_UNALIGNED
-#  ifdef __ARM_ARCH_7A__
-#   define __ARM_ARCH_PROFILE 'A'
-#  else
-#   define __ARM_ARCH_PROFILE 'R'
-#  endif
-# endif
-
-# ifdef __ARM_ARCH_7EM__
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# ifdef __ARM_ARCH_7M__
-#  define __ARM_ARCH 7
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 7
-#  define __ARM_FEATURE_UNALIGNED
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# ifdef __ARM_ARCH_6T2__
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 2
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_LDREX 4
-#  define __ARM_FEATURE_UNALIGNED
-# endif
-
-# ifdef __ARM_ARCH_6M__
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 1
-#  define __ARM_ARCH_PROFILE 'M'
-# endif
-
-# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \
-  || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \
-  || defined (__ARM_ARCH_6ZK__)
-#  define __ARM_ARCH 6
-#  define __ARM_ARCH_ISA_THUMB 1
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_SIMD32
-#  define __ARM_FEATURE_DSP
-#  define __ARM_FEATURE_QBIT
-#  define __ARM_FEATURE_SAT
-#  define __ARM_FEATURE_UNALIGNED
-#  ifndef __thumb__
-#   if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
-#    define __ARM_FEATURE_LDREX 15
-#   else
-#    define __ARM_FEATURE_LDREX 4
-#   endif
-#  endif
-# endif
-
-# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)
-#  define __ARM_ARCH 5
-#  define __ARM_ARCH_ISA_ARM
-#  ifdef __ARM_ARCH_5TE__
-#   define __ARM_ARCH_ISA_THUMB 1
-#  endif
-#  define __ARM_FEATURE_CLZ
-#  define __ARM_FEATURE_DSP
-# endif
-
-# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)
-#  define __ARM_ARCH 5
-#  define __ARM_ARCH_ISA_ARM
-#  ifdef __ARM_ARCH_5TE__
-#   define __ARM_ARCH_ISA_THUMB 1
-#  endif
-#  define __ARM_FEATURE_CLZ
-# endif
-
-# ifdef __ARM_ARCH_4T__
-#  define __ARM_ARCH 4
-#  define __ARM_ARCH_ISA_ARM
-#  define __ARM_ARCH_ISA_THUMB 1
-# endif
-
-# ifdef __ARM_ARCH_4__
-#  define __ARM_ARCH 4
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
-#  define __ARM_ARCH 3
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# ifdef __ARM_ARCH_2__
-#  define __ARM_ARCH 2
-#  define __ARM_ARCH_ISA_ARM
-# endif
-
-# ifdef __ARMEB__
-#  define __ARM_BIG_ENDIAN
-# endif
-
-/* If we still don't know what the target architecture is, then we're
-   probably not using GCC.  */
-# ifndef __ARM_ARCH
-#  error Unable to determine architecture version.
-# endif
-
-#endif /* __ARM_ARCH  */
-
diff --git a/newlib/libc/machine/arm/memchr-stub.c b/newlib/libc/machine/arm/memchr-stub.c
index 5c7881b9c82d..48451a136c9c 100644
--- a/newlib/libc/machine/arm/memchr-stub.c
+++ b/newlib/libc/machine/arm/memchr-stub.c
@@ -27,7 +27,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memchr.S.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #if defined (__ARM_NEON__) || defined (__ARM_NEON)
 /* Defined in memchr.S.  */
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index 3c11addada96..d13ef8d65454 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -75,7 +75,7 @@
 
 	.syntax unified
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 #include "arm_asm.h"
 
 @ NOTE: This ifdef MUST match the one in memchr-stub.c
diff --git a/newlib/libc/machine/arm/memcpy-stub.c b/newlib/libc/machine/arm/memcpy-stub.c
index 6cd0e3b1d4d5..6f41a85e01b5 100644
--- a/newlib/libc/machine/arm/memcpy-stub.c
+++ b/newlib/libc/machine/arm/memcpy-stub.c
@@ -27,7 +27,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memcpy.S.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
 # include "../../string/memcpy.c"
diff --git a/newlib/libc/machine/arm/memcpy.S b/newlib/libc/machine/arm/memcpy.S
index 77bd2a606e4b..8416232ec8c9 100644
--- a/newlib/libc/machine/arm/memcpy.S
+++ b/newlib/libc/machine/arm/memcpy.S
@@ -29,7 +29,7 @@
 /* The structure of the following #if #else #endif conditional chain
    must match the chain in memcpy-stub.c.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
   /* Defined in memcpy-stub.c.  */
diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
index 5213c063bddc..c615f2428a72 100644
--- a/newlib/libc/machine/arm/setjmp.S
+++ b/newlib/libc/machine/arm/setjmp.S
@@ -2,7 +2,7 @@
 
    Nick Clifton, Cygnus Solutions, 13 June 1997.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 /* ANSI concatenation macros.  */
 #define CONCAT(a, b)  CONCAT2(a, b)
diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S
index 137f44969257..ae308cfc7433 100644
--- a/newlib/libc/machine/arm/strcmp.S
+++ b/newlib/libc/machine/arm/strcmp.S
@@ -28,7 +28,7 @@
 
 /* Wrapper for the various implementations of strcmp.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #ifdef __ARM_BIG_ENDIAN
 #define S2LO lsl
diff --git a/newlib/libc/machine/arm/strlen-armv7.S b/newlib/libc/machine/arm/strlen-armv7.S
index 27094040c748..6aa122c075bb 100644
--- a/newlib/libc/machine/arm/strlen-armv7.S
+++ b/newlib/libc/machine/arm/strlen-armv7.S
@@ -58,7 +58,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 #include "arm_asm.h"
 
 	.macro def_fn f p2align=0
diff --git a/newlib/libc/machine/arm/strlen-thumb2-Os.S b/newlib/libc/machine/arm/strlen-thumb2-Os.S
index a46db573c639..4adbc61d2e03 100644
--- a/newlib/libc/machine/arm/strlen-thumb2-Os.S
+++ b/newlib/libc/machine/arm/strlen-thumb2-Os.S
@@ -24,7 +24,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 #include "arm_asm.h"
 
 	.macro def_fn f p2align=0
diff --git a/newlib/libc/machine/arm/strlen.S b/newlib/libc/machine/arm/strlen.S
index 0435fb2de848..d85a7eeb5bd9 100644
--- a/newlib/libc/machine/arm/strlen.S
+++ b/newlib/libc/machine/arm/strlen.S
@@ -24,7 +24,7 @@
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 #if defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED
 #if __ARM_ARCH_ISA_THUMB == 2
diff --git a/newlib/libc/sys/arm/arm.h b/newlib/libc/sys/arm/arm.h
index 10e5b0509cf8..f3cd49308f77 100644
--- a/newlib/libc/sys/arm/arm.h
+++ b/newlib/libc/sys/arm/arm.h
@@ -29,7 +29,7 @@
 #ifndef _LIBGLOSS_ARM_H
 #define _LIBGLOSS_ARM_H
 
-#include "acle-compat.h"
+#include "arm-acle-compat.h"
 
 /* Checking for targets supporting only Thumb instructions (eg. ARMv6-M) or
    supporting Thumb-2 instructions, whether ARM instructions are available or
-- 
2.39.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v3] libgloss: arm: break newlib dependency
  2023-01-11  6:01 ` [PATCH v3] " Mike Frysinger
@ 2023-01-11  9:14   ` Corinna Vinschen
  0 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2023-01-11  9:14 UTC (permalink / raw)
  To: newlib

On Jan 11 01:01, Mike Frysinger wrote:
> The libgloss port has been reaching back into newlib internals for a
> single header whose contents have been frozen for almost a decade.
> To break this backwards libgloss->newlib dependency, move the acle
> header to the srcroot include/ so everyone can use the same copy.
> ---
> v3
> - use -idirafter with srcroot
> 
>  .../arm-acle-compat.h                         |   0
>  libgloss/Makefile.am                          |   3 +
>  libgloss/Makefile.in                          |   2 +
>  libgloss/arm/Makefile.in                      |   2 -
>  libgloss/arm/arm.h                            |   2 +-
>  libgloss/config/default.mh                    |   2 +-
>  newlib/Makefile.am                            |   3 +-
>  newlib/Makefile.in                            |   4 +-
>  newlib/libc/machine/arm/aeabi_memcpy-armv7a.S |   2 +-
>  newlib/libc/machine/arm/aeabi_memmove-thumb.S |   2 +-
>  newlib/libc/machine/arm/aeabi_memset-thumb.S  |   2 +-
>  newlib/libc/machine/arm/arm_asm.h             |   2 +-
>  newlib/libc/machine/arm/machine/acle-compat.h | 182 ------------------
>  newlib/libc/machine/arm/memchr-stub.c         |   2 +-
>  newlib/libc/machine/arm/memchr.S              |   2 +-
>  newlib/libc/machine/arm/memcpy-stub.c         |   2 +-
>  newlib/libc/machine/arm/memcpy.S              |   2 +-
>  newlib/libc/machine/arm/setjmp.S              |   2 +-
>  newlib/libc/machine/arm/strcmp.S              |   2 +-
>  newlib/libc/machine/arm/strlen-armv7.S        |   2 +-
>  newlib/libc/machine/arm/strlen-thumb2-Os.S    |   2 +-
>  newlib/libc/machine/arm/strlen.S              |   2 +-
>  newlib/libc/sys/arm/arm.h                     |   2 +-
>  23 files changed, 25 insertions(+), 203 deletions(-)
>  rename newlib/libc/machine/arm/acle-compat.h => include/arm-acle-compat.h (100%)
>  delete mode 100644 newlib/libc/machine/arm/machine/acle-compat.h

LGTM.


Thanks,
Corinna


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-01-11  9:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14  9:13 [PATCH] libgloss: arm: break newlib dependency Mike Frysinger
2022-12-19  9:34 ` Corinna Vinschen
2022-12-19 10:08 ` Richard Earnshaw
2022-12-21  1:47   ` Mike Frysinger
2022-12-21  8:24     ` Corinna Vinschen
2022-12-22 22:03       ` Mike Frysinger
2023-01-03 14:56         ` Richard Earnshaw
2023-01-04  2:04 ` Mike Frysinger
2023-01-04  2:17   ` Stefan Tauner
2023-01-04  3:06     ` Mike Frysinger
2023-01-09 10:29       ` Corinna Vinschen
2023-01-10  2:07         ` Mike Frysinger
2023-01-10  8:43           ` Corinna Vinschen
2023-01-11  6:01 ` [PATCH v3] " Mike Frysinger
2023-01-11  9:14   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).