public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Fangrui Song <maskray@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r15-10] RISC-V: Add -X to link spec
Date: Sat, 27 Apr 2024 01:14:36 +0000 (GMT)	[thread overview]
Message-ID: <20240427011436.133113858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:50c218e3ffe57860591a987ecf44fcc0abb31f2c

commit r15-10-g50c218e3ffe57860591a987ecf44fcc0abb31f2c
Author: Fangrui Song <maskray@gcc.gnu.org>
Date:   Fri Apr 26 18:14:33 2024 -0700

    RISC-V: Add -X to link spec
    
    --discard-locals (-X) instructs the linker to remove local .L* symbols,
    which occur a lot due to label differences for linker relaxation. The
    arm port has a similar need and passes -X to ld.
    
    In contrast, the RISC-V port does not pass -X to ld and rely on the
    default --discard-locals in GNU ld's riscv port. The arm way is more
    conventional (compiler driver instead of the linker customizes the
    default linker behavior) and works with lld.
    
    gcc/ChangeLog:
    
            * config/riscv/elf.h (LINK_SPEC): Add -X.
            * config/riscv/freebsd.h (LINK_SPEC): Add -X.
            * config/riscv/linux.h (LINK_SPEC): Add -X.

Diff:
---
 gcc/config/riscv/elf.h     | 1 +
 gcc/config/riscv/freebsd.h | 1 +
 gcc/config/riscv/linux.h   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h
index f533764d9f8..c97f13c0cca 100644
--- a/gcc/config/riscv/elf.h
+++ b/gcc/config/riscv/elf.h
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared}"
diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h
index bd08a985285..5dd4d51c42b 100644
--- a/gcc/config/riscv/freebsd.h
+++ b/gcc/config/riscv/freebsd.h
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}	\
   %{v:-V}							\
   %{assert*} %{R*} %{rpath*} %{defsym*}				\
+  -X								\
   %{mbig-endian:-EB}						\
   %{mlittle-endian:-EL}						\
   %{shared:-Bshareable %{h*} %{soname*}}			\
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 15851f653bc..3c356227134 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared} \

                 reply	other threads:[~2024-04-27  1:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240427011436.133113858C50@sourceware.org \
    --to=maskray@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).