public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yuri Kanivetsky <yuri.kanivetsky@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Is --as-needed the default these days?
Date: Sun, 24 Mar 2024 20:52:31 +0200	[thread overview]
Message-ID: <CAMhVC3b=FQc2JjCnC2EJPpbQozCeem4umicyYcUTGq+z=YmhZw@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdQ6i-7a7tCH3DgczS5gJUe1_6sASZiaVs5asB3ZFt3yXg@mail.gmail.com>

> That's a linker option, and the linker is not part of GCC. Any change in linker behaviour is not because of a change in GCC.

Have you noticed what gcc does?

3.4: /usr/libexec/gcc/x86_64-alpine-linux-musl/5.3.0/collect2 ... -lintl
3.5: /usr/libexec/gcc/x86_64-alpine-linux-musl/6.2.1/collect2 ...
--as-needed ... -lintl

collect2 is supposedly part of GCC. And what passes --as-needed is
supposedly gcc.

I was told on IRC that generally --as-needed is not the default. For
the linker I guess. Although I wasn't able to confirm it. The option
is supposedly defined here:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/lexsup.c;h=dad3b6059edfe1fe31f46c454fdc90d55b0aed5b;hb=ec6f962151998434f9cc743386f2a49a1ce1a0f6#l295

But I don't see the default value, and where it's used.

And also it looks like gcc started to pass --as-needed to the linker
since 5.x/6.x.

Am I missing something?

> The GNU linker can be configured to default to --as-needed or not, and different distros use different defaults.

Can you tell me briefly how it's configured? Is there a config?

Regards,
Yuri

  reply	other threads:[~2024-03-24 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 18:00 Yuri Kanivetsky
2024-03-24 18:23 ` Jonathan Wakely
2024-03-24 18:52   ` Yuri Kanivetsky [this message]
2024-03-24 19:01     ` Andrew Pinski
2024-03-24 19:28       ` Yuri Kanivetsky

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='CAMhVC3b=FQc2JjCnC2EJPpbQozCeem4umicyYcUTGq+z=YmhZw@mail.gmail.com' \
    --to=yuri.kanivetsky@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jwakely.gcc@gmail.com \
    /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).