mailing list of musl libc
 help / color / Atom feed
* [musl] Build error with -flto option
@ 2020-03-03 20:25 Yuseok
  2020-03-03 20:51 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Yuseok @ 2020-03-03 20:25 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]

Hi all,

I got a below error message during building the musl with clang and -flto
option.
- my build option was ./configure CC=clang CFLAGS="-fPIC -flto -O2".
- I also tried building with "CFLAGS="-flto -O2". However, the result was
the same.
- I used clang 9.

This was my error message.

> ...................................
> j/src/unistd/setuid.o obj/src/unistd/setxid.o obj/src/unistd/sleep.o
> obj/src/unistd/symlink.o obj/src/unistd/symlinkat.o obj/src/unistd/sync.o
> obj/src/unistd/tcgetpgrp.o obj/src/unistd/tcsetpgrp.o
> obj/src/unistd/truncate.o obj/src/unistd/ttyname.o
> obj/src/unistd/ttyname_r.o obj/src/unistd/ualarm.o obj/src/unistd/unlink.o
> obj/src/unistd/unlinkat.o obj/src/unistd/usleep.o obj/src/unistd/write.o
> obj/src/unistd/writev.o
> ranlib lib/libc.a
>
> */usr/bin/ld: error: /tmp/lto-llvm-200919.o: requires dynamic
> R_X86_64_PC32 reloc against '__dls2' which may overflow at runtime;
> recompile with -fPIC*/tmp/lto-llvm-200919.o:ld-temp.o:function
> _dlstart_c: error: undefined reference to '__dls2'
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> make: *** [Makefile:161: lib/libc.so] Error 1


Could you please advise how I should handle this error?

[-- Attachment #2: Type: text/html, Size: 1538 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] Build error with -flto option
  2020-03-03 20:25 [musl] Build error with -flto option Yuseok
@ 2020-03-03 20:51 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-03-03 20:51 UTC (permalink / raw)
  To: musl

On Tue, Mar 03, 2020 at 03:25:47PM -0500, Yuseok wrote:
> Hi all,
> 
> I got a below error message during building the musl with clang and -flto
> option.
> - my build option was ./configure CC=clang CFLAGS="-fPIC -flto -O2".
> - I also tried building with "CFLAGS="-flto -O2". However, the result was
> the same.
> - I used clang 9.
> 
> This was my error message.
> 
> > ...................................
> > j/src/unistd/setuid.o obj/src/unistd/setxid.o obj/src/unistd/sleep.o
> > obj/src/unistd/symlink.o obj/src/unistd/symlinkat.o obj/src/unistd/sync.o
> > obj/src/unistd/tcgetpgrp.o obj/src/unistd/tcsetpgrp.o
> > obj/src/unistd/truncate.o obj/src/unistd/ttyname.o
> > obj/src/unistd/ttyname_r.o obj/src/unistd/ualarm.o obj/src/unistd/unlink.o
> > obj/src/unistd/unlinkat.o obj/src/unistd/usleep.o obj/src/unistd/write.o
> > obj/src/unistd/writev.o
> > ranlib lib/libc.a
> >
> > */usr/bin/ld: error: /tmp/lto-llvm-200919.o: requires dynamic
> > R_X86_64_PC32 reloc against '__dls2' which may overflow at runtime;
> > recompile with -fPIC*/tmp/lto-llvm-200919.o:ld-temp.o:function
> > _dlstart_c: error: undefined reference to '__dls2'
> > clang: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> > make: *** [Makefile:161: lib/libc.so] Error 1
> 
> 
> Could you please advise how I should handle this error?

While in theory musl's code aims to be correct so that LTO can't break
it (i.e. not wrongly relying on translation units as compiler
barriers), there are a lot of invalid transformations LLVM does that
are fairly harmless until they start happening across translation unit
boundaries. There are also things like this where LTO misses
identifying cross-asm link dependencies and drops code it needs, which
is what seems to have happened here.

A few ppl have hacked through making LTO work, and found,
unsurprisingly, that it just makes libc.so larger and slower. So I
would recommend just not using it unless you want to track down and
fix the issues on the compiler side. Until LTO is at least
theoretically okay (i.e. not risking broken floating point code,
etc.), I'm probably not going to accept anything upstream on the musl
side in the form of hacks just to make it link.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 20:25 [musl] Build error with -flto option Yuseok
2020-03-03 20:51 ` Rich Felker

mailing list of musl libc

Archives are clonable: git clone --mirror http://inbox.vuxu.org/musl

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git