From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by sourceware.org (Postfix) with ESMTPS id DD2F33858D35 for ; Tue, 23 Apr 2024 04:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD2F33858D35 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=flex--maskray.bounces.google.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DD2F33858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1149 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713846472; cv=none; b=RNl9lIdoZP/HRWi61ksXx8sLroQUrQdrVJt21YQefDsPhsvdvqWEeRUC/PuhWCanqCWEgDd2IeM+oHXTIaRD/XFj2ukOn+4rV5jrobzSxHkf0Q/q0sAtXpolic3E9RFygAxmY/7VZknvXeuxqprcsqqN6Owx9bnUvnagmjM0nNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713846472; c=relaxed/simple; bh=YzjSxs0xJCGamjLJCyCar7ZddkWHcWOvk9ezUPeYwO0=; h=DKIM-Signature:Date:Mime-Version:Message-ID:Subject:From:To; b=mZVf5kKOrBZnT8SsclXh7HFGD+sLek0PBpZSoIZTp7BnYfCB1iQ+LDTvMPOsdV8IKwb1I7qGReyYEABvt7iBCgY32vc+1Arjg6jkbIIhNxhrLuHVZTi0qi7EkALbz2G1uedl8Z5a5q3xsuEujq2/9PX5oDiNlqggjrGCF9XPcUo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6183c4a6d18so94256417b3.3 for ; Mon, 22 Apr 2024 21:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713846470; x=1714451270; darn=gcc.gnu.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=fWbgH3dwqZsh3tJdISEz7vaFqJs2kpxRxcTna0hEwTU=; b=sTokL9gfM8CElOkVJXkFhJpsGDlrk3oz9Y1YLRvUUgqT1tnAnkcFhN8kp8O4v0Al/4 FhT3MHtkwpnWezS9tQq6VFkE0odoBi2CZylxRFLioe/Js8UX+4lMJ0f9u7ne8MmZH0on BEuOC3WOCKulzIi7Hz+uQuzGZcU2M6IydRsM1LwozxZmvIpNsgggv3pNP342khWMAYog 2wbQjQWNyiiGn2QQtFm1T008conAVhWMLHuEQYT0ofApHdkEwyx4ihd4ONfpZ3DmmJNQ 6p53/pYk4fkiACbhxz0hRdCIWYgpt1SDBIQWsbSDBnkWch4NLKkV8/kBCMXi4iiXTB7j Y4IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713846470; x=1714451270; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fWbgH3dwqZsh3tJdISEz7vaFqJs2kpxRxcTna0hEwTU=; b=IZh3Sp/VXJv7tAyYdZnDS4RivPnEObZU2yPqRys//grAdsEdxkAVwXG25UwnRlqRB7 0SQyzDUEO8nq2SkhY/VHy8YC2OOF5jumFp1A5P8J9BftbXWdghCmT70dHgKHwMTLSGYK zxpCVBFyl/uLXdj/Ar4ADcL6x7sP7ET41QRaLz5AKhMymGRnmqybKJOYO73sMs1hOWza HuipdLBpXXDZKquS5ty7XwAA9gQnpB24WEsknhuG0z2Dxb+un9952oqPfIz/v6CU7ee4 wVtrCn5zC9JjSUap+PK1vmHPoHhGiwAt19AloM4UYuG8xaX6Ianm3Hb6Dm6McvYJeG1z 3NrQ== X-Forwarded-Encrypted: i=1; AJvYcCWoD8Fc3DznO4uuw+uTGkkDkZEs0zb3i1WYc/1uQ1YlKwIjZyWfZcuprWoISvwPjcdJEwk0qsa2HwCI7jcMkJYshvPjrSkS6g== X-Gm-Message-State: AOJu0YwnhKsKkSFwZyzIJn80sRxaP6s2Y9yMTNT4X5d7zDhk2RLawHAs yfzLvpQ/irn0p6qC/1a1lJ4RN7jyi85zdhnT7CzF7W4zidlILj/opmxEXPmU+7eVTqQrPD3yfNG Kw4RNng== X-Google-Smtp-Source: AGHT+IExKBTDlyRWWVpNRnVhO07cFIBZRWHggJkrw/bk5/+0Alw30N545H34NzhWX2inGTZGT+02Q6JkMoUC X-Received: from maskray.svl.corp.google.com ([2620:15c:2d3:205:2f0d:10b6:5331:fd08]) (user=maskray job=sendgmr) by 2002:a81:a1d2:0:b0:61a:bdb1:896e with SMTP id y201-20020a81a1d2000000b0061abdb1896emr1748241ywg.5.1713846470242; Mon, 22 Apr 2024 21:27:50 -0700 (PDT) Date: Mon, 22 Apr 2024 21:27:45 -0700 Mime-Version: 1.0 Message-ID: <20240423042745.3324538-1-maskray@google.com> Subject: [PATCH] RISC-V: Add -X to link spec From: Fangrui Song To: Kito Cheng , gcc-patches@gcc.gnu.org Cc: Fangrui Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-19.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Fangrui Song --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