Date: Sat, 30 Jan 2021 18:30:12 -0500 From: Rich Felker <dalias@...c.org> To: Jiahao XU <Jiahao_XU@...look.com> Cc: musl@...ts.openwall.com Subject: Re: Can’t build musl with lto=thin 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 += -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’t able to statically linked with libc. > > Once I added ‘-static’ to the compiler flags, the executable failed with ‘Segmentation fault (core dumped)’. 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 <dalias@...c.org> > Sent: Sunday, January 31, 2021 7:12:31 AM > To: Jiahao XU <Jiahao_XU@...look.com> > Cc: musl@...ts.openwall.com <musl@...ts.openwall.com> > Subject: Re: [musl] Can’t build musl with lto=thin > > 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=‘-march=native -mtune=native -Oz -flto > > -fmerge-all-constants -fomit-frame-pointer’ and LDFLAGS=‘-flto > ^^^^^^^^^^^^^^^^^^^^^ > > The -fmerge-all-constants option gives non-conforming language > semantics and should not be used, but that's a separate issue. > > > -fuse-ld=lld -Wl,—plugin-opt=O3,-O3,—icf=safe’. > > > 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 += -fno-lto > > Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.