public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Michael Hope <michael.hope@linaro.org>
To: "Carlos O'Donell" <carlos@systemhalted.org>
Cc: Richard Earnshaw <rearnsha@arm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
		"cross-distro@lists.linaro.org" <cross-distro@lists.linaro.org>,
		"libc-ports@sourceware.org" <libc-ports@sourceware.org>
Subject: Re: [PATCH v2] ARM: Use different linker path for hardfloat ABI
Date: Thu, 26 Apr 2012 23:27:00 -0000	[thread overview]
Message-ID: <CANLjY-m8udADuOo1gMfR9NWa-iw_JHbtnsoRAF1of1cvzdxSTg@mail.gmail.com> (raw)
In-Reply-To: <CADZpyixYZAGYv=i=Xe4fefcBsxqPb3onaC1RGnfzGJnRX+MF4Q@mail.gmail.com>

On 27 April 2012 08:20, Carlos O'Donell <carlos@systemhalted.org> wrote:
> 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.

I've looked further into this and I think the original pre-#if version
is correct.

The float ABI comes from these places:
 * The -mfloat-abi= command line argument, else
 * The --with-float= configure time argument, else
 * TARGET_DEFAULT_FLOAT_ABI from linux-eabi.h

In the first case the ABI is explicit.  In the second
OPTION_DEFAULT_SPECS turns the configure time argument into an explict
-mfloat-abi=.

The patch below covers all cases, keeps the logic in the spec file,
and adds a comment linking the two #defines.

Tested by building with no configure flags, --wtih-float=softfp,
--with-float=hard, and then running with all combinations of
{,-mfloat-abi=softfp,-mfloat-abi=hard} {,-mglibc,-muclibc,-mbionic}.

OK?

-- Michael

2012-04-27  Michael Hope  <michael.hope@linaro.org>

	* config/arm/linux-eabi.h (GLIBC_DYNAMIC_LINKER): Pick the loader
	using a spec rule.


diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index 2ace6f0..e3cba57 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -60,19 +60,17 @@
 #define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION

 /* Use ld-linux.so.3 so that it will be possible to run "classic"
-   GNU/Linux binaries on an EABI system.  */
+   GNU/Linux binaries on an EABI system.
+   Use ld-linux-armhf.so.3 so that it will be possible to install both
+   hard and soft float binaries on a system.  */
 #undef  GLIBC_DYNAMIC_LINKER
 #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
+/* Update this rule if TARGET_DEFAULT_FLOAT_ABI changes from
+   ARM_FLOAT_ABI_SOFT.  */
 #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 "}"
+  "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_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.  */

  reply	other threads:[~2012-04-26 23:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 22:20 Michael Hope
2012-04-23 15:37 ` Richard Earnshaw
2012-04-23 21:37   ` Michael Hope
2012-04-24 13:32     ` Richard Earnshaw
2012-04-26 20:21     ` Carlos O'Donell
2012-04-26 23:27       ` Michael Hope [this message]
2012-04-30 15:24         ` Richard Earnshaw
2012-04-30 21:48           ` Michael Hope
2012-04-30 22:01             ` Jeff Law
2012-05-01  2:44               ` Michael Hope
2012-05-01  3:46                 ` Jeff Law
2012-05-01  8:52             ` Richard Earnshaw
2012-05-23  7:13               ` Andreas Jaeger
2012-05-23  7:56                 ` Richard Earnshaw
2012-05-23  8:01                   ` Andreas Jaeger
2012-05-23  8:18                     ` Richard Guenther
2012-05-23 14:15                       ` Mike Frysinger
2012-05-23 21:12                         ` Michael Hope
2012-05-24  4:08                           ` Mike Frysinger
2012-05-24  8:15                           ` Andrew Haley
2012-05-25  0:27                             ` Mike Frysinger
2012-05-25  8:24                               ` Andrew Haley
2012-05-24 17:08                       ` Jakub Jelinek
2012-04-23 19:58 ` Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANLjY-m8udADuOo1gMfR9NWa-iw_JHbtnsoRAF1of1cvzdxSTg@mail.gmail.com \
    --to=michael.hope@linaro.org \
    --cc=carlos@systemhalted.org \
    --cc=cross-distro@lists.linaro.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libc-ports@sourceware.org \
    --cc=rearnsha@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).