* [PATCH] RISC-V: Add -X to link spec
@ 2024-04-23 4:27 Fangrui Song
2024-04-27 0:34 ` Kito Cheng
0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song @ 2024-04-23 4:27 UTC (permalink / raw)
To: Kito Cheng, gcc-patches; +Cc: Fangrui Song
From: Fangrui Song <maskray@gcc.gnu.org>
--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 behavior) and works with lld.
---
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} \
--
2.44.0.769.g3c40516874-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] RISC-V: Add -X to link spec
2024-04-23 4:27 [PATCH] RISC-V: Add -X to link spec Fangrui Song
@ 2024-04-27 0:34 ` Kito Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Kito Cheng @ 2024-04-27 0:34 UTC (permalink / raw)
To: Fangrui Song; +Cc: GCC Patches, Fangrui Song
[-- Attachment #1: Type: text/plain, Size: 2426 bytes --]
LGTM :)
Fangrui Song <maskray@google.com> 於 2024年4月23日 週二 12:27 寫道:
> From: Fangrui Song <maskray@gcc.gnu.org>
>
> --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 behavior) and works with lld.
> ---
> 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} \
> --
> 2.44.0.769.g3c40516874-goog
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-27 0:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 4:27 [PATCH] RISC-V: Add -X to link spec Fangrui Song
2024-04-27 0:34 ` Kito Cheng
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).