From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id A21853858D33 for ; Sun, 24 Mar 2024 19:01:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A21853858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A21853858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711306909; cv=none; b=ipxdwT9SxZIQNZffa4Nce+ab8KtGFvT/UMnovDcjfSt7FnFMt5LBGnOImkGxbjZAEYr3U80em80Lqm5bGg2Cl+dMENrsIsu8iAXtUsM/N7hq7VAehMm/GbxKrdk0votQQTbUYQY5Sn73fg1GkNzgRU65vWsmnxNOYhsEXdGJq7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711306909; c=relaxed/simple; bh=16+gQxkzOu0U8/x7x+gsZvLp6hyAtl/Jtu7JdrrtK6U=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=nxVCHc2VVBL4n2qeMd7VVNcf9S5zXsMTrFiITPl2AZzNppNqKiQ1hvwCPHlQWcLF1cMpPjD+ahVcqCqYVoisAJzi5AWSslO/7G+2JLSxDCqWMEqT0UcM69diKZMZJI1U4E6NmZlNNoAUjtA9nNQk2wnZsYRTwuot+12/l/RB49M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5e4613f2b56so2357362a12.1 for ; Sun, 24 Mar 2024 12:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711306906; x=1711911706; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=16+gQxkzOu0U8/x7x+gsZvLp6hyAtl/Jtu7JdrrtK6U=; b=h9GPgFfghQYfOMN8HEGwo9s7AuLyk0oiQVAM6MUU4HEGVgs0pnuciEt+6sq/cKk2Pl lkEQzJOl3F5cVir0xhKvh0pLVqr+aap/kwkAsT8fK5Voh5uDro2TetpsTYh1FvnmMFwF 9P3q1qX+895lVnbzDjz9FSpybMPnPwziETIg5kZIymUwe5qSIXIavMRhHVx5ZEhlHuja me9SICR8UDLHUaNCh5wiIuiXADPEVUKLcbP7rVZMd2eY5spKNa9ySQmj9ZNoxZq38NIi /SISEsn1aoF3jIqdZJqCMYEff0yfhYvlORUUvXGOciE17CEXgZbMJu7s4toCdcPN8Rny gMiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711306906; x=1711911706; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=16+gQxkzOu0U8/x7x+gsZvLp6hyAtl/Jtu7JdrrtK6U=; b=VjPUK39pD6wKUhadaGlznR81LJQEMGl0ShpOcL56cmU88DIijyWuZEnzd8Be+d7lFE FJJRGqBs5C2xX4xvHm+pNLdUbzPdnTMeIThdjxCeVcBU0A/Lcy3CFUNCRR6UovPwhgRc /nlp1WW+DyacetuyNq+400agXLlgjsqxs4rWWp84Witzaw/73/MrZ2M9Ka3bpRfulI0g SABjcmTBtaq8YB9hzA+6R+D6utgth6HhzXZ7zWSg7mNcH2WSmozjrCY0fUKq99vcudth 8erNrD56HC4BZ+0R9ZMFZUXdFARYoBKpgQFnDoJAKgMTtHs1TbNXhKojk337MvRhO1Ot qS5g== X-Forwarded-Encrypted: i=1; AJvYcCWA3qQey2oDJqYRzeh73jE9+j+71w90TV6fn4GADIAAZenouQNL4UzIh/5VGwWVSu5gGtkaD13SkJtpw5EnrJI= X-Gm-Message-State: AOJu0YwdiYbrjEclLOO5Lto1kkKfoBT115afu1ooJYIEW67xJHv9y/Eu JScl1QD365Twh+C7Hu4jWeCQly6bxOLIbuuQYzWymPy4yel4w6r9YOtLMBLYGU1jtDMIiYxCheA mZ0O6V5FyUT5K8X1QdHOWJi/pAq4= X-Google-Smtp-Source: AGHT+IHqEyStwFstQiZavbtwy8ek3elWlhbvZLIDF0+IIjq9m+awHltTJBi5hcY7wWat20JeJ+hVSpR6nXM7OIL/12Y= X-Received: by 2002:a17:90a:c788:b0:29b:c254:5852 with SMTP id gn8-20020a17090ac78800b0029bc2545852mr3409203pjb.11.1711306906493; Sun, 24 Mar 2024 12:01:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Sun, 24 Mar 2024 12:01:34 -0700 Message-ID: Subject: Re: Is --as-needed the default these days? To: Yuri Kanivetsky Cc: Jonathan Wakely , "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 Sun, Mar 24, 2024 at 11:54=E2=80=AFAM Yuri Kanivetsky via Gcc wrote: > > > That's a linker option, and the linker is not part of GCC. Any change i= n 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=3Dbinutils-gdb.git;a=3Dblob;f=3Dld/lexsup.c= ;h=3Ddad3b6059edfe1fe31f46c454fdc90d55b0aed5b;hb=3Dec6f962151998434f9cc7433= 86f2a49a1ce1a0f6#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