James Greenhalgh writes:

> On Tue, Jun 30, 2015 at 03:17:00PM +0100, Jiong Wang wrote:
>> 
>> As discussed here
>> 
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02151.html,
>> 
>> Since have enabled binutils feature detection when configuring gcc,
>> -fpic will not be enabled if there is no binutils support on those new
>> relocation modifiers, thus we should update the testcase pic-small.c,
>> only run it if check_effective_target_aarch64_small_fpic is true.
>> 
>> On AArch64, if -fpic is not supported, then we will fall back to -fPIC
>> silently.  So, we can't rely on the existed "check_effective_target_fpic" as
>> it assume compiler will give warning if -fpic not supported.  Here we
>> check whether binutils support those new -fpic relocation modifiers, and
>> assume -fpic is supported if there is binutils support, as gcc
>> configuration will enable -fpic for AArch64 on such case. This will not
>> apply if the test system is with new binutils and old gcc which is rare
>> and this patch will not handle.
>> 
>> OK for trunk?
>
> OK, with a couple of very minor changes in the documentation/comments.

Thanks. Committed patch below as 225232.

Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi    (revision 225230)
+++ gcc/doc/sourcebuild.texi    (working copy)
@@ -1580,6 +1580,15 @@
 
 @end table
 
+@subsubsection AArch64-specific attributes
+
+@table @code
+@item aarch64_small_fpic
+Binutils installed on test system supports relocation types required by -fpic
+for AArch64 small memory model.
+
+@end table
+
 @subsubsection MIPS-specific attributes
 
 @table @code
Index: gcc/testsuite/gcc.target/aarch64/pic-small.c
===================================================================
--- gcc/testsuite/gcc.target/aarch64/pic-small.c        (revision 225230)
+++ gcc/testsuite/gcc.target/aarch64/pic-small.c        (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target aarch64_small_fpic } */
 /* { dg-options "-O2 -fpic -fno-inline --save-temps" } */
 
 void abort ();
Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp       (revision 225230)
+++ gcc/testsuite/lib/target-supports.exp       (working copy)
@@ -937,6 +937,26 @@
     return 0
 }
 
+# On AArch64, if -fpic is not supported, then we will fall back to -fPIC
+# silently.  So, we can't rely on above "check_effective_target_fpic" as it
+# assumes compiler will give warning if -fpic not supported.  Here we check
+# whether binutils supports those new -fpic relocation modifiers, and assume
+# -fpic is supported if there is binutils support.  GCC configuration will
+# enable -fpic for AArch64 in this case.
+#
+# "check_effective_target_aarch64_small_fpic" is dedicated for checking small
+# memory model -fpic relocation types.
+
+proc check_effective_target_aarch64_small_fpic { } {
+    if { [istarget aarch64*-*-*] } {
+       return [check_no_compiler_messages aarch64_small_fpic object {
+           void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
+       }]
+    } else {
+       return 0
+    }
+}
+
 # Return 1 if -shared is supported, as in no warnings or errors
 # emitted, 0 otherwise.
 

Reply via email to