public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: chenglulu <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, gcc-patches@gcc.gnu.org
Cc: i@xen0n.name, xuchenghua@loongson.cn
Subject: Re: [GCC 13 PATCH] LoongArch: Don't default to -mno-explicit-relocs if -mno-relax
Date: Thu, 22 Feb 2024 19:09:41 +0800	[thread overview]
Message-ID: <dc59e4aa-cd42-7681-507c-ea8835108802@loongson.cn> (raw)
In-Reply-To: <20240222102121.180635-1-xry111@xry111.site>


在 2024/2/22 下午6:20, Xi Ruoyao 写道:
> To improve Binutils compatibility we've had to backported 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.
> ---
>
> Ok for releases/gcc-13?

LGTM!

Thanks!

>
>   gcc/config/loongarch/genopts/loongarch.opt.in |  2 +-
>   gcc/config/loongarch/loongarch.cc             |  4 ++++
>   gcc/config/loongarch/loongarch.opt            |  2 +-
>   gcc/doc/invoke.texi                           | 11 +++++------
>   4 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in
> index da6fedd153e..76acd35d39c 100644
> --- a/gcc/config/loongarch/genopts/loongarch.opt.in
> +++ b/gcc/config/loongarch/genopts/loongarch.opt.in
> @@ -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.
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 768e2427285..e78b81cd8fc 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -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;
>   
> diff --git a/gcc/config/loongarch/loongarch.opt b/gcc/config/loongarch/loongarch.opt
> index 59b1e06d3f2..e61fbaed2c1 100644
> --- a/gcc/config/loongarch/loongarch.opt
> +++ b/gcc/config/loongarch/loongarch.opt
> @@ -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.
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 99657fb44d8..792ce283bb9 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -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


  reply	other threads:[~2024-02-22 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 10:20 Xi Ruoyao
2024-02-22 11:09 ` chenglulu [this message]
2024-02-23 10:26   ` Pushed: " Xi Ruoyao

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=dc59e4aa-cd42-7681-507c-ea8835108802@loongson.cn \
    --to=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /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).