[LLVMdev] lld-3.4 bloats llvm build badly

Jack Howarth howarth at bromo.med.uc.edu
Wed Nov 20 10:34:23 PST 2013


On Wed, Nov 20, 2013 at 11:13:32AM -0600, Shankar Easwaran wrote:
> Hi Jack,
>
> Are you packaging all the static libraries that lld produces as part of  
> the package ?
>
> PS : When I build on x86_64, I only get a 9M image for lld.
>
> Thanks
>
> Shankar Easwaran

Shankar,
    I think I found the problem. Apparentally I was passing too many flags to
CMAKE_CXX_FLAGS. The following reduced cmake invocation works fine...

cmake -DLLVM_BUILD_32_BITS:BOOL=OFF -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=%p/opt/llvm-%v -DLLVM_ENABLE_ASSERTIONS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT:STRING=/ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="" -DCMAKE_CXX_FLAGS:STRING=-std=c++0x ..

Now the package size is normal again...

-rw-r--r--  1 root  wheel  85591978 Nov 20 12:15 llvm34_3.4-0_darwin-x86_64.deb

I am still unclear however on how to wire the llvm/compiler-rt/clang/polly/test-suite/lld build up
for clang to default to using the new lld linker. Normally we install a symlink at
/sw/opt/llvm-3.4/bin/ld point to /usr/bin/ld. 

% /sw/opt/llvm-3.4/bin/clang++ -v hello.cc
clang version 3.4 (branches/release_34)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
 "/sw/opt/llvm-3.4/bin/clang-3.4" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello.cc -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -v -resource-dir /sw/opt/llvm-3.4/bin/../lib/clang/3.4 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/howarth -ferror-limit 19 -fmessage-length 172 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/sp/w18sshgj1b3f84306wt32xd40000gn/T/hello-9d5a89.o -x c++ hello.cc
clang -cc1 version 3.4 based upon LLVM 3.4svn default target x86_64-apple-darwin13.0.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /sw/opt/llvm-3.4/bin/../include/c++/v1
 /sw/opt/llvm-3.4/bin/../lib/clang/3.4/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/sw/opt/llvm-3.4/bin/ld" -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/folders/sp/w18sshgj1b3f84306wt32xd40000gn/T/hello-9d5a89.o -lc++ -lSystem

If I change this to symlink to point at lld...

ln -sf /sw/opt/llvm-3.4/bin/lld /sw/opt/llvm-3.4/bin/ld

the compiler fails to link...

% /sw/opt/llvm-3.4/bin/clang++ -v hello.cc
clang version 3.4 (branches/release_34)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
 "/sw/opt/llvm-3.4/bin/clang-3.4" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello.cc -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -v -resource-dir /sw/opt/llvm-3.4/bin/../lib/clang/3.4 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/howarth -ferror-limit 19 -fmessage-length 172 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/sp/w18sshgj1b3f84306wt32xd40000gn/T/hello-f87c73.o -x c++ hello.cc
clang -cc1 version 3.4 based upon LLVM 3.4svn default target x86_64-apple-darwin13.0.0
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /sw/opt/llvm-3.4/bin/../include/c++/v1
 /sw/opt/llvm-3.4/bin/../lib/clang/3.4/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/sw/opt/llvm-3.4/bin/ld" -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/folders/sp/w18sshgj1b3f84306wt32xd40000gn/T/hello-f87c73.o -lc++ -lSystem
Unable to find library -lSystem
Unable to find library -lc++
Unable to find file 10.9.0
Unable to find file x86_64
Cannot open /var/folders/sp/w18sshgj1b3f84306wt32xd40000gn/T/hello-f87c73.o: Error parsing linker script
clang-3.4: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas how to default clang to the new linker?

>
> On 11/20/2013 9:15 AM, Jack Howarth wrote:
>>     When lld-3.4 is added to the tools directory of the llvm source tree
>> as lld, the resulting cmake build produces a huge number of static libs and
>> bloats the overall package from...
>>
>> -rw-r--r--  1 root  wheel  86361440 Nov 19 21:09 llvm34_3.4-0_darwin-x86_64.deb
>>
>> to
>>
>> -rw-r--r--  1 root  wheel  495257452 Nov 19 20:49 llvm34_3.4-0_darwin-x86_64.deb
>>
>> Is this a known issue with the initial release of lld?
>>               Jack
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>
>
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation



More information about the llvm-dev mailing list