Patchwork [v2] ARM: Use different linker path for hardfloat ABI

login
register
mail settings
Submitter Michael Hope
Date April 23, 2012, 9:36 p.m.
Message ID <CANLjY-=y8pnK2jJZ+mo212o=5b0yOMgvy5G=WhoKnJX_mOV1CQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/154544/
State New
Headers show

Comments

Michael Hope - April 23, 2012, 9:36 p.m.
On 24 April 2012 03:35, Richard Earnshaw <rearnsha@arm.com> wrote:
> On 22/04/12 23:20, Michael Hope wrote:
>> Change the dynamic linker path for ARM hard float executables.
>> Matches the path discussed and agreed on last week[1].  Carlos will
>> follow up with the matching patch to GLIBC[2].  I'm happy to if he's
>> busy.
>>
>> OK for trunk?
>>
>> -- Michael
>> [1] http://sourceware.org/ml/libc-ports/2012-04/msg00060.html
>> [2] http://sourceware.org/ml/libc-ports/2012-04/msg00064.html
>>
>> 2012-04-23  Michael Hope  <michael.hope@linaro.org>
>>
>>       * config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
>>       (GLIBC_DYNAMIC_LINKER_SOFT_FLOAT): Define.
>>       (GLIBC_DYNAMIC_LINKER): Redefine to use the hard float path.
>>
>> diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
>> index 80bd825..3ddf812 100644
>> --- a/gcc/config/arm/linux-eabi.h
>> +++ b/gcc/config/arm/linux-eabi.h
>> @@ -62,7 +62,11 @@
>>  /* 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/ld-linux-armhf.so.3"
>> +#define GLIBC_DYNAMIC_LINKER \
>> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
>> +    %{!mfloat-abi=hard:" 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.  */
>>
>
>
> I think this should handle having the hard-float variant as the default
> more gracefully, so something like:
>
>
> -#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/ld-linux-armhf.so.3"
> +#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_HARD_FLOAT
> +#else
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
> +#endif
> +#define GLIBC_DYNAMIC_LINKER \
> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> +    %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
> +    %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
>
> But I haven't tested any of that.

It tests just fine when setting the float ABI at configure time or
explicitly.  Updated patch is below.  I prefer the original, shorter
version but the new one is easier for someone else to understand.

OK for trunk?

-- Michael

