From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7814) id 133113858C50; Sat, 27 Apr 2024 01:14:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 133113858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714180476; bh=5OKeKB4+PtZuRq6GCTPH1zjKJZ2UyIKjYUj0sCXaXYo=; h=From:To:Subject:Date:From; b=QqfG0mQfpuFQKSc04zHvM58/lyR5KAKybX5ilZPE8CmIWv2hEmTKth0SxsIFF+TnC Y1r+v36NpoUnaYHPdASmyw9+dyX9t9IymUDWmxe9daaEQ/FfF/cf9+ocWrls/qrnvU 2ui4WikRWDuLXiVW/9eE3RftJtXVXCoSTS2sOpck= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Fangrui Song To: gcc-cvs@gcc.gnu.org Subject: [gcc r15-10] RISC-V: Add -X to link spec X-Act-Checkin: gcc X-Git-Author: Fangrui Song X-Git-Refname: refs/heads/master X-Git-Oldrev: 2781d8090e66f1e60bedb597e9472d1bc0a9df19 X-Git-Newrev: 50c218e3ffe57860591a987ecf44fcc0abb31f2c Message-Id: <20240427011436.133113858C50@sourceware.org> Date: Sat, 27 Apr 2024 01:14:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:50c218e3ffe57860591a987ecf44fcc0abb31f2c commit r15-10-g50c218e3ffe57860591a987ecf44fcc0abb31f2c Author: Fangrui Song 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} \