Bug 36792

Summary: [PATCH] link to shared LLVM library
Product: Mesa Reporter: Fabio Pedretti <pedretti.fabio>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: link to shared llvm
link to shared llvm
LLVM should prefer shared libraries.
link to shared llvm

Description Fabio Pedretti 2011-05-03 03:06:36 UTC
Created attachment 46283 [details] [review]
link to shared llvm

I am providing an Ubuntu PPA to enable some mesa features (e.g. llvm support) not available in the Ubuntu version:
https://launchpad.net/~oibaf/+archive/graphics-drivers/

Mesa defaults to use static llvm libraries and this creates huge packages (+10MB for every file using it). I am using the attached patch to link to shared llvm library. Maybe it could be used when specifying a configure flag or be the default if the availability of the shared llvm is detected.
Comment 1 Alan Swanson 2011-05-05 05:27:51 UTC
Actually it's LLVM itself that causes linking to static libraries via llvm-config even when built with enable shared due to LLVM bug 6823.

http://llvm.org/bugs/show_bug.cgi?id=6823
Comment 2 Fabio Pedretti 2011-10-06 01:06:47 UTC
Created attachment 52030 [details] [review]
link to shared llvm

Updated patch for current mesa git.
Comment 3 Brian Paul 2011-10-06 07:14:03 UTC
So with this patch we'll try to link with a file name libLLVM-x.y.so?  I only have static LLVM libs here and there's no libLLVM-2.9.so file.  I get this error:

/usr/bin/ld: cannot find -lLLVM-2.9

I think the patch needs to somehow determine if we're linking with static vs. shared libs.
Comment 4 Johannes Obermayr 2011-10-08 07:14:32 UTC
Created attachment 52118 [details] [review]
LLVM should prefer shared libraries.

Please try this patch on LLVM.

It should also work if you patch /usr/bin/llvm-config (maybe other path on your system?). Then you do not have to recompile LLVM ...
Comment 5 Fabio Pedretti 2011-10-11 02:14:34 UTC
(In reply to comment #3)
> So with this patch we'll try to link with a file name libLLVM-x.y.so?  I only
> have static LLVM libs here and there's no libLLVM-2.9.so file.  I get this
> error:
> 
> /usr/bin/ld: cannot find -lLLVM-2.9
> 
> I think the patch needs to somehow determine if we're linking with static vs.
> shared libs.

Yes, the patch should eventually check that, or it also may be eventually forced with a configure flag (--force-shared-llvm ?).

Anyway it would be useful to have it in mesa.
Comment 6 Fabio Pedretti 2011-11-05 07:14:35 UTC
(In reply to comment #4)
> Created attachment 52118 [details] [review] [review]
> LLVM should prefer shared libraries.
> 
> Please try this patch on LLVM.
> 
> It should also work if you patch /usr/bin/llvm-config (maybe other path on your
> system?). Then you do not have to recompile LLVM ...

I applied this patch on my llvm-config (llvm 2.8 on Ubuntu 11.04) but it doesn't change anything. The output of "llvm-config --libs" is the same with or without the patch:

$ llvm-config --libs
-lLLVMpic16passes -lLLVMMCDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreAsmPrinter -lLLVMXCoreInfo -lLLVMSystemZCodeGen -lLLVMSystemZAsmPrinter -lLLVMSystemZInfo -lLLVMSparcCodeGen -lLLVMSparcAsmPrinter -lLLVMSparcInfo -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmPrinter -lLLVMPowerPCInfo -lLLVMPIC16AsmPrinter -lLLVMPIC16CodeGen -lLLVMPIC16Info -lLLVMMipsAsmPrinter -lLLVMMipsCodeGen -lLLVMMipsInfo -lLLVMMSP430CodeGen -lLLVMMSP430AsmPrinter -lLLVMMSP430Info -lLLVMMBlazeAsmPrinter -lLLVMMBlazeCodeGen -lLLVMMBlazeInfo -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMCppBackend -lLLVMCppBackendInfo -lLLVMCellSPUCodeGen -lLLVMCellSPUAsmPrinter -lLLVMCellSPUInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBlackfinCodeGen -lLLVMBlackfinAsmPrinter -lLLVMBlackfinInfo -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86AsmPrinter -lLLVMX86Info -lLLVMAsmParser -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMAsmPrinter -lLLVMARMInfo -lLLVMArchive -lLLVMBitReader -lLLVMAlphaCodeGen -lLLVMSelectionDAG -lLLVMAlphaAsmPrinter -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMAlphaInfo -lLLVMSupport -lLLVMSystem -L/usr/lib/llvm-2.8/lib
Comment 7 Fabio Pedretti 2011-11-05 07:18:16 UTC
Created attachment 53185 [details] [review]
link to shared llvm

Updated patch for current mesa git
Comment 8 Fabio Pedretti 2012-03-30 09:16:25 UTC
Fixed with 7d87c71a70c95d4fe3a94676128fd9524f048112 .

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.