2012-04-24  Michael Hope  <michael.hope@linaro.org>
	    Richard Earnshaw  <rearnsha@arm.com>

	* config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_SOFT_FLOAT): Define.
	(GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
	(GLIBC_DYNAMIC_LINKER_DEFAULT): Define.
	(GLIBC_DYNAMIC_LINKER): Redefine to use the hard float path.
Richard Earnshaw - April 24, 2012, 1:31 p.m.
On 23/04/12 22:36, Michael Hope wrote:
> On 24 April 2012 03:35, Richard Earnshaw <rearnsha@arm.com> wrote:
>> On 22/04/12 23:20, Michael Hope wrote:
>>> Change the dynamic linker path for ARM hard float executables.
>>> Matches the path discussed and agreed on last week[1].  Carlos will
>>> follow up with the matching patch to GLIBC[2].  I'm happy to if he's
>>> busy.
>>>
>>> OK for trunk?
>>>
>>> -- Michael
>>> [1] http://sourceware.org/ml/libc-ports/2012-04/msg00060.html
>>> [2] http://sourceware.org/ml/libc-ports/2012-04/msg00064.html
>>>
>>> 2012-04-23  Michael Hope  <michael.hope@linaro.org>
>>>
>>>       * config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
>>>       (GLIBC_DYNAMIC_LINKER_SOFT_FLOAT): Define.
>>>       (GLIBC_DYNAMIC_LINKER): Redefine to use the hard float path.
>>>
>>> diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
>>> index 80bd825..3ddf812 100644
>>> --- a/gcc/config/arm/linux-eabi.h
>>> +++ b/gcc/config/arm/linux-eabi.h
>>> @@ -62,7 +62,11 @@
>>>  /* 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/ld-linux-armhf.so.3"
>>> +#define GLIBC_DYNAMIC_LINKER \
>>> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
>>> +    %{!mfloat-abi=hard:" 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.  */
>>>
>>
>>
>> I think this should handle having the hard-float variant as the default
>> more gracefully, so something like:
>>
>>
>> -#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/ld-linux-armhf.so.3"
>> +#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD
>> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_HARD_FLOAT
>> +#else
>> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
>> +#endif
>> +#define GLIBC_DYNAMIC_LINKER \
>> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
>> +    %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
>> +    %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
>>
>> But I haven't tested any of that.
> 
> It tests just fine when setting the float ABI at configure time or
> explicitly.  Updated patch is below.  I prefer the original, shorter
> version but the new one is easier for someone else to understand.
> 

Your version would work for configuration using --with-float-abi, but
not for built-in setting with hard-float as default.

> OK for trunk?
> 

OK.

> -- Michael
> 
> 2012-04-24  Michael Hope  <michael.hope@linaro.org>
> 	    Richard Earnshaw  <rearnsha@arm.com>
> 
> 	* config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_SOFT_FLOAT): Define.
> 	(GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
> 	(GLIBC_DYNAMIC_LINKER_DEFAULT): Define.
> 	(GLIBC_DYNAMIC_LINKER): Redefine to use the hard float path.
> 
> diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
> index 80bd825..2ace6f0 100644
> --- a/gcc/config/arm/linux-eabi.h
> +++ b/gcc/config/arm/linux-eabi.h
> @@ -62,7 +62,17 @@
>  /* 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/ld-linux-armhf.so.3"
> +#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_HARD_FLOAT
> +#else
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
> +#endif
> +#define GLIBC_DYNAMIC_LINKER \
> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> +    %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
> +    %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
> 
>  /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
>     use the GNU/Linux version, not the generic BPABI version.  */
>
Carlos O'Donell - April 26, 2012, 8:20 p.m.
On Mon, Apr 23, 2012 at 5:36 PM, Michael Hope <michael.hope@linaro.org> wrote:
> 2012-04-24  Michael Hope  <michael.hope@linaro.org>
>            Richard Earnshaw  <rearnsha@arm.com>
>
>        * config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER_SOFT_FLOAT): Define.
>        (GLIBC_DYNAMIC_LINKER_HARD_FLOAT): Define.
>        (GLIBC_DYNAMIC_LINKER_DEFAULT): Define.
>        (GLIBC_DYNAMIC_LINKER): Redefine to use the hard float path.
>
> diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
> index 80bd825..2ace6f0 100644
> --- a/gcc/config/arm/linux-eabi.h
> +++ b/gcc/config/arm/linux-eabi.h
> @@ -62,7 +62,17 @@
>  /* 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/ld-linux-armhf.so.3"
> +#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_HARD_FLOAT
> +#else
> +#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
> +#endif
> +#define GLIBC_DYNAMIC_LINKER \
> +   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
> +    %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
> +    %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
>
>  /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
>    use the GNU/Linux version, not the generic BPABI version.  */

This patch is broken. Please fix this.

You can't use a named enumeration in cpp equality.

The type ARM_FLOAT_ABI_HARD is a named enumeration and evaluates to 0
as an unknown identifier.

Therefore "#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD"
evaluates to "#if 0 == 0" and is always true.

Watch out that "#define ARM_FLOAT_ABI_HARD ARM_FLOAT_ABI_HARD" for
such enums is not conforming C99/C11.

I suggest you define the types as macros and then set the named enum
to those values, then use the macros in the header equality checks.

e.g.
#define VAL1 0 then enum FOO { RVAL1 = VAL1, ... }

Look at arm.h for the enum definition.

Cheers,
Carlos.

Patch

diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index 80bd825..2ace6f0 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -62,7 +62,17 @@ 
 /* 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/ld-linux-armhf.so.3"
+#if TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_HARD
+#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_HARD_FLOAT
+#else
+#define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
+#endif
+#define GLIBC_DYNAMIC_LINKER \
+   "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
+    %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+    %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"

 /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
    use the GNU/Linux version, not the generic BPABI version.  */