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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11234 invoked from network); 31 Jan 2021 22:41:10 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 31 Jan 2021 22:41:10 -0000 Received: (qmail 11955 invoked by uid 550); 31 Jan 2021 22:41:08 -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 9624 invoked from network); 31 Jan 2021 22:29:40 -0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SH3+8yrfZjs67rF6z2V2iHIXu37neFTXFTq0vo4xPD01AYtjk1RY7eiUAa6qXgdLN0JcmD5tAo/vgqMZ4NSdIfwvUNbIxRMYe7GN3XgyC5/7oADFSiWoHWpQzwYXbuHlT2rMXOFQZJ+Zp7a83zFo54C2ldAoujELRGyDi9hBh2e0XLtRPMN7+PyoCaxgTntdDBniFKNJhiCGvs+LqxWLfBMC2ioBsuhwUgAE4Xz3uWaQlZne3TRCIfIVxA6bfGtRDmR0Ki7uhfD6KNo/6FF8R6UyULe/6yng52GpW8mqVREOyqbbQE6QI5bqmNClFFSVI/hlXj3YmfuoVWwLf2N/oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JBfdmTs5LSOAWfp9xr3s8A/w4zO8jJERhUpxTCAP/tU=; b=gZQlFyNKun/mv6H+K5DFyf/UZaGK18a45CzBVrT5UW3nNGXQhh0VUC8TCH0iUC23LP+M0tzPdxamLAR6p3OwCF8XVcICc1qb65DfEBKiNP+iWS5+vmLRtkONknuU0z4z9xGxu3etcHXF/NakXIMkois0LrYv2uukYop2FSt4lHLBinYuy96bcSH46wf0lxhDq3R7WtaqMAcMiYCRzh3+maHmkhsuJsf0RJ40a3F5Pth/t9LXvK/5nccLD/DAAQ5wE0RkM/FxewKabUlhwaNhpfNSCjAfBTDr38SBnWnwyJ2Mx5QHGgN/kDyG9911Lo4/CWS3hvzw1JGkDmpujEP6IQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JBfdmTs5LSOAWfp9xr3s8A/w4zO8jJERhUpxTCAP/tU=; b=QQ3gFl6lk1AXQlllEcYIFF9/6XbvHKA2SiUj5g99eVcfnPYzgYQ+3PA9ABQ6WUtFHzOmFLnGcY7+0XJVwT5nGaWhw+WiDQMcuTxBC3wzx2pULlieyg3Uw5EE3EU5V9Ng7cQzmSlwVgtF0aEIBoRe/+rk8zg96OZZBafkbmhDIckRakKxSuiHzRDKUV5cfApZ6wMu/2+OkKud7Kz28eALMJQ4U9zkHyLmONQWaDZXDJeJAvuokYohZFsfAlcXZCpTssL1kYoDoFZYwGtDru4KF+/QWMGzwRHDzJsspVABr/zxcQlYe8eWjuidd6tLCbNKrfiR6ylcMV+0xlM533qk6A== From: Jiahao XU To: Rich Felker CC: "musl@lists.openwall.com" Thread-Topic: =?Windows-1252?Q?[musl]_Can=92t_build_musl_with_lto=3Dthin?= Thread-Index: AQHW9jgSvzPebfQPWE+aIHYKw/I+pqpAnAqAgAAvdNWAAAfHAIAAA9LIgABYtQCAAAdvOIABBLYAgAAXyqo= Date: Sun, 31 Jan 2021 22:29:19 +0000 Message-ID: References: <20210130201227.GP23432@brightrain.aerifal.cx> <20210130233012.GR23432@brightrain.aerifal.cx> <20210131050121.GS23432@brightrain.aerifal.cx> ,<20210131210105.GT23432@brightrain.aerifal.cx> In-Reply-To: <20210131210105.GT23432@brightrain.aerifal.cx> Accept-Language: en-US Content-Language: en-AU X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:4A3C32962403FB9933B77C7EB13528C9A7C3C520B2D381F219799905C324D198;UpperCasedChecksum:540E687B4FDB8193DBA624F09D805AEA5134C3830802147E7B9653AE767960AC;SizeAsReceived:7352;Count:44 x-tmn: [JDFUC1EpMxt91pwdBM9/jsZOSMDL8lS0] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 5e5adbe7-2035-4b15-4c56-08d8c637a6fb x-ms-traffictypediagnostic: SG2APC01HT124: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ldwCE4o1XeWlm+weewxFFNRY/F0a/Hx4f2CIpQVvUVFH1daDc6mHwxfSlk9h8Fh7eUWE9FfnOtAIK8o2YRRE9CQj/3GVkx7UOJkUelJbf6SNfdVQw3BLbhkeNvdy2rwu1M7cSPMG2Qd08t6w2QZFVenx8BigMLdZcDw+FSrJn8PcbsBO2mS6KOPDltSor0bcpqw9SkSqVok/lRRj1tMUlwn6AL/T9pwkkS+kgQE9FJIMZ71zFCa4KBjNIZ50cXCfQydwpHgrRr+VAJ5yJ3Rd7MFXydy48nesXdN8uQf+A+et1r8PgnzZqMfOc2ycADiF0jbm0QJeE3hcr6k/kJN4Jyy4UFSdouiIEkewiuUjd2KrEpCx/6ZB7eB4VnrO7cFn0JIKaCBeb91oWxPztWwSw5dBW/nAgihOYNnoQkhDTwwRq11rU7QpJH0pRaRZ6dwY x-ms-exchange-antispam-messagedata: w9c89OpzXq0hTK2ciiGggTbKtEdihO4V7UOBZd6m4EPDrTiP5xeLl6FxmAweFheOEgGUVWCPEF32rAELdwreAFzW11xmf8tN/UIza8dH31WL5mGrkZreuSH0O3xB0hNwodKEDM8GS9dDBjhUVqck4w== x-ms-exchange-transport-forked: True Content-Type: multipart/alternative; boundary="_000_SYBP282MB020251816B33C715D27F51A18AB79SYBP282MB0202AUSP_" MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: SG2APC01FT015.eop-APC01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 5e5adbe7-2035-4b15-4c56-08d8c637a6fb X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jan 2021 22:29:19.9573 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT124 Subject: =?Windows-1252?Q?Re:_[musl]_Can=92t_build_musl_with_lto=3Dthin?= --_000_SYBP282MB020251816B33C715D27F51A18AB79SYBP282MB0202AUSP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I tried to run =93musl-clang -Oz -flto -s -static -fuse-ld=3Dmusl-clang-lld= -Wl,=97plugin-opt=3DO3,-O3 hello.c=94, but it still doesn=92t work. Note that I have removed -static from ld.musl-clang-lld Jiahao XU ________________________________ From: Rich Felker Sent: Monday, February 1, 2021 8:01:06 AM To: Jiahao XU Cc: musl@lists.openwall.com Subject: Re: [musl] Can=92t build musl with lto=3Dthin On Sun, Jan 31, 2021 at 05:32:45AM +0000, Jiahao XU wrote: > I used `musl-clang -Oz -flto -s -fuse-ld=3Dmusl-clang-lld-static -Wl,=97p= lugin-opt=3DO3,-O3 hello.c` to produce the executable. Where is -static? Normally it does *not* work to add -static just to the ld command line. The compiler driver has to know that it's requesting static linking because it will pass a different command line to the linker based on that. > Content of `/usr/local/musl/bin/ld.musl-clang-lld-static` is same as > the generated `ld.musl-clang`, except for the last line, which I > modified it to: > > exec $($cc -print-prog-name=3Dld.lld) -nostdlib =93$@=93 -static -lc = -dynamic-linker =93$ldso=94 Try moving -static out from here (i.e. using the script unmodified except for requesting ld.lld) and see if that works. Note that a correctly linked executable will not have any INTERP in readelf -a output, so as long as you see INTERP anywhere there you're doing something wrong. Rich > ________________________________ > From: Rich Felker > Sent: Sunday, January 31, 2021 4:01:22 PM > To: Jiahao XU > Cc: musl@lists.openwall.com > Subject: Re: [musl] Can=92t build musl with lto=3Dthin > > On Sat, Jan 30, 2021 at 11:44:48PM +0000, Jiahao XU wrote: > > (gdb) bt > > > > #0 0x00007ffff7ff5498 in decode_vec () from /lib/ld-musl-x86_64.so.1 > > > > #1 0x00007ffff7ff58cb in decode_dyn () from /lib/ld-musl-x86_64.so.1 > > > > #2 0x0000000000000000 in ?? () > > This is not a static-linked program. decode_dyn is part of the dynamic > linker. It looks to me like you've created some sort of weird hybrid > executable that's not valid. Can you show the command lines you used > to produce it? > > Also please keep list on CC when replying. > > Rich > > > > (gdb) info r > > > > rax 0x1 1 > > > > rbx 0x7ffff7ffe2d8 140737354130136 > > > > rcx 0x5000 20480 > > > > rdx 0x200238 2097720 > > > > rsi 0x7fffffffd8d0 140737488345296 > > > > rdi 0x0 0 > > > > rbp 0x7ffff7ffe2d8 0x7ffff7ffe2d8 <__dls3.app> > > > > rsp 0x7fffffffd8c8 0x7fffffffd8c8 > > > > r8 0x0 0 > > > > r9 0xfffffffffffff000 -4096 > > > > r10 0x800000 8388608 > > > > r11 0x200000 2097152 > > > > r12 0x7fffffffdcb8 140737488346296 > > > > r13 0x0 0 > > > > r14 0x7fffffffd8d0 140737488345296 > > > > r15 0x7fffffffdcb8 140737488346296 > > > > rip 0x7ffff7ff5498 0x7ffff7ff5498 > > > > eflags 0x10246 [ PF ZF IF RF ] > > > > cs 0x33 51 > > > > ss 0x2b 43 > > > > ds 0x0 0 > > > > es 0x0 0 > > > > fs 0x0 0 > > > > gs 0x0 0 > > > > > > Disassembly of decode_dyn: > > > > > > 0x00007ffff7ff58af <+0>: push %r14 > > > > 0x00007ffff7ff58b1 <+2>: push %rbx > > > > 0x00007ffff7ff58b2 <+3>: sub $0x108,%rsp > > > > 0x00007ffff7ff58b9 <+10>: mov %rdi,%rbx > > > > 0x00007ffff7ff58bc <+13>: mov 0x10(%rdi),%rdi > > > > 0x00007ffff7ff58c0 <+17>: mov %rsp,%r14 > > > > 0x00007ffff7ff58c3 <+20>: mov %r14,%rsi > > > > 0x00007ffff7ff58c6 <+23>: call 0x7ffff7ff5483 > > > > 0x00007ffff7ff58cb <+28>: mov (%rbx),%rax > > > > > > Disassembly of decode_vec: > > > > > > 0x00007ffff7ff5483 <+0>: xor %eax,%eax > > > > 0x00007ffff7ff5485 <+2>: cmp $0x20,%rax > > > > 0x00007ffff7ff5489 <+6>: je 0x7ffff7ff5495 > > > > 0x00007ffff7ff548b <+8>: andq $0x0,(%rsi,%rax,8) > > > > 0x00007ffff7ff5490 <+13>: inc %rax > > > > 0x00007ffff7ff5493 <+16>: jmp 0x7ffff7ff5485 > > > > 0x00007ffff7ff5495 <+18>: push $0x1 > > > > 0x00007ffff7ff5497 <+20>: pop %rax > > > > =3D> 0x00007ffff7ff5498 <+21>: mov (%rdi),%rcx > > > > 0x00007ffff7ff549b <+24>: test %rcx,%rcx > > > > 0x00007ffff7ff549e <+27>: je 0x7ffff7ff54c3 > > > > 0x00007ffff7ff54a0 <+29>: lea -0x1(%rcx),%rdx > > > > 0x00007ffff7ff54a4 <+33>: cmp $0x1e,%rdx > > > > 0x00007ffff7ff54a8 <+37>: ja 0x7ffff7ff54bd > > > > 0x00007ffff7ff54aa <+39>: shlx %rcx,%rax,%rcx > > > > 0x00007ffff7ff54af <+44>: or %rcx,(%rsi) > > > > 0x00007ffff7ff54b2 <+47>: mov (%rdi),%rcx > > > > 0x00007ffff7ff54b5 <+50>: mov 0x8(%rdi),%rdx > > > > 0x00007ffff7ff54b9 <+54>: mov %rdx,(%rsi,%rcx,8) > > > > 0x00007ffff7ff54bd <+58>: add $0x10,%rdi > > > > 0x00007ffff7ff54c1 <+62>: jmp 0x7ffff7ff5498 > > > > 0x00007ffff7ff54c3 <+64>: ret > > > > > > Jiahao XU > > > > Get Outlook for iOS > > ________________________________ > > From: Rich Felker > > Sent: Sunday, January 31, 2021 10:30:12 AM > > To: Jiahao XU > > Cc: musl@lists.openwall.com > > Subject: Re: [musl] Can=92t build musl with lto=3Dthin > > > > On Sat, Jan 30, 2021 at 11:04:32PM +0000, Jiahao XU wrote: > > > > So something like (in config.mak): > > > > > > > > obj/ldso/dlstart.lo: CFLAGS_ALL +=3D -fno-lto > > > > > > Thanks, with this I was able to build libc.so successfully with clang= and created a 3.5 KB hello world program using clang and lld. > > > > > > However, I still wasn=92t able to statically linked with libc. > > > > > > Once I added =91-static=92 to the compiler flags, the executable fail= ed with =91Segmentation fault (core dumped)=92. > > > > It's libc.a, not libc.so, that will be involved in making a > > static-linked binary. It's hard to know what's going wrong without > > more information. Can you run under a debugger and provide a > > backtrace, disassembly, and register dump for where the crash occurs? > > > > Rich > > > > > > > ________________________________ > > > From: Rich Felker > > > Sent: Sunday, January 31, 2021 7:12:31 AM > > > To: Jiahao XU > > > Cc: musl@lists.openwall.com > > > Subject: Re: [musl] Can=92t build musl with lto=3Dthin > > > > > > On Fri, Jan 29, 2021 at 12:19:42PM +0000, Jiahao XU wrote: > > > > musl-1.2.2 compilation with clang-11 failed to build libc.so at the= final linking stage: > > > > > > > > ld.lld: error: undefined hidden symbol: __dls2 > > > > >>> referenced by ld-temp.o > > > > >>> lto.tmp:(_dlstart_c) > > > > >>> did you mean: __dls3 > > > > >>> defined in: lto.tmp > > > > > > > > I am using CFLAGS=3D=91-march=3Dnative -mtune=3Dnative -Oz -flto > > > > -fmerge-all-constants -fomit-frame-pointer=92 and LDFLAGS=3D=91-flt= o > > > ^^^^^^^^^^^^^^^^^^^^^ > > > > > > The -fmerge-all-constants option gives non-conforming language > > > semantics and should not be used, but that's a separate issue. > > > > > > > -fuse-ld=3Dlld -Wl,=97plugin-opt=3DO3,-O3,=97icf=3Dsafe=92. > > > > > > > No configure option is supplied. > > > > > > Otherwise, it's a known issue that LTO misses references from asm > > > (both top-level and in functions). I think dlstart.lo and a few other > > > files should just be built with LTO disabled; any LTO-type > > > optimization in code that runs at this stage is inherently invalid, > > > anyway. So something like (in config.mak): > > > > > > obj/ldso/dlstart.lo: CFLAGS_ALL +=3D -fno-lto > > > > > > Rich --_000_SYBP282MB020251816B33C715D27F51A18AB79SYBP282MB0202AUSP_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
I tried to run =93musl-clang -Oz -flto -s -static -fuse-ld=3Dmusl-clang-lld= -Wl,=97plugin-opt=3DO3,-O3 hello.c=94, but it still doesn=92t work.

