public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Is --as-needed the default these days?
@ 2024-03-24 18:00 Yuri Kanivetsky
  2024-03-24 18:23 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri Kanivetsky @ 2024-03-24 18:00 UTC (permalink / raw)
  To: gcc

Hi,

It looks like somewhere between gcc-5.3.0 and gcc-6.2.1 --as-needed
became the default:

https://gist.github.com/x-yuri/1b4c19891be50b2b8801689de1487009

In other words it looks like on Alpine Linux 3.4 -lintl always adds
libintl, on >= 3.5 only if some of its symbols are really needed.

Can you possibly give a link to the commit or a changelog entry?

Regards,
Yuri

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is --as-needed the default these days?
  2024-03-24 18:00 Is --as-needed the default these days? Yuri Kanivetsky
@ 2024-03-24 18:23 ` Jonathan Wakely
  2024-03-24 18:52   ` Yuri Kanivetsky
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2024-03-24 18:23 UTC (permalink / raw)
  To: Yuri Kanivetsky; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

On Sun, 24 Mar 2024, 18:01 Yuri Kanivetsky via Gcc, <gcc@gcc.gnu.org> wrote:

> Hi,
>
> It looks like somewhere between gcc-5.3.0 and gcc-6.2.1 --as-needed
> became the default:
>
> https://gist.github.com/x-yuri/1b4c19891be50b2b8801689de1487009
>
> In other words it looks like on Alpine Linux 3.4 -lintl always adds
> libintl, on >= 3.5 only if some of its symbols are really needed.
>
> Can you possibly give a link to the commit or a changelog entry?
>

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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is --as-needed the default these days?
  2024-03-24 18:23 ` Jonathan Wakely
@ 2024-03-24 18:52   ` Yuri Kanivetsky
  2024-03-24 19:01     ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri Kanivetsky @ 2024-03-24 18:52 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is --as-needed the default these days?
  2024-03-24 18:52   ` Yuri Kanivetsky
@ 2024-03-24 19:01     ` Andrew Pinski
  2024-03-24 19:28       ` Yuri Kanivetsky
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2024-03-24 19:01 UTC (permalink / raw)
  To: Yuri Kanivetsky; +Cc: Jonathan Wakely, gcc

On Sun, Mar 24, 2024 at 11:54 AM Yuri Kanivetsky via Gcc
<gcc@gcc.gnu.org> wrote:
>
> > 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?
Upstream GCC does (still) not default to adding `--as-needed` to the
command line (except around libgcc). Some distros add patches which
add `--as-needed` by default though. It looks like alpine is one of
those distros. Maybe you should ask them instead of asking us. It
looks like they made the change between their 3.4 and 3.5 release.

Thanks,
Andrew Pinski

>
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Is --as-needed the default these days?
  2024-03-24 19:01     ` Andrew Pinski
@ 2024-03-24 19:28       ` Yuri Kanivetsky
  0 siblings, 0 replies; 5+ messages in thread
From: Yuri Kanivetsky @ 2024-03-24 19:28 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Jonathan Wakely, gcc

> Upstream GCC does (still) not default to adding `--as-needed` to the
> command line (except around libgcc). Some distros add patches which
> add `--as-needed` by default though. It looks like alpine is one of
> those distros. Maybe you should ask them instead of asking us. It
> looks like they made the change between their 3.4 and 3.5 release.

I believe I've found the change:

https://git.alpinelinux.org/aports/commit/?id=5b7befa1b989315a57f4fb49b8381ce06ded96c9

As we saw above on 3.4 (gcc-5.3.0) it adds libintl, on 3.5 (gcc-6.2.1)
it doesn't.

This commit changes pkgver from 5.3.0 to 6.1.0 and seems to make gcc
add --as-needed, can you confirm?

> Thanks,
> Andrew Pinski
>
> >
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-24 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-24 18:00 Is --as-needed the default these days? Yuri Kanivetsky
2024-03-24 18:23 ` Jonathan Wakely
2024-03-24 18:52   ` Yuri Kanivetsky
2024-03-24 19:01     ` Andrew Pinski
2024-03-24 19:28       ` Yuri Kanivetsky

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).