public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler
@ 2015-06-29 13:07 Jiong Wang
  2015-06-30  7:32 ` Andreas Schwab
  2015-07-01  8:32 ` James Greenhalgh
  0 siblings, 2 replies; 5+ messages in thread
From: Jiong Wang @ 2015-06-29 13:07 UTC (permalink / raw)
  To: gcc-patches

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


This patch fix the breakage caused by

  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01913.html

We fall back to -fPIC if there is no assembler support on those new
relocation modifiers for -fpic.

OK for trunk?

gcc/
  * configure.ac: Add check for aarch64 assembler -fpic relocation
  modifier support.
  * configure: Regenerate.
  * config.in: Regenerate.
  * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
  -fPIC if not support of -fpic relocation modifier in assembler.
-- 
Regards,
Jiong


[-- Attachment #2: 2.patch --]
[-- Type: text/x-diff, Size: 3348 bytes --]

diff --git a/gcc/config.in b/gcc/config.in
index 3aee936..476d585 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -606,6 +606,12 @@
 #endif
 
 
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SPIC_RELOCS
+#endif
+
+
 /* Define if your assembler and linker support thread-local storage. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_TLS
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f130f8d..7e09e3b 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7581,9 +7581,13 @@ initialize_aarch64_code_model (void)
 	   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
 	   break;
 	 case AARCH64_CMODEL_SMALL:
+#ifdef HAVE_AS_SPIC_RELOCS
 	   aarch64_cmodel = (flag_pic == 2
 			     ? AARCH64_CMODEL_SMALL_PIC
 			     : AARCH64_CMODEL_SMALL_SPIC);
+#else
+	   aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+#endif
 	   break;
 	 case AARCH64_CMODEL_LARGE:
 	   sorry ("code model %qs with -f%s", "large",
diff --git a/gcc/configure b/gcc/configure
index 3f3f578..b72cde7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -24228,6 +24228,40 @@ $as_echo "#define HAVE_AS_MABI_OPTION 1" >>confdefs.h
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic relocs" >&5
+$as_echo_n "checking assembler for -fpic relocs... " >&6; }
+if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_aarch64_picreloc=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '
+	.text
+	ldr     x0, [x2, #:gotpage_lo15:globalsym]
+    ' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_aarch64_picreloc=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_aarch64_picreloc" >&5
+$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
+if test $gcc_cv_as_aarch64_picreloc = yes; then
+
+$as_echo "#define HAVE_AS_SPIC_RELOCS 1" >>confdefs.h
+
+fi
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     # Check whether --enable-fix-cortex-a53-835769 was given.
 if test "${enable_fix_cortex_a53_835769+set}" = set; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 85f72d5..fb7dbfb 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3562,6 +3562,13 @@ case "$target" in
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
+    [
+	.text
+	ldr     x0, [[x2, #:gotpage_lo15:globalsym]]
+    ],,[AC_DEFINE(HAVE_AS_SPIC_RELOCS, 1,
+	[Define if your assembler supports relocs needed by -fpic.])])
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     AC_ARG_ENABLE(fix-cortex-a53-835769,
     [

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

* Re: [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler
  2015-06-29 13:07 [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler Jiong Wang
@ 2015-06-30  7:32 ` Andreas Schwab
  2015-06-30  8:46   ` Jiong Wang
  2015-07-01  8:32 ` James Greenhalgh
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2015-06-30  7:32 UTC (permalink / raw)
  To: Jiong Wang; +Cc: gcc-patches

Jiong Wang <jiong.wang@arm.com> writes:

> gcc/
>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>   modifier support.
>   * configure: Regenerate.
>   * config.in: Regenerate.
>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>   -fPIC if not support of -fpic relocation modifier in assembler.

This fixes all testsuite regressions except this one:

gcc.target/aarch64/pic-small.c scan-assembler-times adrp\tx[0-9]+, _GLOBAL_OFFSET_TABLE 2

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler
  2015-06-30  7:32 ` Andreas Schwab
@ 2015-06-30  8:46   ` Jiong Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Jiong Wang @ 2015-06-30  8:46 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Marcus Shawcroft, gcc-patches


Andreas Schwab writes:

> Jiong Wang <jiong.wang@arm.com> writes:
>
>> gcc/
>>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>>   modifier support.
>>   * configure: Regenerate.
>>   * config.in: Regenerate.
>>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>>   -fPIC if not support of -fpic relocation modifier in assembler.
>
> This fixes all testsuite regressions except this one:
>
> gcc.target/aarch64/pic-small.c scan-assembler-times adrp\tx[0-9]+,
> _GLOBAL_OFFSET_TABLE 2

Thanks for testing.

We need another dejagnu check, something like
"check_effective_target_fpic", to restrict this testcase only tested
when -fpic supported.

But the problem is the existed "check_effective_target_fpic" assume if
-fpic not supported, then warning will be issued in compile stage, while
on AArch64, if -fpic is not supported, we will not issue warning, we
just fall back to -fPIC.

What I can think of to fix this is add a new check
"check_effective_target_fpic_asm" which check whether those new
relocation types are supported by binutils, I don't have any other
better idea, and this will be a seperate patch.

So, is this patch OK for trunk?

-- 
Regards,
Jiong

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

* Re: [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler
  2015-06-29 13:07 [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler Jiong Wang
  2015-06-30  7:32 ` Andreas Schwab
@ 2015-07-01  8:32 ` James Greenhalgh
  2015-07-01  8:55   ` [COMMITTED][AArch64] " Jiong Wang
  1 sibling, 1 reply; 5+ messages in thread
From: James Greenhalgh @ 2015-07-01  8:32 UTC (permalink / raw)
  To: Jiong Wang; +Cc: gcc-patches

On Mon, Jun 29, 2015 at 01:42:13PM +0100, Jiong Wang wrote:
> 
> This patch fix the breakage caused by
> 
>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01913.html
> 
> We fall back to -fPIC if there is no assembler support on those new
> relocation modifiers for -fpic.
> 
> OK for trunk?
> 
> gcc/
>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>   modifier support.
>   * configure: Regenerate.
>   * config.in: Regenerate.
>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>   -fPIC if not support of -fpic relocation modifier in assembler.
> -- 
> Regards,
> Jiong

This patch is OK, but please rename

> +#undef HAVE_AS_SPIC_RELOCS

to

  HAVE_AS_SMALL_PIC_RELOCS

It seems clearer to explicitly spell out what feature this relates to.

Thanks,
James

> 

> diff --git a/gcc/config.in b/gcc/config.in
> index 3aee936..476d585 100644
> --- a/gcc/config.in
> +++ b/gcc/config.in
> @@ -606,6 +606,12 @@
>  #endif
>  
>  
> +/* Define if your assembler supports relocs needed by -fpic. */
> +#ifndef USED_FOR_TARGET
> +#undef HAVE_AS_SPIC_RELOCS
> +#endif
> +
> +
>  /* Define if your assembler and linker support thread-local storage. */
>  #ifndef USED_FOR_TARGET
>  #undef HAVE_AS_TLS
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index f130f8d..7e09e3b 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -7581,9 +7581,13 @@ initialize_aarch64_code_model (void)
>  	   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
>  	   break;
>  	 case AARCH64_CMODEL_SMALL:
> +#ifdef HAVE_AS_SPIC_RELOCS
>  	   aarch64_cmodel = (flag_pic == 2
>  			     ? AARCH64_CMODEL_SMALL_PIC
>  			     : AARCH64_CMODEL_SMALL_SPIC);
> +#else
> +	   aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
> +#endif
>  	   break;
>  	 case AARCH64_CMODEL_LARGE:
>  	   sorry ("code model %qs with -f%s", "large",
> diff --git a/gcc/configure b/gcc/configure
> index 3f3f578..b72cde7 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -24228,6 +24228,40 @@ $as_echo "#define HAVE_AS_MABI_OPTION 1" >>confdefs.h
>          done
>        fi
>      fi
> +    # Check if we have binutils support for relocations types needed by -fpic
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic relocs" >&5
> +$as_echo_n "checking assembler for -fpic relocs... " >&6; }
> +if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  gcc_cv_as_aarch64_picreloc=no
> +  if test x$gcc_cv_as != x; then
> +    $as_echo '
> +	.text
> +	ldr     x0, [x2, #:gotpage_lo15:globalsym]
> +    ' > conftest.s
> +    if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
> +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> +  (eval $ac_try) 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; }
> +    then
> +	gcc_cv_as_aarch64_picreloc=yes
> +    else
> +      echo "configure: failed program was" >&5
> +      cat conftest.s >&5
> +    fi
> +    rm -f conftest.o conftest.s
> +  fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_aarch64_picreloc" >&5
> +$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
> +if test $gcc_cv_as_aarch64_picreloc = yes; then
> +
> +$as_echo "#define HAVE_AS_SPIC_RELOCS 1" >>confdefs.h
> +
> +fi
>      # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
>      # Check whether --enable-fix-cortex-a53-835769 was given.
>  if test "${enable_fix_cortex_a53_835769+set}" = set; then :
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 85f72d5..fb7dbfb 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -3562,6 +3562,13 @@ case "$target" in
>          done
>        fi
>      fi
> +    # Check if we have binutils support for relocations types needed by -fpic
> +    gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
> +    [
> +	.text
> +	ldr     x0, [[x2, #:gotpage_lo15:globalsym]]
> +    ],,[AC_DEFINE(HAVE_AS_SPIC_RELOCS, 1,
> +	[Define if your assembler supports relocs needed by -fpic.])])
>      # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
>      AC_ARG_ENABLE(fix-cortex-a53-835769,
>      [

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

* [COMMITTED][AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler
  2015-07-01  8:32 ` James Greenhalgh
@ 2015-07-01  8:55   ` Jiong Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Jiong Wang @ 2015-07-01  8:55 UTC (permalink / raw)
  To: James Greenhalgh; +Cc: Andreas Schwab, gcc-patches

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


James Greenhalgh writes:

> On Mon, Jun 29, 2015 at 01:42:13PM +0100, Jiong Wang wrote:
>> 
>> This patch fix the breakage caused by
>> 
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01913.html
>> 
>> We fall back to -fPIC if there is no assembler support on those new
>> relocation modifiers for -fpic.
>> 
>> OK for trunk?
>> 
>> gcc/
>>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>>   modifier support.
>>   * configure: Regenerate.
>>   * config.in: Regenerate.
>>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>>   -fPIC if not support of -fpic relocation modifier in assembler.
>> -- 
>> Regards,
>> Jiong
>
> This patch is OK, but please rename
>
>> +#undef HAVE_AS_SPIC_RELOCS
>
> to
>
>   HAVE_AS_SMALL_PIC_RELOCS
>
> It seems clearer to explicitly spell out what feature this relates to.

Thanks, commited below patch as 225231.


[-- Attachment #2: k.txt --]
[-- Type: text/plain, Size: 3421 bytes --]

Index: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c	(revision 225228)
+++ gcc/config/aarch64/aarch64.c	(working copy)
@@ -7581,9 +7581,13 @@
 	   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
 	   break;
 	 case AARCH64_CMODEL_SMALL:
+#ifdef HAVE_AS_SMALL_PIC_RELOCS
 	   aarch64_cmodel = (flag_pic == 2
 			     ? AARCH64_CMODEL_SMALL_PIC
 			     : AARCH64_CMODEL_SMALL_SPIC);
+#else
+	   aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+#endif
 	   break;
 	 case AARCH64_CMODEL_LARGE:
 	   sorry ("code model %qs with -f%s", "large",
Index: gcc/config.in
===================================================================
--- gcc/config.in	(revision 225228)
+++ gcc/config.in	(working copy)
@@ -606,6 +606,12 @@
 #endif
 
 
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SMALL_PIC_RELOCS
+#endif
+
+
 /* Define if your assembler and linker support thread-local storage. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_TLS
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 225228)
+++ gcc/configure	(working copy)
@@ -24228,6 +24228,40 @@
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic relocs" >&5
+$as_echo_n "checking assembler for -fpic relocs... " >&6; }
+if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_aarch64_picreloc=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '
+	.text
+	ldr     x0, [x2, #:gotpage_lo15:globalsym]
+    ' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_aarch64_picreloc=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_aarch64_picreloc" >&5
+$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
+if test $gcc_cv_as_aarch64_picreloc = yes; then
+
+$as_echo "#define HAVE_AS_SMALL_PIC_RELOCS 1" >>confdefs.h
+
+fi
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     # Check whether --enable-fix-cortex-a53-835769 was given.
 if test "${enable_fix_cortex_a53_835769+set}" = set; then :
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 225228)
+++ gcc/configure.ac	(working copy)
@@ -3562,6 +3562,13 @@
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
+    [
+	.text
+	ldr     x0, [[x2, #:gotpage_lo15:globalsym]]
+    ],,[AC_DEFINE(HAVE_AS_SMALL_PIC_RELOCS, 1,
+	[Define if your assembler supports relocs needed by -fpic.])])
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     AC_ARG_ENABLE(fix-cortex-a53-835769,
     [

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

end of thread, other threads:[~2015-07-01  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-29 13:07 [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler Jiong Wang
2015-06-30  7:32 ` Andreas Schwab
2015-06-30  8:46   ` Jiong Wang
2015-07-01  8:32 ` James Greenhalgh
2015-07-01  8:55   ` [COMMITTED][AArch64] " Jiong Wang

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