Note that I have removed -static from ld.musl-clang-lld 

Jiahao XU

From: Rich Felker <dalia= s@libc.org>
Sent: Monday, February 1, 2021 8:01:06 AM
To: Jiahao XU <Jiahao_XU@outlook.com>
Cc: musl@lists.openwall.com <musl@lists.openwall.com>
Subject: Re: [musl] Can=92t build musl with lto=3Dthin
 
On Sun, Jan 31, 2021 at 05:32:45AM +0000, Jiahao X= U wrote:
> I used `musl-clang -Oz -flto -s -fuse-ld=3Dmusl-clang-lld-static -Wl,= =97plugin-opt=3DO3,-O3 hello.c` to produce the executable.

Where is -static? Normally it does *not* work to add -static just to
the ld command line. The compiler driver has to know that it's
requesting static linking because it will pass a different command
line to the linker based on that.

> Content of `/usr/local/musl/bin/ld.musl-clang-lld-static` is same as > the generated `ld.musl-clang`, except for the last line, which I
> modified it to:
>
>     exec $($cc -print-prog-name=3Dld.lld) -nostdli= b =93$@=93 -static -lc -dynamic-linker =93$ldso=94

Try moving -static out from here (i.e. using the script unmodified
except for requesting ld.lld) and see if that works. Note that a
correctly linked executable will not have any INTERP in readelf -a
output, so as long as you see INTERP anywhere there you're doing
something wrong.

