From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id B6ACE3858D33 for ; Sun, 24 Mar 2024 19:28:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6ACE3858D33 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 B6ACE3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711308534; cv=none; b=xGuByEuNuCrTq95IkO0lgRE5rWugNyNJ6obRknO5sFUKbcapP2X+haSjTdhrZAt7iRehQvf0Q1b7t7y3rAts6St+xwP6BHUDPIvMYZxcbwYQLwl7bCyM3r9Q5y1KTkNqFMh+oCvj/9HC2HX292MoIC82t9RN63q3IIhsoD7ijfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711308534; c=relaxed/simple; bh=2A5mQUNTMNCBB/zMeYO5FjrmsX5QT0nhzbrkXkCrCIA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=oj9XnKyuGvJh3KWERWgU60e++1HJZJAsrJC8bKA8vVbty9Fl4yQJJV9ZUYrZuW5nSkIIA//Gqr89CYNU60VMjvRNU/VN6PXQrBaqlEzB2iVBdh4xBjE9iynZ1rHvI+Zg9V8gIi0SuETvoZrW7u21TkKFh4/nllD+rIGP73CZLXg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-56ba6c83805so4275491a12.0 for ; Sun, 24 Mar 2024 12:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711308530; x=1711913330; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2A5mQUNTMNCBB/zMeYO5FjrmsX5QT0nhzbrkXkCrCIA=; b=krYYwIKXtbgas5qkeQEabaf4lyzDI4edy2nYmwxf1+S7mvcw9T7I0NnXJtK/+yJj/f fplHoxTQzXok/eckH+i5S2/wqYHbbhTk/cipwxplLnUWyvWJ097nOpL2n32bnYW9p8T1 AMZzTflMpyTT5J2v8RtIYNiZlnH3bpae0RKgHoRxjIn5v8iw5t957FR5PPsaEJVe6qiT 49ecljYGzA/km1vjhtOi0Yh9Oj51DhkmHL2qRoofSDmfHH80KROtw7PDg3olNJmRcvep IZ9zYaPtbHJbrCn9NF7jadig4SVa6vRrD7Pvuz2AY/rRoj9tLOY1ZNtNE6PTDqxQaPGs bZ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711308530; x=1711913330; h=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=2A5mQUNTMNCBB/zMeYO5FjrmsX5QT0nhzbrkXkCrCIA=; b=YYI7wrKCBnTjIBqrtVrAGCvhP31KFs1f2zFmZcSrZ7bLHDtfkGkuqBr0HStP383nne da00PBpFBEV1NZtn3Qlgz94WNC+JIpqQ2fLfirLF/ZBxanx64CkBDSmN713eUlUOhXMp vplibKtj/MFlhNkd5547WavHrbSDX9JO0jumvto4vHu1Su4T4yReAYSdbTj/aMJgSy/J 5eyKB1yBKXLxi1jDEgqI/ihxiQZaQcmukTHoOvzAc5/o2PXmmGmJcdnqW3wvYOipFV5O 48ok2GBGRbsdJhi08id2BdDItnRQBTGPAs+KzvwBMjyF4T9tEJuBdOS2RlmgwwcdH4RI ELyw== X-Forwarded-Encrypted: i=1; AJvYcCVN1o48g3MnRL+WlvN3SeINiGhEktbjdmZGRCLl/fhyNxf3C922sAPoSvc26Z/hmUcDqt6Mf+GD3z6D5IhTsh4= X-Gm-Message-State: AOJu0Yz7o23DrHtHoKIEngVC4E6lgoK5NBD0EO/gPmnB0iwN1dwo+2JN oi0PmTzsDbESmJDUWunHpYuKgul5rHoteVAM0Ec77EZoLnShZ+SLFBxCLK7MhdRs/HNoY/dbmOM W2ybkCVgW2vo0E3/3yxKvqBFJfw== X-Google-Smtp-Source: AGHT+IH8Q1a4tnJnjjY/M1xiq382f4KixCsPFf/JjAL5pUj0c1N+qUyW7Fc8dub/eLcVN/4UbykAhRHuwoLmJJjgW6o= X-Received: by 2002:a05:6402:c8d:b0:56b:fa95:ae2b with SMTP id cm13-20020a0564020c8d00b0056bfa95ae2bmr2685610edb.21.1711308529909; Sun, 24 Mar 2024 12:28:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yuri Kanivetsky Date: Sun, 24 Mar 2024 21:28:38 +0200 Message-ID: Subject: Re: Is --as-needed the default these days? To: Andrew Pinski Cc: Jonathan Wakely , "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.5 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: > 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