]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Don't default to -mno-explicit-relocs if -mno-relax
authorXi Ruoyao <xry111@xry111.site>
Thu, 22 Feb 2024 09:58:45 +0000 (17:58 +0800)
committerXi Ruoyao <xry111@xry111.site>
Fri, 23 Feb 2024 10:11:49 +0000 (18:11 +0800)
To improve Binutils compatibility we've had to backport relaxation
support.  But if a user just updates to GCC 13.3 and sticks with
Binutils 2.41, there is no reason to use -mno-explicit-relocs as the
default because we are turning off relaxation for Binutils 2.41 (it
lacks conditional branch relaxation support) anyway.

So like GCC 14, make the default of -m[no-]explicit-relocs depend on
-m[no-]relax instead of HAVE_AS_MRELAX_OPTION.  Also update the doc to
reflect the behavior change.

gcc/ChangeLog:

* config/loongarch/genopts/loongarch.opt.in
(TARGET_EXPLICIT_RELOCS): Init to M_OPTION_NOT_SEEN.
* config/loongarch/loongarch.opt: Regenerate.
* config/loongarch/loongarch.cc
(loongarch_option_override_internal): Set the default of
TARGET_EXPLICIT_RELOCS to HAVE_AS_EXPLICIT_RELOCS
&& !loongarch_mrelax.
* doc/invoke.texi (-m[no-]explicit-relocs): Update for
LoongArch.

gcc/config/loongarch/genopts/loongarch.opt.in
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.opt
gcc/doc/invoke.texi

index da6fedd153efbe14dec15552bf43c242ec90ff76..76acd35d39c3950f39be4bf8af1fc6078cdc950a 100644 (file)
@@ -155,7 +155,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init
 -mmax-inline-memcpy-size=SIZE  Set the max size of memcpy to inline, default is 1024.
 
 mexplicit-relocs
-Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION)
+Target Var(TARGET_EXPLICIT_RELOCS) Init(M_OPTION_NOT_SEEN)
 Use %reloc() assembly operators.
 
 ; The code model option names for -mcmodel.
index 768e2427285ceaee468e3d3cb9edc459a6540d02..e78b81cd8fcc54de77b84cf9a7392d5b7e008860 100644 (file)
@@ -6222,6 +6222,10 @@ loongarch_option_override_internal (struct gcc_options *opts)
        gcc_unreachable ();
     }
 
+  if (TARGET_EXPLICIT_RELOCS == M_OPTION_NOT_SEEN)
+    TARGET_EXPLICIT_RELOCS = (HAVE_AS_EXPLICIT_RELOCS
+                             && !loongarch_mrelax);
+
   /* Validate the guard size.  */
   int guard_size = param_stack_clash_protection_guard_size;
 
index 59b1e06d3f2040f93c25656af7c5b92952e82a59..e61fbaed2c1f04b05b48d9838dd001a945ef3793 100644 (file)
@@ -162,7 +162,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init
 -mmax-inline-memcpy-size=SIZE  Set the max size of memcpy to inline, default is 1024.
 
 mexplicit-relocs
-Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION)
+Target Var(TARGET_EXPLICIT_RELOCS) Init(M_OPTION_NOT_SEEN)
 Use %reloc() assembly operators.
 
 ; The code model option names for -mcmodel.
index 99657fb44d86a4ba1532cd35169f1d50e44ae805..792ce283bb989ce738a8d569ff288bfb2111e4c6 100644 (file)
@@ -25830,12 +25830,11 @@ The default code model is @code{normal}.
 @itemx -mno-explicit-relocs
 Use or do not use assembler relocation operators when dealing with symbolic
 addresses.  The alternative is to use assembler macros instead, which may
-limit optimization.  The default value for the option is determined during
-GCC build-time by detecting corresponding assembler support:
-@code{-mexplicit-relocs} if said support is present,
-@code{-mno-explicit-relocs} otherwise.  This option is mostly useful for
-debugging, or interoperation with assemblers different from the build-time
-one.
+limit instruction scheduling but allow linker relaxation.  The default
+value for the option is determined with the assembler capability detected
+during GCC build-time and the setting of @code{-mrelax}:
+@code{-mexplicit-relocs} if the assembler supports relocation operators
+but @code{-mrelax} is not enabled, @code{-mno-explicit-relocs} otherwise.
 
 @opindex mdirect-extern-access
 @item -mdirect-extern-access