public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: chenglulu <chenglulu@loongson.cn>, gcc-patches@gcc.gnu.org
Cc: i@xen0n.name, xuchenghua@loongson.cn,
	mengqinggang <mengqinggang@loongson.cn>
Subject: Re: [PATCH 2/5] LoongArch: Use explicit relocs for GOT access when -mexplicit-relocs=auto and LTO during a final link with linker plugin
Date: Sat, 21 Oct 2023 16:42:07 +0800	[thread overview]
Message-ID: <d2595d9516d49afa15db789891b4c23525c65df1.camel@xry111.site> (raw)
In-Reply-To: <0a7f962f-8a2b-d6e3-1e32-3675c13abefe@loongson.cn>

On Sat, 2023-10-21 at 15:32 +0800, chenglulu wrote:
> > +  /* If we are performing LTO for a final link, and we have the linker
> > +     plugin so we know the resolution of the symbols, then all GOT
> > +     references are binding to external symbols or preemptable symbols.
> > +     So the linker cannot relax them.  */
> > +  return (in_lto_p
> > +	  && !flag_incremental_link
> 
> I don’t quite understand this condition "!flag_incremental_link". Can 
> you explain it? Others LGTM.
> 
> Thanks.

If we have two (or several) .o files containing LTO bytecode, GCC
supports "LTO incremental linking" with:

gcc a.o b.o -o ab.o -O2 -flto -flinker-output=nolto-rel

The resulted ab.o will include data and code in a.o and b.o, but it
contains machine code instead of LTO bytecode.  Now if ab.o refers to an
external symbol c, the linker may relax "la.global c" to "la.local c"
(if ab.o is linked together with another file c.o which contains the
definition of c) or not.  As we cannot exclude the possibility of a
relaxation on la.global for incremental linking, just emit la.global and
let the linker to do the correct thing.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-10-21  8:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 14:02 [PATCH 0/5] LoongArch: Better balance between relaxation and scheduling Xi Ruoyao
2023-10-19 14:02 ` [PATCH 1/5] LoongArch: Add enum-style -mexplicit-relocs= option Xi Ruoyao
2023-10-19 14:02 ` [PATCH 2/5] LoongArch: Use explicit relocs for GOT access when -mexplicit-relocs=auto and LTO during a final link with linker plugin Xi Ruoyao
2023-10-21  7:32   ` chenglulu
2023-10-21  8:42     ` Xi Ruoyao [this message]
2023-10-23  0:56       ` chenglulu
2023-10-19 14:02 ` [PATCH 3/5] LoongArch: Use explicit relocs for TLS access with -mexplicit-relocs=auto Xi Ruoyao
2023-10-19 14:02 ` [PATCH 4/5] LoongArch: Use explicit relocs for addresses only used for one load or store with -mexplicit-relocs=auto and -mcmodel={normal,medium} Xi Ruoyao
2023-10-19 14:03 ` [PATCH 5/5] LoongArch: Document -mexplicit-relocs={auto,none,always} Xi Ruoyao
2023-10-23  7:34 ` Pushed: [PATCH 0/5] LoongArch: Better balance between relaxation and scheduling Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2595d9516d49afa15db789891b4c23525c65df1.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=mengqinggang@loongson.cn \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).