From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by sourceware.org (Postfix) with ESMTPS id 2C37E3858D35 for ; Sun, 19 Mar 2023 13:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C37E3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=aarsen.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=aarsen.me Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PfdsL4CsWz9sWV; Sun, 19 Mar 2023 14:25:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1679232326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aDmRNyyRzzjzw6StiWiPRSNokFZyRy7k6QwgXxaMEKY=; b=PHFG9w3t4EwD0tNWo/EMxsEVa6iDrtZocJewJo7tkEkBysFiSDv74b9tRApnsvF08wQ0ho sChKNSQAr178n/2BhjbS6828xKWaJjBL7JfUOHaH184J4VN4i04ZebFmY+X4jc+qddJ3kc nBqmxugqJOAqAo3/+B9VYxE9/FBgH7B/FpTeEIiDFYA136kKdA8Iy5sgXQ+sfCS+77QrX7 UAgm78SuXBFhtPAdneTDIXLm/b88zjivlA4fK57RzO4aenOR1zQAMzakjGPkYaG1IC/ufL jVGwZ4Yu3+lCGsx1UX/3i0tW7FYpUJ2BljvbT2HRG8f8QIGc/ra/mFfBcXRY9Q== References: From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: "3119369616.qq" <3119369616@qq.com> Cc: gcc@gcc.gnu.org Subject: Re: Is it possible to enable data sections and function sections without explicitly giving flags "-fdata-sections" and "-ffunction-sections"? Date: Sun, 19 Mar 2023 14:18:36 +0100 In-reply-to: Message-ID: <861qlkg9ff.fsf@aarsen.me> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Rspamd-Queue-Id: 4PfdsL4CsWz9sWV X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_LOW,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: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "3119369616.qq via Gcc" writes: > To divide functions into sections and then remove unused sections, I must > provide flags "-fdata-sections" and "-ffunction-sections" in GCC and a fl= ag > "--gc-sections" in LD. Most of the build systems don't support these flag= s so > GCC will generate bigger binaries. > Is it possible to enable this feature without  giving any command li= ne flags manually? All (at least decent) build systems support passing extra flags to the compiler and linker (e.g. CXXFLAGS=3D"-ffunction-sections"), or passing a custom compiler and linker (which can set those flags, something like CC=3D"gcc -ffunction-sections"). This is how you should be setting such flags. If you're interested in DCE and other size-reducing optimizations, you might also be interested in LTO and -Os. =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZBcNRF8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy c2VuLm1lAAoJEFLClDAeosSTEs4BAK9OunaIcXcYUscQqhANxBds5NFeDCD2KNDB rFgeSEhOAQDxL5ric/MdC1gN+VJ++ZPGWIBtRHoII60xOTFYVy1RCw== =LgSt -----END PGP SIGNATURE----- --=-=-=--