From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10755 invoked from network); 1 Feb 2021 18:06:51 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 1 Feb 2021 18:06:51 -0000 Received: (qmail 32671 invoked by uid 550); 1 Feb 2021 18:06:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 32638 invoked from network); 1 Feb 2021 18:06:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=HqR94g39mkxalA1970mUeE6EuYsfJYGAhhXYyhmGRcw=; b=RN9wWiuxl6AeYV2aMhF6jOroXOy/HSw84bSuXH0AZHqzt0lsXiYKpobnalYdQJKemX 1cFmoCTvnFIHi3N1nTxgfH6KkRWoSLvv+EQsFm8jlZ0MlPDgHbZwrzYnFxjJ1AgWx0RY 9f1UKeI5bHR+qapj/Pk7rd0uh3/VCOn0nwhrrF45Xd10krhtiYFpe8H3aheX4laQN/RH vNUSvqwBaLhVRJvrmsLxxrWP/YvEj5mWKNSo66XjQDbIU7HvAJ9SlcsUmii0PTVOg+Oy oBU+Kbd4DPjF6YFpZFWK9lHBdcRL3GVXa8TT2caGFqPcGnnhZNxzT2t/GA2wDLuaUUa/ T+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HqR94g39mkxalA1970mUeE6EuYsfJYGAhhXYyhmGRcw=; b=TF3gwuxfB3p735PBnj4AAH1bA36cPKAbAqqszcfM+EzR43cpT7J4mKE+fqlCvF8bNS pyJblTrJ45djkzB5/JEq7jcj7je+bo/rct0PUgjQ74A4Bw9Y0UbcMrSzoFU64nK4rw2O puh7Gki4RLuCC1fuBkJexYaWsxo6JkqDpGST7zh2bhqbN5E/KI3LUbvWYc2TewlcsKvO cbZ56hboBi9U69ZC+/41uE/pDpq4+qBM8rdnc46blW99kXlDxZRe9GvGQOorhRWd0cjg GfK3X8iOt8nVHIa8UwWjsHJFTmdN/p3mYKcoITH5ZLbr6jWI5NKIVL/LD0vT324F1fcR giSw== X-Gm-Message-State: AOAM531m73PJEJP5b36syf8CSuJq65dn4tmgbd9R5YkVeLHE4ZA3P83y 2nQfikZ9zS/67HEMfTrYIJ5NJ8kqoniZeRrF+ew= X-Google-Smtp-Source: ABdhPJyCom2BBxvAwM+rDVupHntxNWwNzQYwu8o769XTu4N21RbnWy4U53VCpTrkuSTRYDjtZxNLYuLeEgcqbIOK7zc= X-Received: by 2002:aed:3964:: with SMTP id l91mr16397361qte.32.1612202797164; Mon, 01 Feb 2021 10:06:37 -0800 (PST) MIME-Version: 1.0 References: <20210130201227.GP23432@brightrain.aerifal.cx> <20210130233012.GR23432@brightrain.aerifal.cx> <20210131050121.GS23432@brightrain.aerifal.cx> <20210131210105.GT23432@brightrain.aerifal.cx> <20210201175313.GU23432@brightrain.aerifal.cx> In-Reply-To: <20210201175313.GU23432@brightrain.aerifal.cx> From: Fangrui Song Date: Mon, 1 Feb 2021 10:06:26 -0800 Message-ID: To: Jiahao XU Cc: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: =?UTF-8?Q?Re=3A_=5Bmusl=5D_Can=E2=80=99t_build_musl_with_lto=3Dthin?= On Mon, Feb 1, 2021 at 9:53 AM Rich Felker wrote: > > On Mon, Feb 01, 2021 at 12:31:47AM +0000, Jiahao XU wrote: > > Interesting enough, I found =E2=80=94gc-section used along with -flto c= an cut the size of final hello_world executable from 48KB to 5KB. > > > > After investigating with bloaty, I found that =E2=80=94gc-section along= with -flto is able to cut .text from 25.4 KiB to 3.04 KiB, and cut the .ro= data from 19.5 KiB to 120 bytes. > > ..data section however, seen an increase from 316 bytes to 372 bytes, b= ut the VM size is cut from 252 to 244 bytes. > > > > > > $ bloaty gc-section-a.out -- no-gc-section.a.out > > > > FILE SIZE VM SIZE > > > > -------------- -------------- > > > > +18% +56 -3.2% -8 .data > > > > [NEW] +6 [NEW] +6 [LOAD #2 [RX]] > > > > [DEL] -4 -66.7% -8 [LOAD #4 [RW]] > > > > -72.7% -8 [ =3D ] 0 [Unmapped] > > > > -32.0% -64 [ =3D ] 0 .comment > > > > -99.4% -19.4Ki -99.7% -19.4Ki .rodata > > > > -88.0% -22.3Ki -88.2% -22.3Ki .text > > > > -89.4% -41.8Ki -88.5% -41.8Ki TOTAL > > What is included in your hello world? Mine, static linked normally (no > LTO) is around 4k of text and virtually no rodata. (This is with GCC; > I'm not using clang.) If I compile with -fno-builtin so printf doesn't > get transformed to puts, there's about 16k of text and 3k of rodata, > but still nowhere near the ~20k you saw. > > Rich In LLD and LLVMgold.so's LTO configuration, -ffunction-sections & -fdata-sections are automatically enabled. Without them --gc-sections is not useful. -ffunction-sections & -fdata-sections are code generation options and not encoded in bitcode files.