public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	Wilco Dijkstra via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default
Date: Tue, 20 Sep 2022 15:02:33 -0700	[thread overview]
Message-ID: <20220920220233.wmj5dossqk2k6dbj@google.com> (raw)
In-Reply-To: <AS4PR08MB79019A23A4122594A16FB66B834C9@AS4PR08MB7901.eurprd08.prod.outlook.com>


On 2022-09-20, Wilco Dijkstra wrote:
>Hi Florian,
>
>>> Well if changing the default of fPIC is unacceptable in GCC, adding a
>>> new option should help LLVM too since it could imply more than
>>> -fno-semantic-interposition.  A key question is whether we could
>>> require that exported symbols are marked explicitly so that we only
>>> emit GOT and PLT indirections on such exported symbols.
>>
>> -flto with a linker plugin already covers this.  I don't think we need
>> anything else.  Maybe an LTO mode that only deals with visibility, but
>> otherwise does little cross-TU optimization?

clang -flto={full,thin} respect -fsemantic-interposition.
If -fsemantic-interposition is specified, it disables interprocedural
optimizations (including inlining) for default visibility non-vague external linkage functions.

(
-Ofast unfortunately implies -ffast-math and does crtfastmath.o.
)
Piggybacking -fno-semantic-interposition on -Ofast

>Well it would be great if LTO solved this problem, but unfortunately it can't...
>LTO tells you which symbols are locally defined, but this doesn't help PIC.
>Local definitions with default visibility must still indirect via the GOT/PLT,
>similarly interprocedural optimizations are still blocked.
>
>A LTO-lite option that just deals with visibility and global variable optimization
>(eg. better use of anchors) and other cheap optimizations seems useful indeed.
>
>Cheers,
>Wilco

-fno-semantic-interposition should be sufficient. I think we don't need
another option. We should just the few software to use -fsemantic-interposition so that
the world can be changed.

FreeBSD and quite a few musl-based Linux distributions use Clang as the
system compiler and have verified that -fno-semantic-interposition-like
default (allow interprocedural optimizations for default visibility
non-vague external linkage functions.

I think folks can give
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937 another request.
Even if the upstream doesn't take it, changing a distro's own spec file
to default to -fno-semantic-interposition isn't that difficult.
Many Linux distributions customize their GCC to do some stuff by default
anyway.

  reply	other threads:[~2022-09-20 22:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 18:39 Wilco Dijkstra
2022-08-26 19:02 ` H.J. Lu
2022-08-26 19:45   ` Richard Henderson
2022-08-26 20:11     ` H.J. Lu
2022-08-29 11:49       ` Wilco Dijkstra
2022-08-29 13:10         ` Florian Weimer
2022-08-29 15:27           ` Wilco Dijkstra
2022-08-29 15:27             ` Wilco Dijkstra
2022-08-29 19:43             ` H.J. Lu
2022-08-29 19:57               ` Fangrui Song
2022-09-05  8:58                 ` Wilco Dijkstra
2022-09-15 21:45                   ` Fangrui Song
2022-09-20 13:59                     ` Wilco Dijkstra
2022-09-20 14:12                       ` Florian Weimer
2022-09-20 16:00                         ` Wilco Dijkstra
2022-09-20 22:02                           ` Fangrui Song [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-08-25 21:01 Richard Henderson
2022-08-26 12:32 ` Adhemerval Zanella Netto
2022-08-26 17:29   ` Richard Henderson

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=20220920220233.wmj5dossqk2k6dbj@google.com \
    --to=maskray@google.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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).