From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 0458C3858D20 for ; Mon, 22 May 2023 05:40:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0458C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1684734023; bh=sL2HTAwUshbaKbc5Fad8nYEOoGHv1CiPSUda+msYJl0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=JPyEKRe61nK6LyChwpTtnmGlvs/PALtK+fuBvNeaTrUfrHw9lC6ejhKaUF+5UXzM/ UmJx6N3ePZxo60JG+d251Ey+U4Ud9W7weX2F4VWvTTzx/X+e8LC6kOUBDJjk2xLT+h Y6jUfgpipFayAuBvnNljGVmdmwXg/mlNaV889iwc= Received: from [IPv6:240e:358:114f:a600:dc73:854d:832e:5] (unknown [IPv6:240e:358:114f:a600:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0ADE365A04; Mon, 22 May 2023 01:40:14 -0400 (EDT) Message-ID: <3d26b5ef4aa4ec462c3232a21527424b933dd70a.camel@xry111.site> Subject: Re: [PATCH v4 0/6] LoongArch linker relaxation support. From: Xi Ruoyao To: mengqinggang , binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, i.swmail@xen0n.name, maskray@google.com Date: Mon, 22 May 2023 13:40:02 +0800 In-Reply-To: <20230522013441.3074776-1-mengqinggang@loongson.cn> References: <20230522013441.3074776-1-mengqinggang@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.1 MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_INFOUSMEBIZ,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 2023-05-22 at 09:34 +0800, mengqinggang wrote: > This is the v4 version of patches to support loongarch linker relax. > This version mainly rebase to the master branch. >=20 > The binutils, gcc, glibc and Spec2006 testcases is ok. Have you tried the kernel and GRUB? AFAIK they are the most "fragile" package regarding to this kind of optimization. The RISC-V port of them uses -mno-relax. > Now, only the instrunctions expand from macro (la.local, la.global, etc.)= at=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > assembly time can be relaxed, because gcc instruction scheduling causes r= elax=C2=A0=C2=A0=20 > unable to handle some special cases. Gcc can add -mno-explicit-relocs opt= ion=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > to generate macro instrunction. I guess -fsection-anchors (enabled by default with any optimization level but -O0) can also affect. Maybe we should change GCC to use -mno- explicit-relocs and maybe -fno-section-anchors for -Os then. For -O1/- O2/-O3 the benefit of scheduling is more important on a modern CPU. > There are two code sequence can be relaxed in LoongArch. The first one=C2= =A0=20 > is "pcala12i + addi.d", which can be relaxed to pcaddi. Another one is=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > "pcalau12i + ld.d", which can be relaxed to "pcalau12i + addi.d". And it = can be=C2=A0=20 > relaxed to pcaddi one more time. Pcaddi instrunction can address a signed= 22=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > bits 4-byte alinged offset relative to pc.=20 >=20 > In the future, the TLS LE code sequence and function call in medium > code mode would be relaxed too. >=20 > For .align directive, some small problems cannot be perfectly solved (see > http://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxatio= n). > >=20 > The new relocs document at here: > =C2=A0 https://github.com/loongson/LoongArch-Documentation/pull/77 But the repo is archived so any PR in it should be considered dead. May I "hijack" the discussion to ask the rationale about archiving it? Note that if you want to mean "it's stable and should not be changed w/o a major update" you should create a tag and release instead of archiving it. Archiving basically mean "the repo is dead or moved elsewhere". --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University