Are you building llvm-gcc yourself? If so, what version? Xcode releases include an older llvm-gcc and libLTO.dylib, which may not understand bitcode generated by newer self-built compilers. If you are only using llvm-gcc from the Xcode tools release, use the driver from: /Developer/usr/bin/llvm-gcc-4.2 If you are building llvm-gcc yourself, try, in this order: 1) sudo ln -s ../../Developer/usr/lib/libLTO.dylib /usr/lib/libLTO.dylib 2) If you still get errors, try installing the libLTO.dylib from your LLVM build into /Developer/usr/lib. Make sure that if you're on a 64-bit machine, you built llvm for x86_64-apple-darwin10 (which should be the default) Shantonu Sen ssen at apple.com Sent from my Mac Pro On Dec 4, 2009, at 1:57 PM, John Criswell wrote:> John Criswell wrote: >> Dear All, >> >> I'm trying to use transparent link-time optimization on Mac OS X. >> >> I've got Xcode 3.2 installed, and I'm trying to compile code with >> llvm-gcc -O4. However, I get the following error: >> >> gcc -O4 -o dftables .libs/dftables.o >> ld: warning: in .libs/dftables.o, file is not of required architecture >> Undefined symbols: >> "_main", referenced from: >> start in crt1.10.6.o >> ld: symbol(s) not found >> collect2: ld returned 1 exit status >> > I should add that the gcc above is a symbolic link to llvm-gcc. > > -- John T. > >> It seems that the linker doesn't understand the bitcode format. Am I >> missing a command line option? Do I need a newer version of XCode? >> >> -- John T. >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Shantonu Sen wrote:> Are you building llvm-gcc yourself? If so, what version? > > Xcode releases include an older llvm-gcc and libLTO.dylib, which may not understand bitcode generated by newer self-built compilers. >Thanks. A bitcode format mismatch was the problem. I'm not sure if the problem stems from the fact that the bitcode was generated for the wrong architecture (32 vs. 64 bit) or if the bitcode format changed during the development of LLVM 2.6 (I'm using the LLVM 2.6 release, while XCode 3.2 seems to be using some version of LLVM in-between LLVM 2.5 and LLVM 2.6).> If you are only using llvm-gcc from the Xcode tools release, use the driver from: > /Developer/usr/bin/llvm-gcc-4.2 > > If you are building llvm-gcc yourself, try, in this order: > 1) sudo ln -s ../../Developer/usr/lib/libLTO.dylib /usr/lib/libLTO.dylib > > 2) If you still get errors, try installing the libLTO.dylib from your LLVM build into /Developer/usr/lib. Make sure that if you're on a 64-bit machine, you built llvm for x86_64-apple-darwin10 (which should be the default) >The problem I'm going to have (now that LTO works) is that I want to replace libLTO.dylib with my own (I'm trying to do transparent whole-program analysis within libLTO). My libLTO is going to generate bitcode that /Developer/usr/bin/ld (probably) won't understand because the format seems to be newer (LLVM 2.6). Is the source code to Apple's ld linker publicly available, and if so, in what package is it in the Mac OS X sources? -- John T.> > Shantonu Sen > ssen at apple.com > > Sent from my Mac Pro > > On Dec 4, 2009, at 1:57 PM, John Criswell wrote: > > >> John Criswell wrote: >> >>> Dear All, >>> >>> I'm trying to use transparent link-time optimization on Mac OS X. >>> >>> I've got Xcode 3.2 installed, and I'm trying to compile code with >>> llvm-gcc -O4. However, I get the following error: >>> >>> gcc -O4 -o dftables .libs/dftables.o >>> ld: warning: in .libs/dftables.o, file is not of required architecture >>> Undefined symbols: >>> "_main", referenced from: >>> start in crt1.10.6.o >>> ld: symbol(s) not found >>> collect2: ld returned 1 exit status >>> >>> >> I should add that the gcc above is a symbolic link to llvm-gcc. >> >> -- John T. >> >> >>> It seems that the linker doesn't understand the bitcode format. Am I >>> missing a command line option? Do I need a newer version of XCode? >>> >>> -- John T. >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >>> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >
I'm confused. libLTO takes bitcode files as input and creates a native object file as output. Why would libLTO create bitcode as output? If so, you're changing the existing API contract. Or are you creating an out-of-band bitcode file, in which case the linker would never see it. ld doesn't have bitcode support, it has libLTO support, and libLTO is what processes the bitcode. <http://opensource.apple.com/source/ld64/ld64-95.2.12/> Shantonu Sen ssen at apple.com Sent from my Mac Pro On Dec 4, 2009, at 2:49 PM, John Criswell wrote:> Shantonu Sen wrote: >> Are you building llvm-gcc yourself? If so, what version? >> >> Xcode releases include an older llvm-gcc and libLTO.dylib, which may not understand bitcode generated by newer self-built compilers. >> > Thanks. A bitcode format mismatch was the problem. I'm not sure if the problem stems from the fact that the bitcode was generated for the wrong architecture (32 vs. 64 bit) or if the bitcode format changed during the development of LLVM 2.6 (I'm using the LLVM 2.6 release, while XCode 3.2 seems to be using some version of LLVM in-between LLVM 2.5 and LLVM 2.6). >> If you are only using llvm-gcc from the Xcode tools release, use the driver from: >> /Developer/usr/bin/llvm-gcc-4.2 >> >> If you are building llvm-gcc yourself, try, in this order: >> 1) sudo ln -s ../../Developer/usr/lib/libLTO.dylib /usr/lib/libLTO.dylib >> >> 2) If you still get errors, try installing the libLTO.dylib from your LLVM build into /Developer/usr/lib. Make sure that if you're on a 64-bit machine, you built llvm for x86_64-apple-darwin10 (which should be the default) >> > The problem I'm going to have (now that LTO works) is that I want to replace libLTO.dylib with my own (I'm trying to do transparent whole-program analysis within libLTO). My libLTO is going to generate bitcode that /Developer/usr/bin/ld (probably) won't understand because the format seems to be newer (LLVM 2.6). > > Is the source code to Apple's ld linker publicly available, and if so, in what package is it in the Mac OS X sources? > > -- John T. > >> >> Shantonu Sen >> ssen at apple.com >> >> Sent from my Mac Pro >> >> On Dec 4, 2009, at 1:57 PM, John Criswell wrote: >> >> >>> John Criswell wrote: >>> >>>> Dear All, >>>> >>>> I'm trying to use transparent link-time optimization on Mac OS X. >>>> >>>> I've got Xcode 3.2 installed, and I'm trying to compile code with llvm-gcc -O4. However, I get the following error: >>>> >>>> gcc -O4 -o dftables .libs/dftables.o >>>> ld: warning: in .libs/dftables.o, file is not of required architecture >>>> Undefined symbols: >>>> "_main", referenced from: >>>> start in crt1.10.6.o >>>> ld: symbol(s) not found >>>> collect2: ld returned 1 exit status >>>> >>>> >>> I should add that the gcc above is a symbolic link to llvm-gcc. >>> >>> -- John T. >>> >>> >>>> It seems that the linker doesn't understand the bitcode format. Am I missing a command line option? Do I need a newer version of XCode? >>>> >>>> -- John T. >>>> >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>>> >>>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >> >> >
Hi John, On Fri, Dec 4, 2009 at 2:49 PM, John Criswell <criswell at uiuc.edu> wrote:> Shantonu Sen wrote: >> Are you building llvm-gcc yourself? If so, what version? >> >> Xcode releases include an older llvm-gcc and libLTO.dylib, which may not understand bitcode generated by newer self-built compilers. >> > Thanks. A bitcode format mismatch was the problem. I'm not sure if the > problem stems from the fact that the bitcode was generated for the wrong > architecture (32 vs. 64 bit) or if the bitcode format changed during the > development of LLVM 2.6 (I'm using the LLVM 2.6 release, while XCode 3.2 > seems to be using some version of LLVM in-between LLVM 2.5 and LLVM 2.6). >> If you are only using llvm-gcc from the Xcode tools release, use the driver from: >> /Developer/usr/bin/llvm-gcc-4.2 >> >> If you are building llvm-gcc yourself, try, in this order: >> 1) sudo ln -s ../../Developer/usr/lib/libLTO.dylib /usr/lib/libLTO.dylib >> >> 2) If you still get errors, try installing the libLTO.dylib from your LLVM build into /Developer/usr/lib. Make sure that if you're on a 64-bit machine, you built llvm for x86_64-apple-darwin10 (which should be the default) >> > The problem I'm going to have (now that LTO works) is that I want to > replace libLTO.dylib with my own (I'm trying to do transparent > whole-program analysis within libLTO). My libLTO is going to generate > bitcode that /Developer/usr/bin/ld (probably) won't understand because > the format seems to be newer (LLVM 2.6).Why not use llmv-ld tool instead of ld for your needs ? - Devang
On Dec 4, 2009, at 2:49 PM, John Criswell wrote:>> If you are building llvm-gcc yourself, try, in this order: >> 1) sudo ln -s ../../Developer/usr/lib/libLTO.dylib /usr/lib/ >> libLTO.dylib >> >> 2) If you still get errors, try installing the libLTO.dylib from >> your LLVM build into /Developer/usr/lib. Make sure that if you're >> on a 64-bit machine, you built llvm for x86_64-apple-darwin10 >> (which should be the default) >> > The problem I'm going to have (now that LTO works) is that I want to > replace libLTO.dylib with my own (I'm trying to do transparent > whole-program analysis within libLTO). My libLTO is going to generate > bitcode that /Developer/usr/bin/ld (probably) won't understand because > the format seems to be newer (LLVM 2.6).'ld' doesn't know anything about the bitcode format. If you replace liblto with something from mainline, then 'ld' will understand mainline LLVM .bc files. Note that the linker looks relative to itself. This means that if you want to use /usr/bin/ld that you need to install liblto in /usr/lib. If you want to use /Developer/usr/bin/ld you need to update /Developer/ usr/lib. -Chris