|
Message-ID: <20150430234451.GY17573@brightrain.aerifal.cx> Date: Thu, 30 Apr 2015 19:44:51 -0400 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: Re: building musl libc.so with gcc -flto On Thu, Apr 30, 2015 at 01:46:21PM -0700, Andy Lutomirski wrote: > On 04/22/2015 07:23 PM, Rich Felker wrote: > >On Wed, Apr 22, 2015 at 03:48:52PM -0700, Andre McCurdy wrote: > >>Hi all, > >> > >>Below are some observations from building musl libc.so with gcc's -flto > >>(link time optimization) option. > > > >Interesting! > > > >>1) With today's master (afbcac68), adding -flto to CFLAGS causes the > >>build to fail: > >> > >> | `_dlstart_c' referenced in section `.text' of /tmp/cc8ceNIy.ltrans0.ltrans.o: defined in discarded section `.text' of src/ldso/dlstart.lo (symbol from plugin) > >> | collect2: error: ld returned 1 exit status > >> | make: *** [lib/libc.so] Error 1 > >> > >>Reverting f1faa0e1 (make _dlstart_c function use hidden visibility) > >>seems to be a workaround. > > > >I think the problem is that LTO is garbage collecting "unused" symbols > >before it gets to the step of linking with asm for which there is no > >IR code, thereby losing anything that's only referenced from asm. A > >better workaround might be to define _dlstart_c with a different name > >as a non-hidden function (e.g. call it __dls1) and then make > >_dlstart_c a hidden alias for it via: > > > >__attribute__((__visibility__("hidden"))) > >void _dlstart_c(size_t *, size_t *); > > > >weak_alias(__dls1, _dlstart_c); > > > >If you get a chance to try that, let me know if it works. Another > >option might be adding -Wl,-u,_dlstart_c to LDFLAGS. > > Wouldn't adding __attribute__((externally_visible)) to the relevant > symbols be more appropriate? It's intended to solve exactly this > problem. I'm not clear whether it would be reliable to use this or not. Semantically externally_visible and visibility=hidden are contradictory. Even if we weren't trying to avoid relying on additional GNU C features, I think it would be a bad idea to rely on this working since the behavior under such contradictory annotations could potentially vary widely between compilers. 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.