From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id A8FE43858CD1 for ; Sat, 27 Apr 2024 00:34:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8FE43858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A8FE43858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714178059; cv=none; b=xUeKkq50CCiu3ZHY4EJ9U0ny2XAYjXmEBJe7fAGBcfax54SOv3lE+IAw0ZJjMMNhQn+7UAcjQrDV4S+Yr/06Tm4gXs4AZjghhxKBUbAdysPes+HsGAy4Y8ZzH7Vsjlf7mRj4WFg+sZ0wW3/OnrDJYRzsmCZONnWAoOhI6CHWCWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714178059; c=relaxed/simple; bh=jIHdpHpTJhr/6SfBzXwf83NBAxakeZr7estopjp9khI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=TrB30Q5CT5Pf3QE7n4EpX2Lfc905qrj9+wpAJh8uyZ9QUXDMFpc6GQ9KwE4xspEcqUQKwtqz/5TwKRv9SK5E0sTeO3ign12MqZoJ/CnE0m0La5lyNPXE/gxTbg4i9X2rW66Rm16em/kZ6aGcoD84I9I8oJJ8gUQ6KEgTJ/zGn84= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso1996823a12.3 for ; Fri, 26 Apr 2024 17:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1714178056; x=1714782856; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PyOX6vT+ZZMe9US0q+LNz168pqh2aybItT6dxfTC5lU=; b=IFIOb1mfPv/3e8lcjwSyMHin8FGS8Ii9JC6Y4MmAaIpYU4OyM8UyOHCZV6645cxm4R jxE+1yPwEOJUd/31OaQQ/VwAZ/p3I9BVwXvgtWaedR2+xgmBDRuLmREfI/4hM9R8hLTW bvzOFVjAwDBbTR+0n9cwijn29R/KYVvE9MCbtr1rwv7lo/0Bs2olMrG6IMF3bxIeYQh1 tpikaHVpw5MB7U+G9ppwoKmFi/HseI152RWeD/zY2r1iytoUw+Feu0mQA/Ge81siNxhx 38rg/3BwUP4aahQ4oA/AIiZCf1IC4ZCfDKaez8rqZE1mxBL1rSl+YEQdUxoLzpjjm0HW bDWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714178056; x=1714782856; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PyOX6vT+ZZMe9US0q+LNz168pqh2aybItT6dxfTC5lU=; b=dx7bhYsavO9qmGW2WoyiuLewm6N8/HKGkP78v0MZeBveP9bAK0xZXCgvd8pZRws+S1 V8yF+NR6OVq9fqwZg6uDVjFGwPePPlqdiryx8J14WcmplgbgCaMAbZxD2wsRI7B8tXzi KbpFxMchbNstzOBpfzvtemgV57SRzEg6zOMqgMtrFguQTobYXlsCUHes0OZFDXBz8jR7 ouRsQZmIEEVgLX5HU+/1b5vZZvrDe/oU8TTFVG+udFggvBBSkJP+7eXmIPt5o39mFllR Cb0lqZQcnVHn1Q61odwGvCVhCl2DVIuG0dfgV/9R4gJA/ziKMqB7aB7WmBKKBVY/vDoF PdqQ== X-Gm-Message-State: AOJu0Yxn9JbBc9Fn4+VtMchmK3jheULnbfTRwaqAbxp6YQKecMyTuxTR BepstnpP6hkZsBzQY4k0IccfLUsrKrAoAUVjCRCrsFGEwjbQ/XoxzHjQlPFHDewPU26IE5CZz8o sW76FfANSkKa9xKNdotPWrOsvSZB4jofj0CX/HQ== X-Google-Smtp-Source: AGHT+IG7c4NNSDnXMRfVI98OjJeLJfLUk4Y6/mIxJwEB/waes8078LBN/pzogZoUTXoCmwl6vTM+RHWq1EIkY3V47uw= X-Received: by 2002:a17:90b:1085:b0:2a7:d810:2f5e with SMTP id gj5-20020a17090b108500b002a7d8102f5emr4183880pjb.48.1714178056277; Fri, 26 Apr 2024 17:34:16 -0700 (PDT) MIME-Version: 1.0 References: <20240423042745.3324538-1-maskray@google.com> In-Reply-To: <20240423042745.3324538-1-maskray@google.com> From: Kito Cheng Date: Sat, 27 Apr 2024 08:34:04 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Add -X to link spec To: Fangrui Song Cc: GCC Patches , Fangrui Song Content-Type: multipart/alternative; boundary="000000000000206cf30617092e94" X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: --000000000000206cf30617092e94 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable LGTM :) Fangrui Song =E6=96=BC 2024=E5=B9=B44=E6=9C=8823=E6=97= =A5 =E9=80=B1=E4=BA=8C 12:27 =E5=AF=AB=E9=81=93=EF=BC=9A > 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 > > --000000000000206cf30617092e94--