RISC-V: allow -fno-plt to disable PLT

Message ID tencent_49B8BD311D21298D067C92824DDA648E3D08@qq.com
State Superseded
Headers
Series RISC-V: allow -fno-plt to disable PLT |

Checks

Context Check Description
rivoscibot/toolchain-ci-rivos-apply-patch success Patch applied
rivoscibot/toolchain-ci-rivos-lint success Lint passed
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gc-lp64d-non-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc-lp64d-non-multilib success Build passed
rivoscibot/toolchain-ci-rivos-test success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Yangyu Chen Oct. 31, 2024, 5:35 a.m. UTC
  Currently, the RISC-V target uses the target specific mplt option to
control PLT generation. This patch deprecates the target specific mplt
option and uses the common fplt option instead. This allows users to
use the same option for most targets. Since both fplt and mplt are
initialized to 1, it's safe to use logical and to combine them.

Co-Developed-by: Liao Shihua <shihua@iscas.ac.cn>
Signed-off-by: Yangyu Chen <cyy@cyyself.name>

gcc/ChangeLog:

	* config/riscv/predicates.md: deprecates mplt option.
	* config/riscv/riscv.opt: allow -fno-plt to disable PLT.
---
 gcc/config/riscv/predicates.md | 3 ++-
 gcc/config/riscv/riscv.opt     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Kito Cheng Oct. 31, 2024, 8:02 a.m. UTC | #1
Thanks, just one minor comment: could you just make it become an alias
of -fplt (e.g. "Alias(fplt)") and just check flag_plt?

On Thu, Oct 31, 2024 at 1:35 PM Yangyu Chen <cyy@cyyself.name> wrote:
>
> Currently, the RISC-V target uses the target specific mplt option to
> control PLT generation. This patch deprecates the target specific mplt
> option and uses the common fplt option instead. This allows users to
> use the same option for most targets. Since both fplt and mplt are
> initialized to 1, it's safe to use logical and to combine them.
>
> Co-Developed-by: Liao Shihua <shihua@iscas.ac.cn>
> Signed-off-by: Yangyu Chen <cyy@cyyself.name>
>
> gcc/ChangeLog:
>
>         * config/riscv/predicates.md: deprecates mplt option.
>         * config/riscv/riscv.opt: allow -fno-plt to disable PLT.
> ---
>  gcc/config/riscv/predicates.md | 3 ++-
>  gcc/config/riscv/riscv.opt     | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
> index 9971fabc587..a48b4aa9534 100644
> --- a/gcc/config/riscv/predicates.md
> +++ b/gcc/config/riscv/predicates.md
> @@ -329,7 +329,8 @@
>  {
>    enum riscv_symbol_type type;
>    return (riscv_symbolic_constant_p (op, &type)
> -         && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op) && TARGET_PLT);
> +         && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op)
> +         && TARGET_PLT && flag_plt);
>  })
>
>  (define_predicate "call_insn_operand"
> diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
> index 6360ed3984d..3ac54017337 100644
> --- a/gcc/config/riscv/riscv.opt
> +++ b/gcc/config/riscv/riscv.opt
> @@ -35,7 +35,7 @@ Target RejectNegative Joined UInteger Var(riscv_branch_cost)
>
>  mplt
>  Target Var(TARGET_PLT) Init(1)
> -When generating -fpic code, allow the use of PLTs. Ignored for fno-pic.
> +This option is deprecated; use -fplt or -fno-plt instead.
>
>  mabi=
>  Target RejectNegative Joined Enum(abi_type) Var(riscv_abi) Init(ABI_ILP32) Negative(mabi=)
> --
> 2.45.2
>
  

Patch

diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
index 9971fabc587..a48b4aa9534 100644
--- a/gcc/config/riscv/predicates.md
+++ b/gcc/config/riscv/predicates.md
@@ -329,7 +329,8 @@ 
 {
   enum riscv_symbol_type type;
   return (riscv_symbolic_constant_p (op, &type)
-	  && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op) && TARGET_PLT);
+	  && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op)
+	  && TARGET_PLT && flag_plt);
 })
 
 (define_predicate "call_insn_operand"
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index 6360ed3984d..3ac54017337 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -35,7 +35,7 @@  Target RejectNegative Joined UInteger Var(riscv_branch_cost)
 
 mplt
 Target Var(TARGET_PLT) Init(1)
-When generating -fpic code, allow the use of PLTs. Ignored for fno-pic.
+This option is deprecated; use -fplt or -fno-plt instead.
 
 mabi=
 Target RejectNegative Joined Enum(abi_type) Var(riscv_abi) Init(ABI_ILP32) Negative(mabi=)