public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
@ 2012-05-07  2:22 Carlos O'Donell
  2012-05-07  7:27 ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos O'Donell @ 2012-05-07  2:22 UTC (permalink / raw)
  To: libc-ports, Joseph S. Myers; +Cc: GNU C Library

The dynamic linker name should be /lib/ld-linux-armhf.so.3 when
compiling glibc with a compiler and flags that would cause the ARM
hard-float ABI to be selected. The following patch implements the
selection of the correct dynamic linker name for ARM given the new
alternate name for the hard-float ABI.

The compiler defines __ARM_PCS_VFP when the hard-float ABI is being
used. The sysdeps/arm/configure.in check sets HAVE_ARM_PCS_VFP when it
detects that the compiler *and* flags would select the hard-float ABI.
The shlib-versions file then uses %ifdef HAVE_ARM_PCS_VFP to select
the alternate dynamic linker; we can do this because shlib-versions is
handled by the implicit rule which uses -include to include
include/libc-symbols.h which in turn includes config.h. The file
shlib-versions is run through sed to convert the %ifdef into #ifdef,
and cpp does the final processing.

Interestingly the patch *could* have been a one-line change to add
%ifdef __ARM_PCS_VFP, but this is not possible since the implicit rule
that runs cpp also adds -undef which removes all of the compiler
builtin defines. Trying to remove the -undef is difficult because the
implicit rule is used in contexts where the compiler builtin defines
should not be present. Adding a new implicit rule in the makefile just
for shlib-versions processing was, in my opinion, less clear than this
current patch.

This patch is significantly better than original WIP patch which added
an additional sysdep directory with an alternate shlib-versions file.
By adding an alternate directory you must also mirror the structure of
all the sub-machine (armv7 and armv6t2) directories and include
Implies to add them back into the build.

Tested by building a multilib'd compiler and compiling glibc for at
least the soft-float (armv5te) and hard-float (armv7-a) cases, and
verifying that glibc installs the correct dynamic loader in each case.

Testing requires a recent gcc with Michael Hope and Richard Earnshaw's
final patches to default to the original soft-float loader or select
the new hard-float loader if -mfloat-abi=hard is used (see
http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01335.html).

I additionally tested some compatibility cases where an old toolchain
was used to build an application and run it against the new sysroot
with a compat symlink e.g. ld-linux.so.3 -> ld-2.xx.so and
ld-linux-armhf.so.3 -> ld-2.xx.so, and everything worked as expected.

OK to commit?

2012-05-06  Carlos O'Donell  <carlos_odonell@mentor.com>
	    Khem Raj <raj.khem@gmail.com>

	* sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
	If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
	* sysdeps/arm/configure: Regenerate.
	* sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
	then use ld=/lib/ld-linux-armhf.so.3.

diff --git a/sysdeps/arm/configure.in b/sysdeps/arm/configure.in
index 706add2..60d4093 100644
--- a/sysdeps/arm/configure.in
+++ b/sysdeps/arm/configure.in
@@ -49,3 +49,28 @@ EOF
 if test $libc_cv_asm_cfi_directive_sections != yes; then
   AC_MSG_ERROR([need .cfi_sections in this configuration])
 fi
+
+AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
+  [libc_cv_arm_pcs_vfp],
+  [archcppflag=`echo "" |
+       $CC $CFLAGS $CPPFLAGS -E -dM - |
+       grep __ARM_PCS_VFP |
+       sed -e 's/^#define //' -e 's/ .*//'`
+  # We check to see if the compiler and flags are
+  # selecting the hard-float ABI and if they are then
+  # we set libc_cv_arm_pcs_vfp to yes which causes
+  # HAVE_ARM_PCS_VFP to be defined in config.h and
+  # in include/libc-symbols.h and thus availabile to
+  # shlib-versions to select the appropriate name for
+  # the dynamic linker via %ifdef.
+  case x$archcppflag in
+  x__ARM_PCS_VFP)
+    libc_cv_arm_pcs_vfp=yes
+    ;;
+  *)
+    libc_cv_arm_pcs_vfp=no
+    ;;
+  esac])
+if test $libc_cv_arm_pcs_vfp = yes; then
+  AC_DEFINE(HAVE_ARM_PCS_VFP)
+fi
diff --git a/sysdeps/arm/shlib-versions b/sysdeps/arm/shlib-versions
index 626d58b..d500166 100644
--- a/sysdeps/arm/shlib-versions
+++ b/sysdeps/arm/shlib-versions
@@ -1,3 +1,9 @@
 arm.*-.*-linux-gnueabi.*       DEFAULT                 GLIBC_2.4

