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=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18705 invoked from network); 13 Feb 2021 17:54:42 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 13 Feb 2021 17:54:42 -0000 Received: (qmail 21526 invoked by uid 550); 13 Feb 2021 17:54:37 -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 20472 invoked from network); 13 Feb 2021 17:54:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=decentral.ch; s=rsa1; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject; bh=ReAPqie2WPP/9+4Kg2OBEGLIcAQyqx9P1R3J5Gifb34=; b=I+LjX80bQZeBy4rwbzHDHQZKBa0DMp5fHBUWaC1RR8DP8rqiprhTerqbTQNv8iuWVkd8+8zhhHEYK0qay6F9W9t5nZ4ncbUwOanXi08sB/D6z4uAfkllvQzMWIpfFFLP; To: musl@lists.openwall.com 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> From: Tim Tassonis Message-ID: <65ed0ffa-fd55-da6f-fa34-001939ed36ce@decentral.ch> Date: Sat, 13 Feb 2021 18:54:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: =?UTF-8?Q?Re=3a_=5bmusl=5d_Can=e2=80=99t_build_musl_with_lto=3dthin?= On 2/1/21 10:20 PM, Jiahao XU wrote: > My hello.c: >     #include >     int main() >     { >         puts(“Hello, world!”); >         return 0; >     } > > And if I changed puts to printf and uses -fno-builtin, it also generates > a 16KB executable. Strange, I get 19k without -fno-builtin and 28K with it: timtas@lfsda0:~$ cat hello.c #include int main(int arc, char **argv) { printf("Hello World!\n"); return 0; } timtas@lfsda0:~$ musl-gcc -c hello.c -o hello.o timtas@lfsda0:~$ musl-gcc -o hello hello.o timtas@lfsda0:~$ ls -lh hello -rwxr-xr-x 1 timtas timtas 19K Feb 13 18:49 hello timtas@lfsda0:~$ musl-gcc -fno-builtin -c hello.c -o hello.o timtas@lfsda0:~$ musl-gcc -fno-builtin -o hello hello.o timtas@lfsda0:~$ ls -lh hello -rwxr-xr-x 1 timtas timtas 28K Feb 13 18:50 hello This is musl 1.2.1 with gcc 10.2.0 Bye Tim > > Jiahao XU > ------------------------------------------------------------------------ > *From:* Fangrui Song > *Sent:* Tuesday, February 2, 2021 5:06:26 AM > *To:* Jiahao XU > *Cc:* musl@lists.openwall.com > *Subject:* Re: [musl] Can’t build musl with lto=thin > 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 —gc-section used along with -flto can cut the size of final hello_world executable from 48KB to 5KB. >> > >> > After investigating with bloaty, I found that —gc-section along with -flto is able to cut .text from 25.4 KiB to 3.04 KiB, and cut the .rodata from 19.5 KiB to 120 bytes. >> > ..data section however, seen an increase from 316 bytes to 372 bytes, but 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  [ = ]       0    [Unmapped] >> > >> >  -32.0%     -64  [ = ]       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. -- decentral.ch - IT Stuff Tim Tassonis Hohlstrasse 400 c/o Baubüro Insitu 8048 Zürich stuff@decentral.ch +41 79 229 36 17