Rich


> ________________________________
> From: Rich Felker <dalias@libc.org>
> Sent: Sunday, January 31, 2021 4:01:22 PM
> To: Jiahao XU <Jiahao_XU@outlook.com>
> Cc: musl@lists.openwall.com <musl@lists.openwall.com>
> Subject: Re: [musl] Can=92t build musl with lto=3Dthin
>
> On Sat, Jan 30, 2021 at 11:44:48PM +0000, Jiahao XU wrote:
> > (gdb) bt
> >
> > #0  0x00007ffff7ff5498 in decode_vec () from /lib/ld-musl-x8= 6_64.so.1
> >
> > #1  0x00007ffff7ff58cb in decode_dyn () from /lib/ld-musl-x8= 6_64.so.1
> >
> > #2  0x0000000000000000 in ?? ()
>
> This is not a static-linked program. decode_dyn is part of the dynamic=
> linker. It looks to me like you've created some sort of weird hybrid > executable that's not valid. Can you show the command lines you used > to produce it?
>
> Also please keep list on CC when replying.
>
> Rich
>
>
> > (gdb) info r
> >
> > rax          &n= bsp; 0x1           &= nbsp;     1
> >
> > rbx          &n= bsp; 0x7ffff7ffe2d8      140737354130136
> >
> > rcx          &n= bsp; 0x5000          &nbs= p;   20480
> >
> > rdx          &n= bsp; 0x200238          &n= bsp; 2097720
> >
> > rsi          &n= bsp; 0x7fffffffd8d0      140737488345296
> >
> > rdi          &n= bsp; 0x0           &= nbsp;     0
> >
> > rbp          &n= bsp; 0x7ffff7ffe2d8      0x7ffff7ffe2d8 <__dls3= .app>
> >
> > rsp          &n= bsp; 0x7fffffffd8c8      0x7fffffffd8c8
> >
> > r8          &nb= sp;  0x0          &n= bsp;      0
> >
> > r9          &nb= sp;  0xfffffffffffff000  -4096
> >
> > r10          &n= bsp; 0x800000          &n= bsp; 8388608
> >
> > r11          &n= bsp; 0x200000          &n= bsp; 2097152
> >
> > r12          &n= bsp; 0x7fffffffdcb8      140737488346296
> >
> > r13          &n= bsp; 0x0           &= nbsp;     0
> >
> > r14          &n= bsp; 0x7fffffffd8d0      140737488345296
> >
> > r15          &n= bsp; 0x7fffffffdcb8      140737488346296
> >
> > rip          &n= bsp; 0x7ffff7ff5498      0x7ffff7ff5498 <decode= _vec+21>
> >
> > eflags         0x10246&nb= sp;            [ PF = ZF IF RF ]
> >
> > cs          &nb= sp;  0x33          &= nbsp;     51
> >
> > ss          &nb= sp;  0x2b          &= nbsp;     43
> >
> > ds          &nb= sp;  0x0          &n= bsp;      0
> >
> > es          &nb= sp;  0x0          &n= bsp;      0
> >
> > fs          &nb= sp;  0x0          &n= bsp;      0
> >
> > gs          &nb= sp;  0x0          &n= bsp;      0
> >
> >
> > Disassembly of decode_dyn:
> >
> >
> >    0x00007ffff7ff58af <+0>:   = ;  push   %r14
> >
> >    0x00007ffff7ff58b1 <+2>:   = ;  push   %rbx
> >
> >    0x00007ffff7ff58b2 <+3>:   = ;  sub    $0x108,%rsp
> >
> >    0x00007ffff7ff58b9 <+10>:  &nbs= p; mov    %rdi,%rbx
> >
> >    0x00007ffff7ff58bc <+13>:  &nbs= p; mov    0x10(%rdi),%rdi
> >
> >    0x00007ffff7ff58c0 <+17>:  &nbs= p; mov    %rsp,%r14
> >
> >    0x00007ffff7ff58c3 <+20>:  &nbs= p; mov    %r14,%rsi
> >
> >    0x00007ffff7ff58c6 <+23>:  &nbs= p; call   0x7ffff7ff5483 <decode_vec>
> >
> >    0x00007ffff7ff58cb <+28>:  &nbs= p; mov    (%rbx),%rax
> >
> >
> > Disassembly of decode_vec:
> >
> >
> >    0x00007ffff7ff5483 <+0>:   = ;  xor    %eax,%eax
> >
> >    0x00007ffff7ff5485 <+2>:   = ;  cmp    $0x20,%rax
> >
> >    0x00007ffff7ff5489 <+6>:   = ;  je     0x7ffff7ff5495 <decode_vec+18>
> >
> >    0x00007ffff7ff548b <+8>:   = ;  andq   $0x0,(%rsi,%rax,8)
> >
> >    0x00007ffff7ff5490 <+13>:  &nbs= p; inc    %rax
> >
> >    0x00007ffff7ff5493 <+16>:  &nbs= p; jmp    0x7ffff7ff5485 <decode_vec+2>
> >
> >    0x00007ffff7ff5495 <+18>:  &nbs= p; push   $0x1
> >
> >    0x00007ffff7ff5497 <+20>:  &nbs= p; pop    %rax
> >
> > =3D> 0x00007ffff7ff5498 <+21>:    mov&nbs= p;   (%rdi),%rcx
> >
> >    0x00007ffff7ff549b <+24>:  &nbs= p; test   %rcx,%rcx
> >
> >    0x00007ffff7ff549e <+27>:  &nbs= p; je     0x7ffff7ff54c3 <decode_vec+64>
> >
> >    0x00007ffff7ff54a0 <+29>:  &nbs= p; lea    -0x1(%rcx),%rdx
> >
> >    0x00007ffff7ff54a4 <+33>:  &nbs= p; cmp    $0x1e,%rdx
> >
> >    0x00007ffff7ff54a8 <+37>:  &nbs= p; ja     0x7ffff7ff54bd <decode_vec+58>
> >
> >    0x00007ffff7ff54aa <+39>:  &nbs= p; shlx   %rcx,%rax,%rcx
> >
> >    0x00007ffff7ff54af <+44>:  &nbs= p; or     %rcx,(%rsi)
> >
> >    0x00007ffff7ff54b2 <+47>:  &nbs= p; mov    (%rdi),%rcx
> >
> >    0x00007ffff7ff54b5 <+50>:  &nbs= p; mov    0x8(%rdi),%rdx
> >
> >    0x00007ffff7ff54b9 <+54>:  &nbs= p; mov    %rdx,(%rsi,%rcx,8)
> >
> >    0x00007ffff7ff54bd <+58>:  &nbs= p; add    $0x10,%rdi
> >
> >    0x00007ffff7ff54c1 <+62>:  &nbs= p; jmp    0x7ffff7ff5498 <decode_vec+21>
> >
> >    0x00007ffff7ff54c3 <+64>:  &nbs= p; ret
> >
> >
> > Jiahao XU
> >
> > Get Outlook for iOS<https://= aka.ms/o0ukef>
> > ________________________________
> > From: Rich Felker <dalias@libc.org>
> > Sent: Sunday, January 31, 2021 10:30:12 AM
> > To: Jiahao XU <Jiahao_XU@outlook.com>
> > Cc: musl@lists.openwall.com <musl@lists.openwall.com>
> > Subject: Re: [musl] Can=92t build musl with lto=3Dthin
> >
> > On Sat, Jan 30, 2021 at 11:04:32PM +0000, Jiahao XU wrote:
> > > > So something like (in config.mak):
> > > >
> > > > obj/ldso/dlstart.lo: CFLAGS_ALL +=3D -fno-lto
> > >
> > > Thanks, with this I was able to build libc.so successfully w= ith clang and created a 3.5 KB hello world program using clang and lld.
> > >
> > > However, I still wasn=92t able to statically linked with lib= c.
> > >
> > > Once I added =91-static=92 to the compiler flags, the execut= able failed with =91Segmentation fault (core dumped)=92.
> >
> > It's libc.a, not libc.so, that will be involved in making a
> > static-linked binary. It's hard to know what's going wrong withou= t
> > more information. Can you run under a debugger and provide a
> > backtrace, disassembly, and register dump for where the crash occ= urs?
> >
> > Rich
> >
> >
> > > ________________________________
> > > From: Rich Felker <dalias@libc.org>
> > > Sent: Sunday, January 31, 2021 7:12:31 AM
> > > To: Jiahao XU <Jiahao_XU@outlook.com>
> > > Cc: musl@lists.openwall.com <musl@lists.openwall.com><= br> > > > Subject: Re: [musl] Can=92t build musl with lto=3Dthin
> > >
> > > On Fri, Jan 29, 2021 at 12:19:42PM +0000, Jiahao XU wrote: > > > > musl-1.2.2 compilation with clang-11 failed to build li= bc.so at the final linking stage:
> > > >
> > > >     ld.lld: error: undefined hidden= symbol: __dls2
> > > >     >>> referenced by ld-t= emp.o
> > > >     >>>   &= nbsp;           &nbs= p;          lto.tmp:(_dlstart_= c)
> > > >     >>> did you mean: __dl= s3
> > > >     >>> defined in: lto.tm= p
> > > >
> > > > I am using CFLAGS=3D=91-march=3Dnative -mtune=3Dnative = -Oz -flto
> > > > -fmerge-all-constants -fomit-frame-pointer=92 and LDFLA= GS=3D=91-flto
> > >   ^^^^^^^^^^^^^^^^^^^^^
> > >
> > > The -fmerge-all-constants option gives non-conforming langua= ge
> > > semantics and should not be used, but that's a separate issu= e.
> > >
> > > > -fuse-ld=3Dlld -Wl,=97plugin-opt=3DO3,-O3,=97icf=3Dsafe= =92.
> > >
> > > > No configure option is supplied.
> > >
> > > Otherwise, it's a known issue that LTO misses references fro= m asm
> > > (both top-level and in functions). I think dlstart.lo and a = few other
> > > files should just be built with LTO disabled; any LTO-type > > > optimization in code that runs at this stage is inherently i= nvalid,
> > > anyway. So something like (in config.mak):
> > >
> > > obj/ldso/dlstart.lo: CFLAGS_ALL +=3D -fno-lto
> > >
> > > Rich
--_000_SYBP282MB020251816B33C715D27F51A18AB79SYBP282MB0202AUSP_--