+%ifdef HAVE_ARM_PCS_VFP
+# The EABI-derived hard-float ABI uses a new dynamic linker.
+arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
+%else
+# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
 arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
+%endif
===

Note:
- Updated "Regeneration" with instructions on regenerating the
configure fragment for ports machines.
http://sourceware.org/glibc/wiki/Regeneration

Cheers,
Carlos.

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

* Re: [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07  2:22 [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI Carlos O'Donell
@ 2012-05-07  7:27 ` Andreas Schwab
  2012-05-07 18:49   ` Roland McGrath
  2012-05-07 18:56   ` [PATCH v2, " Carlos O'Donell
  0 siblings, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2012-05-07  7:27 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: libc-ports, Joseph S. Myers, GNU C Library

"Carlos O'Donell" <carlos@systemhalted.org> writes:

> +AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
> +  [libc_cv_arm_pcs_vfp],
> +  [archcppflag=`echo "" |
> +       $CC $CFLAGS $CPPFLAGS -E -dM - |
> +       grep __ARM_PCS_VFP |
> +       sed -e 's/^#define //' -e 's/ .*//'`

Please use AC_EGREP_CPP.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07  7:27 ` Andreas Schwab
@ 2012-05-07 18:49   ` Roland McGrath
  2012-05-07 18:53     ` Carlos O'Donell
  2012-05-07 18:56   ` [PATCH v2, " Carlos O'Donell
  1 sibling, 1 reply; 9+ messages in thread
From: Roland McGrath @ 2012-05-07 18:49 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Carlos O'Donell, libc-ports, Joseph S. Myers, GNU C Library

> "Carlos O'Donell" <carlos@systemhalted.org> writes:
> 
> > +AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
> > +  [libc_cv_arm_pcs_vfp],
> > +  [archcppflag=`echo "" |
> > +       $CC $CFLAGS $CPPFLAGS -E -dM - |
> > +       grep __ARM_PCS_VFP |
> > +       sed -e 's/^#define //' -e 's/ .*//'`
> 
> Please use AC_EGREP_CPP.

That won't work because it doesn't pass -dM.  But anyway, what we've always
said was the right approach is just a compile test that does:

#ifndef __ARM_PCS_VFP
#error do not have it
#endif

or the like.


Thanks,
Roland

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

* Re: [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07 18:49   ` Roland McGrath
@ 2012-05-07 18:53     ` Carlos O'Donell
  0 siblings, 0 replies; 9+ messages in thread
From: Carlos O'Donell @ 2012-05-07 18:53 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Andreas Schwab, libc-ports, Joseph S. Myers, GNU C Library

On Mon, May 7, 2012 at 2:49 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> "Carlos O'Donell" <carlos@systemhalted.org> writes:
>>
>> > +AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
>> > +  [libc_cv_arm_pcs_vfp],
>> > +  [archcppflag=`echo "" |
>> > +       $CC $CFLAGS $CPPFLAGS -E -dM - |
>> > +       grep __ARM_PCS_VFP |
>> > +       sed -e 's/^#define //' -e 's/ .*//'`
>>
>> Please use AC_EGREP_CPP.
>
> That won't work because it doesn't pass -dM.  But anyway, what we've always
> said was the right approach is just a compile test that does:
>
> #ifndef __ARM_PCS_VFP
> #error do not have it
> #endif
>
> or the like.

I assumed that's what Andreas meant.

I'm currently using:

#ifdef __ARM_PCS_VFP
yes
#endif

With a `yes' pattern in AC_EGREP_CPP.

Cheers,
Carlos.

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

* [PATCH v2, 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07  7:27 ` Andreas Schwab
  2012-05-07 18:49   ` Roland McGrath
@ 2012-05-07 18:56   ` Carlos O'Donell
  2012-05-07 19:18     ` Joseph S. Myers
  1 sibling, 1 reply; 9+ messages in thread
From: Carlos O'Donell @ 2012-05-07 18:56 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-ports, Joseph S. Myers, GNU C Library

On Mon, May 7, 2012 at 3:27 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> "Carlos O'Donell" <carlos@systemhalted.org> writes:
>
>> +AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
>> +  [libc_cv_arm_pcs_vfp],
>> +  [archcppflag=`echo "" |
>> +       $CC $CFLAGS $CPPFLAGS -E -dM - |
>> +       grep __ARM_PCS_VFP |
>> +       sed -e 's/^#define //' -e 's/ .*//'`
>
> Please use AC_EGREP_CPP.

Thanks. Patch updated.

With AC_EGREP_CPP in a default ARMv5TE build I get:
checking for grep that handles long lines and -e... (cached)
/usr/local/tools/gcc-4.3.3/bin/grep
checking for egrep... (cached) /usr/local/tools/gcc-4.3.3/bin/grep -E
checking whether the compiler is using the ARM hard-float ABI... no

With AC_EGREP_CPP in a ARMv7-A hard-float ABI build I get:
checking for grep that handles long lines and -e... (cached)
/usr/local/tools/gcc-4.3.3/bin/grep
checking for egrep... (cached) /usr/local/tools/gcc-4.3.3/bin/grep -E
checking whether the compiler is using the ARM hard-float ABI... yes

Everything works as expected.

v2 - Use AC_EGREP_CPP.

OK to commit?

2012-05-07  Carlos O'Donell  <carlos_odonell@mentor.com>

	* sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
	If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
	* sysdeps/arm/configure: Regenerate.
	* sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
	then use ld=/lib/ld-linux-armhf.so.3.

diff --git a/sysdeps/arm/configure.in b/sysdeps/arm/configure.in
index 706add2..f00b798 100644
--- a/sysdeps/arm/configure.in
+++ b/sysdeps/arm/configure.in
@@ -49,3 +49,20 @@ EOF
 if test $libc_cv_asm_cfi_directive_sections != yes; then
   AC_MSG_ERROR([need .cfi_sections in this configuration])
 fi
+
+# We check to see if the compiler and flags are
+# selecting the hard-float ABI and if they are then
+# we set libc_cv_arm_pcs_vfp to yes which causes
+# HAVE_ARM_PCS_VFP to be defined in config.h and
+# in include/libc-symbols.h and thus available to
+# shlib-versions to select the appropriate name for
+# the dynamic linker via %ifdef.
+AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
+  [libc_cv_arm_pcs_vfp],
+  [AC_EGREP_CPP(yes,[#ifdef __ARM_PCS_VFP
+                      yes
+                     #endif
+  ], libc_cv_arm_pcs_vfp=yes, libc_cv_arm_pcs_vfp=no)])
+if test $libc_cv_arm_pcs_vfp = yes; then
+  AC_DEFINE(HAVE_ARM_PCS_VFP)
+fi
diff --git a/sysdeps/arm/shlib-versions b/sysdeps/arm/shlib-versions
index 626d58b..ba88d95 100644
--- a/sysdeps/arm/shlib-versions
+++ b/sysdeps/arm/shlib-versions
@@ -1,3 +1,9 @@
 arm.*-.*-linux-gnueabi.*       DEFAULT                 GLIBC_2.4

-arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
+%ifdef HAVE_ARM_PCS_VFP
+# The EABI-derived hard-float ABI uses a new dynamic linker.
+arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
+%else
+# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
+ arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
+%endif
===

Cheers,
Carlos.

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

* Re: [PATCH v2, 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07 18:56   ` [PATCH v2, " Carlos O'Donell
@ 2012-05-07 19:18     ` Joseph S. Myers
  2012-05-07 19:19       ` Carlos O'Donell
  0 siblings, 1 reply; 9+ messages in thread
From: Joseph S. Myers @ 2012-05-07 19:18 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: Andreas Schwab, libc-ports, GNU C Library

On Mon, 7 May 2012, Carlos O'Donell wrote:

> 2012-05-07  Carlos O'Donell  <carlos_odonell@mentor.com>
> 
> 	* sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
> 	If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
> 	* sysdeps/arm/configure: Regenerate.
> 	* sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
> 	then use ld=/lib/ld-linux-armhf.so.3.

This is OK if the libc change is OK, with one fix:

> +%ifdef HAVE_ARM_PCS_VFP
> +# The EABI-derived hard-float ABI uses a new dynamic linker.
> +arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
> +%else
> +# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
> + arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3

Remove the leading space on this line.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH v2, 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07 19:18     ` Joseph S. Myers
@ 2012-05-07 19:19       ` Carlos O'Donell
  2012-05-08 17:55         ` Carlos O'Donell
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos O'Donell @ 2012-05-07 19:19 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Andreas Schwab, libc-ports, GNU C Library

On Mon, May 7, 2012 at 3:18 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Mon, 7 May 2012, Carlos O'Donell wrote:
>
>> 2012-05-07  Carlos O'Donell  <carlos_odonell@mentor.com>
>>
>>       * sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
>>       If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
>>       * sysdeps/arm/configure: Regenerate.
>>       * sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
>>       then use ld=/lib/ld-linux-armhf.so.3.
>
> This is OK if the libc change is OK, with one fix:
>
>> +%ifdef HAVE_ARM_PCS_VFP
>> +# The EABI-derived hard-float ABI uses a new dynamic linker.
>> +arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
>> +%else
>> +# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
>> + arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
>
> Remove the leading space on this line.

Done. Thanks.

Cheers,
Carlos.

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

* Re: [PATCH v2, 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-07 19:19       ` Carlos O'Donell
@ 2012-05-08 17:55         ` Carlos O'Donell
  2012-05-08 17:58           ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Carlos O'Donell @ 2012-05-08 17:55 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Andreas Schwab, libc-ports, GNU C Library

On Mon, May 7, 2012 at 3:19 PM, Carlos O'Donell <carlos@systemhalted.org> wrote:
> On Mon, May 7, 2012 at 3:18 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
>> On Mon, 7 May 2012, Carlos O'Donell wrote:
>>
>>> 2012-05-07  Carlos O'Donell  <carlos_odonell@mentor.com>
>>>
>>>       * sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
>>>       If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
>>>       * sysdeps/arm/configure: Regenerate.
>>>       * sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
>>>       then use ld=/lib/ld-linux-armhf.so.3.
>>
>> This is OK if the libc change is OK, with one fix:
>>
>>> +%ifdef HAVE_ARM_PCS_VFP
>>> +# The EABI-derived hard-float ABI uses a new dynamic linker.
>>> +arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
>>> +%else
>>> +# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
>>> + arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
>>
>> Remove the leading space on this line.
>
> Done. Thanks.

Checked into trunk.

Cheers,
Carlos.

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

* Re: [PATCH v2, 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI.
  2012-05-08 17:55         ` Carlos O'Donell
@ 2012-05-08 17:58           ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2012-05-08 17:58 UTC (permalink / raw)
  To: libc-ports
  Cc: Carlos O'Donell, Joseph S. Myers, Andreas Schwab, GNU C Library

[-- Attachment #1: Type: Text/Plain, Size: 1165 bytes --]

On Tuesday 08 May 2012 13:54:55 Carlos O'Donell wrote:
> On Mon, May 7, 2012 at 3:19 PM, Carlos O'Donell wrote:
> > On Mon, May 7, 2012 at 3:18 PM, Joseph S. Myers wrote:
> >> On Mon, 7 May 2012, Carlos O'Donell wrote:
> >>> 2012-05-07  Carlos O'Donell  <carlos_odonell@mentor.com>
> >>> 
> >>>       * sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
> >>>       If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
> >>>       * sysdeps/arm/configure: Regenerate.
> >>>       * sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
> >>>       then use ld=/lib/ld-linux-armhf.so.3.
> >> 
> >> This is OK if the libc change is OK, with one fix:
> >>> +%ifdef HAVE_ARM_PCS_VFP
> >>> +# The EABI-derived hard-float ABI uses a new dynamic linker.
> >>> +arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
> >>> +%else
> >>> +# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
> >>> + arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
> >> 
> >> Remove the leading space on this line.
> > 
> > Done. Thanks.
> 
> Checked into trunk.

awesome, thanks.  glad to see this hardfp stuff come together :).
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-05-08 17:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07  2:22 [PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamic linker for the ARM hard-float ABI Carlos O'Donell
2012-05-07  7:27 ` Andreas Schwab
2012-05-07 18:49   ` Roland McGrath
2012-05-07 18:53     ` Carlos O'Donell
2012-05-07 18:56   ` [PATCH v2, " Carlos O'Donell
2012-05-07 19:18     ` Joseph S. Myers
2012-05-07 19:19       ` Carlos O'Donell
2012-05-08 17:55         ` Carlos O'Donell
2012-05-08 17:58           ` Mike Frysinger

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