[PATCH] ARM: Use different linker path for hardfloat ABI

2012-03-29 Thread dann frazier
This is an updated version of a patch Debian and Ubuntu are using to
use an alternate linker path for hardfloat binaries. The difference
with this one is that it covers the case where no float flag
was passed in, defaulting to the softfloat path.

2012-03-29  dann frazier 

* config/arm/linux-elf.h: Use alternate linker path
  for hardfloat ABI

Index: gcc/config/arm/linux-elf.h
===
--- gcc/config/arm/linux-elf.h  (revision 185708)
+++ gcc/config/arm/linux-elf.h  (working copy)
@@ -59,14 +59,21 @@
 
 #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
 
-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+#define LINUX_DYNAMIC_LINKER_SF "/lib/ld-linux.so.3"
+#define LINUX_DYNAMIC_LINKER_HF "/lib/arm-linux-gnueabihf/ld-linux.so.3"
 
 #define LINUX_TARGET_LINK_SPEC  "%{h*} \
%{static:-Bstatic} \
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
%{rdynamic:-export-dynamic} \
-   -dynamic-linker " GNU_USER_DYNAMIC_LINKER " \
+   %{msoft-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "} \
+   %{mfloat-abi=soft*:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "} \
+   %{mhard-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
+   %{mfloat-abi=hard:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
+   %{!mfloat-abi: \
+ %{!msoft-float: \
+   %{!mhard-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "}}} \
-X \
%{mbig-endian:-EB} %{mlittle-endian:-EL}" \
SUBTARGET_EXTRA_LINK_SPEC


Re: [PATCH] ARM: Use different linker path for hardfloat ABI

2012-04-02 Thread dann frazier
On Fri, Mar 30, 2012 at 06:52:34PM +0100, Richard Earnshaw wrote:
> On 29/03/12 20:34, dann frazier wrote:
> > This is an updated version of a patch Debian and Ubuntu are using to
> > use an alternate linker path for hardfloat binaries. The difference
> > with this one is that it covers the case where no float flag
> > was passed in, defaulting to the softfloat path.
> > 
> > 2012-03-29  dann frazier 
> > 
> > * config/arm/linux-elf.h: Use alternate linker path
> >   for hardfloat ABI
> > 
> > Index: gcc/config/arm/linux-elf.h
> > ===
> > --- gcc/config/arm/linux-elf.h  (revision 185708)
> > +++ gcc/config/arm/linux-elf.h  (working copy)
> > @@ -59,14 +59,21 @@
> >  
> >  #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
> >  
> > -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
> > +#define LINUX_DYNAMIC_LINKER_SF "/lib/ld-linux.so.3"
> > +#define LINUX_DYNAMIC_LINKER_HF "/lib/arm-linux-gnueabihf/ld-linux.so.3"
> >  
> >  #define LINUX_TARGET_LINK_SPEC  "%{h*} \
> > %{static:-Bstatic} \
> > %{shared:-shared} \
> > %{symbolic:-Bsymbolic} \
> > %{rdynamic:-export-dynamic} \
> > -   -dynamic-linker " GNU_USER_DYNAMIC_LINKER " \
> > +   %{msoft-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "} \
> > +   %{mfloat-abi=soft*:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "} \
> > +   %{mhard-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
> > +   %{mfloat-abi=hard:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
> > +   %{!mfloat-abi: \
> > + %{!msoft-float: \
> > +   %{!mhard-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_SF "}}} \
> > -X \
> > %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
> > SUBTARGET_EXTRA_LINK_SPEC
> > 
> 
> Looks to me as though this will break the old Linux ABI.  While we've
> marked that as deprecated, it hasn't been removed as yet.  So I think
> this patch either needs to wait until that removal has taken place, or
> provide the relevant updates to maintain the old ABI support.

Thanks for your review. You're right, this does appear to break the
old ABI - that was a misunderstanding on my part. I think this fixes
the problem:

Index: gcc/config/arm/linux-elf.h
===
--- gcc/config/arm/linux-elf.h  (revision 185708)
+++ gcc/config/arm/linux-elf.h  (working copy)
@@ -60,13 +60,17 @@
 #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+#define LINUX_DYNAMIC_LINKER_HF "/lib/arm-linux-gnueabihf/ld-linux.so.3"
 
 #define LINUX_TARGET_LINK_SPEC  "%{h*} \
%{static:-Bstatic} \
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
%{rdynamic:-export-dynamic} \
-   -dynamic-linker " GNU_USER_DYNAMIC_LINKER " \
+   %{mhard-float:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
+   %{mfloat-abi=hard:-dynamic-linker " LINUX_DYNAMIC_LINKER_HF "} \
+   %{!mfloat-abi: \
+ %{!mhard-float:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
-X \
%{mbig-endian:-EB} %{mlittle-endian:-EL}" \
SUBTARGET_EXTRA_LINK_SPEC



Re: [PATCH] ARM: Use different linker path for hardfloat ABI

2012-04-03 Thread dann frazier
On Tue, Apr 03, 2012 at 03:29:06PM +1200, Michael Hope wrote:
> On 3 April 2012 09:06, dann frazier  wrote:
> > On Fri, Mar 30, 2012 at 06:52:34PM +0100, Richard Earnshaw wrote:
> >> On 29/03/12 20:34, dann frazier wrote:
> >> > This is an updated version of a patch Debian and Ubuntu are using to
> >> > use an alternate linker path for hardfloat binaries. The difference
> >> > with this one is that it covers the case where no float flag
> >> > was passed in, defaulting to the softfloat path.
> 
> Hi Dann.  The change should be in the EABI specific linux-eabi.h
> instead of the shared/OABI linux-elf.h.  It breaks support for uClibc
> and Bionic by always using the GLIBC loader in hard float mode.  The
> final line in the spec is missing a '=hard' and always adds
> /lib/ld-linux.so.3.
> 
> How about:
> 
> 2012-04-03  Michael Hope  
> 
>* config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
>(GLIBC_DYNAMIC_LINKER): Redefine to use the hard float loader.

Nice, thanks Michael. I'd looked at doing something similar, but I
wasn't sure that defining GLIBC_DYNAMIC_LINKER to a spec macro would
work :)

 -dann
> 
> diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
> index 80bd825..8498472 100644
> --- a/gcc/config/arm/linux-eabi.h
> +++ b/gcc/config/arm/linux-eabi.h
> @@ -62,7 +62,12 @@
>  /* Use ld-linux.so.3 so that it will be possible to run "classic"
> GNU/Linux binaries on an EABI system.  */
>  #undef  GLIBC_DYNAMIC_LINKER
> -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
> +#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
> +#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT
> "/lib/arm-linux-gnueabihf/ld-linux.so.3"
> +#define GLIBC_DYNAMIC_LINKER \
> +   "%{mhard-float:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> +%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> +%{!mfloat-abi=hard:%{!mhard-float:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "}}"
> 
>  /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
> use the GNU/Linux version, not the generic BPABI version.  */
> 
> 
> which works for the following test cases:
>  gcc -mhard-float foo.c => /lib/arm-linux-gnueabihf/ld-linux.so.3
>  gcc -mfloat-abi=hard foo.c => /lib/arm-linux-gnueabihf/ld-linux.so.3
>  gcc -msoft-float foo.c => /lib/ld-linux.so.3
>  gcc -mfloat-abi=softfp foo.c => /lib/ld-linux.so.3
>  gcc -mbionic => /system/bin/linker
>  gcc -mbionic -mhard-float => /system/bin/linker
>  gcc -muclibc => /lib/ld-uClibc.so.0
>  gcc -muclibc -mhard-float => /lib/ld-uClibc.so.0
> 
> -- Michael


Re: [PATCH] ARM: Use different linker path for hardfloat ABI

2012-04-04 Thread dann frazier
On Wed, Apr 04, 2012 at 02:39:58PM +1200, Michael Hope wrote:
> On 4 April 2012 10:56, Joseph S. Myers  wrote:
> > On Tue, 3 Apr 2012, Michael Hope wrote:
> >
> >> +#define GLIBC_DYNAMIC_LINKER \
> >> +   "%{mhard-float:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> >> +    %{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> >> +    %{!mfloat-abi=hard:%{!mhard-float:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT 
> >> "}}"
> >
> > (a) -mhard-float is a .opt Alias for -mfloat-abi=hard so does not need to
> > be handled in specs.
> 
> Fixed.
> 
> > (b) You need to handle compilers configured with --with-float=hard, so
> > make the specs depend on the default ABI the compiler was configured with.
> 
> GCC seems to take configure time options into account when evaluating
> a spec file.
> 
> Tested by building a default, --with-float=hard, and
> --with-float=softfp compiler then checking the loader path for all
> combinations of {,-mglibc,-mbionic,-muclibc} x
> {,-mhard-float,-msoft-float,-mfloat-abi=hard,-mfloat-abi=softfp}.
> 
> > (c) Please include libc-ports on future submissions and provide both the
> > GCC patch and the glibc ports patch that have been tested to work together
> > to build and install the library in the given path; a patch to one
> > component like this cannot sensibly be considered in isolation.  I imagine
> > you'll need appropriate ARM preconfigure support to detect what ABI the
> > compiler is using, much like the support for MIPS, so that the right
> > shlib-versions files are used.
> 
> Agreed.
> 
> >  I try to follow all ARM glibc discussions
> > on libc-ports closely, as the ARM glibc maintainer; was there a previous
> > discussion of the dynamic linker naming issue there that I missed?
> 
> Steve McIntyre is driving this inside Debian.  I'll ping him on the
> GLIBC support.
> 
> The tricky one is new GCC with old GLIBC.  GCC may have to do a
> configure time test and fall back to /lib/ld-linux.so.3 if the hard
> float loader is missing.
> 
> >  (The only previous relevant discussion that I recall is one on
> > patc...@eglibc.org starting at
> > , regarding how the
> > dynamic linker should check that a library has the right ABI, and there
> > was no real followup on that after I indicated what would seem to be the
> > appropriate implementation approaches and places for subsequent
> > discussion.)
> 
> The patch above changes the loader to catch a mixed installation and
> reject mixing incompatible libraries.  The static linker does this
> currently but it's not essential.
> 
> > I have no idea whether shlib-versions files naming a file in a
> > subdirectory will work - but if not, you'd need to send a patch to
> > libc-alpha to support dynamic linkers in subdirectories, with appropriate
> > justification for why you are doing something different from all other
> > architectures.
> 
> Understood.  For now this is just a path.  There's more infrastructure
> work needed if the path includes a directory.
> 
> > (d) Existing practice for Power Architecture and MIPS at least is that
> > hard-float and soft-float *don't* use different library directories /
> > dynamic linkers.
> 
> The goal is to have a standard loader path for all hard float distros
> and, similar to how you can have a mixed 32/64 bit installation, allow
> mixed softfp/hard float installations for distros that want it.  This
> is a new requirement and ARM is the first one exposed to it.  I assume
> Debian would push for similar changes on MIPS and PowerPC.
> 
> Do the MIPS or PowerPC loaders detect the ABI and change the library
> path based on that?  I couldn't tell from the code.
> 
> > (e) Existing practice for cases that do use different dynamic linkers is
> > to use a separate library directory, not just dynamic linker name, as in
> > lib32 and lib64 for MIPS or libx32 for x32; it's certainly a lot easier to
> > make two sets of libraries work in parallel if you have separate library
> > directories like that.
> 
> Is this required, or should it be left to the distro to choose?  Once
> the loader is in control then it can account for any distro specific
> features, which may be the standard /lib and /usr/lib for single ABI
> distros like Fedora or /usr/lib/$tuple for multiarch distros like
> Ubuntu and Debian.
> 
> > So it would seem more appropriate to define a directory libhf for ARM 
> > (meaning you need a binutils patch as well to
> > handle that directory, I think)
> 
> I'd like to leave that discussion for now.  The Debian goal is to
> support incompatible ABIs and, past that, incompatible architectures.
> libhf is ambiguous as you could have a MIPS hard float library
> installed on the same system as an ARM hard float library.
> 
> > and these different Debian-style names
> > could be implemented separately in a multiarch patch if someone submits
> > one that properly accounts for my review comments on previous patch
> > versions (failure to produce such a fixed pa