[patch] LTO support for Mach-O (apple-darwin)

Jack Howarth howarth@bromo.med.uc.edu
Wed May 5 03:34:00 GMT 2010


On Tue, May 04, 2010 at 08:26:12PM -0700, IainS wrote:
>
> On 2 May 2010, at 03:53, Steven Bosscher wrote:
>> This patch adds support for LTO on Mach-O targets, i.e. darwin.
>
> Bravo!
>
>> There are a couple of funny things this patch does to make LTO work on
>> Mach-O. The most noticeable is that I had to capture assembler output
>> in the LTO generate phase and redirect it to a temporary file. The
>> reason is that you can only define relocations in a relocatable Mach-O
>> object for the first 255 sections, although there doesn't seem to be a
>> limit to the number of sections you can add. So I want all non-LTO
>> sections output before the LTO sections.
>
> I want to understand this better -- I don't think we name anything like 
> 255 distinct sections (even with OBJC2 ones in place).
>
>> and appear to work, but I run into some issues with Mach-O PIC on
>> 32-bits darwin that I don't know (yet?) how to fix. So 32-bits Mach-O
>> LTO support is left as an exercise for the interested reader ;-)
>
> I've applied your patch on top  of all my patches (I.m on vacation and  
> don't have the luxury of several independent trees) ..  and bootstrapped 
> on i686.
>
> I've a hunch that the issue is that variables are being optimized away  
> by the lto - but the references need to be re-written .. but that's a  
> thought-experiment and I won't be able to do much more until back in the 
> office.
>
> I'll also try powerpc and ppc64 at some stage,,,,
>
> great stuff!
> Iain

Iain,
   I tried a modified version of the patch to build on powerpc-apple-darwin9
but no joy from the lto testsuite. The failures are of the form...

Executing on host: /Users/howarth/darwin_objdir/gcc/xgcc -B/Users/howarth/darwin_objdir/gcc/  -O0 -fwhopr  -c  -o c_lto_20
080908_0.o /Users/howarth/gcc/gcc/testsuite/gcc.dg/lto/20080908_0.c    (timeout = 300)
/var/tmp//ccZXeZ2X.s:35:unknown section attribute: debug#.gnu.lto_foo
/var/tmp//ccZXeZ2X.s:35:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:35:Junk character 92 (\).
/var/tmp//ccZXeZ2X.s:35:Rest of line ignored. 1st junk character valued 50 (2).
/var/tmp//ccZXeZ2X.s:51:unknown section attribute: debug#.gnu.lto_.cgraph
/var/tmp//ccZXeZ2X.s:51:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:53:unknown section attribute: debug#.gnu.lto_.vars
/var/tmp//ccZXeZ2X.s:53:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:55:unknown section attribute: debug#.gnu.lto_.statics
/var/tmp//ccZXeZ2X.s:55:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:57:unknown section attribute: debug#.gnu.lto_.decls
/var/tmp//ccZXeZ2X.s:57:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:57:Junk character 92 (\).
/var/tmp//ccZXeZ2X.s:57:Rest of line ignored. 1st junk character valued 48 (0).
/var/tmp//ccZXeZ2X.s:66:unknown section attribute: debug#.gnu.lto_.symtab
/var/tmp//ccZXeZ2X.s:66:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:68:unknown section attribute: debug#.gnu.lto_.opts
/var/tmp//ccZXeZ2X.s:68:Rest of line ignored. 1st junk character valued 32 ( ).
compiler exited with status 1
output is:
/var/tmp//ccZXeZ2X.s:35:unknown section attribute: debug#.gnu.lto_foo
/var/tmp//ccZXeZ2X.s:35:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:35:Junk character 92 (\).
/var/tmp//ccZXeZ2X.s:35:Rest of line ignored. 1st junk character valued 50 (2).
/var/tmp//ccZXeZ2X.s:51:unknown section attribute: debug#.gnu.lto_.cgraph
/var/tmp//ccZXeZ2X.s:51:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:53:unknown section attribute: debug#.gnu.lto_.vars
/var/tmp//ccZXeZ2X.s:53:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:55:unknown section attribute: debug#.gnu.lto_.statics
/var/tmp//ccZXeZ2X.s:55:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:57:unknown section attribute: debug#.gnu.lto_.decls
/var/tmp//ccZXeZ2X.s:57:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:57:Junk character 92 (\).
/var/tmp//ccZXeZ2X.s:57:Rest of line ignored. 1st junk character valued 48 (0).
/var/tmp//ccZXeZ2X.s:66:unknown section attribute: debug#.gnu.lto_.symtab
/var/tmp//ccZXeZ2X.s:66:Rest of line ignored. 1st junk character valued 32 ( ).
/var/tmp//ccZXeZ2X.s:68:unknown section attribute: debug#.gnu.lto_.opts
/var/tmp//ccZXeZ2X.s:68:Rest of line ignored. 1st junk character valued 32 ( ).

FAIL: gcc.dg/lto/20080908 c_lto_20080908_0.o assemble, -O0 -fwhopr

Either there are powerpc-specific differences in the Mach-O format or
we are running into endian issues in the Mach-O LTO code.
            Jack



More information about the Gcc-patches mailing list