Bug 44564

Summary: Fix build with LLVM -DLLVM_TARGETS_TO_BUILD=`native`
Product: Mesa Reporter: ojab <ojab>
Component: Mesa coreAssignee: ojab <ojab>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: jfonseca, maraeo
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Use LLVM_LIBS="`$LLVM_CONFIG --libs engine`"
Use LLVM_LIBS="`$LLVM_CONFIG --libs engine bitwriter`"

Description ojab 2012-01-07 13:09:53 UTC
Created attachment 55273 [details]
Use LLVM_LIBS="`$LLVM_CONFIG --libs engine`"

As llvm-config says:

Typical components:
  all               All LLVM libraries (default).
  engine            Either a native JIT or a bitcode interpreter.

`all` contains MIPS/ARM/etc libs, which [AFAIU] is not actually used and is not necessary installed, which leads to build/linking error due to missing libraries.
Comment 1 Vinson Lee 2012-01-08 14:49:31 UTC
This sounds like a LLVM bug to me. If MIPS and ARMS libraries weren't built and installed then 'llvm-config --libs' shouldn't list them.
Comment 2 ojab 2012-01-10 02:44:58 UTC
Anyway, Mesa doesn't need LLVM libraries except in `$LLVM_CONFIG --libs engine` to build/run?
Comment 3 Vinson Lee 2012-01-10 08:56:58 UTC
(In reply to comment #2)
> Anyway, Mesa doesn't need LLVM libraries except in `$LLVM_CONFIG --libs engine`
> to build/run?

I tried the SCons build using 'llvm-config --libs engine' and Mesa fails to build.

$ scons
[...]
  Linking build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend ...
build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_blend.o: In function `test_one':
mesa/src/gallium/drivers/llvmpipe/lp_test_blend.c:691: undefined reference to `LLVMWriteBitcodeToFile'
build/linux-x86_64-debug/gallium/auxiliary/libgallium.a(lp_bld_debug.os): In function `llvm::InitializeAllDisassemblers()':
/usr/lib/llvm-2.8/include/llvm/Config/Disassemblers.def:27: undefined reference to `LLVMInitializeARMDisassembler'
Comment 4 ojab 2012-01-30 00:43:28 UTC
Created attachment 56313 [details] [review]
Use LLVM_LIBS="`$LLVM_CONFIG --libs engine bitwriter`"

Filled bug against LLVM http://llvm.org/bugs/show_bug.cgi?id=11886

Looks like LLVM guys recommend to use more fine-grained llvm-config options with specific LLVM_LINK_COMPONENTS, so Mesa should also use it, if possible (not sure though, waiting for the answer in LLVM bugzilla).

llvmpipe also uses bitwriter functions, so use LLVM_LIBS="`$LLVM_CONFIG --libs engine bitwriter`" (now also with scons changes. Can't check scons build, because it's broken for me due to unrelated reasons).
Comment 5 Jose Fonseca 2012-01-30 10:52:46 UTC
Commited. Thanks ojab
Comment 6 Marek Olšák 2012-01-30 16:34:57 UTC
Hi, the commit:

commit 25ee5a27f30aaeb83232de9bada82534d2d504fc
Author: ojab <ojab@ojab.ru>
Date:   Mon Jan 30 12:34:46 2012 +0400

    Use only native engine & bitwriter LLVM libraries for linking.
    
    Signed-off-by: José Fonseca <jfonseca@vmware.com>


breaks Mesa build:

/bin/bash ../../../../bin/mklib -o r600_dri.so.tmp -noprefix -linker 'g++' -ldflags ' -L/usr/lib/llvm-2.8/lib  -lpthread -lffi -ldl -lm ' \
		target.o ../../../../src/mesa/drivers/dri/common/utils.o ../../../../src/mesa/drivers/dri/common/dri_util.o ../../../../src/mesa/drivers/dri/common/xmlconfig.o   ../../../../src/gallium/drivers/r600/libr600.a ../../../../src/gallium/state_trackers/dri/drm/libdridrm.a ../../../../src/gallium/winsys/radeon/drm/libradeonwinsys.a ../../../../src/gallium/drivers/trace/libtrace.a ../../../../src/gallium/drivers/rbug/librbug.a ../../../../src/gallium/drivers/noop/libnoop.a \
                -Wl,--start-group ../../../../src/mesa/libmesagallium.a ../../../../src/gallium/auxiliary/libgallium.a -Wl,--end-group \
                  -L../../../../lib -Wl,-R/usr/lib/i386-linux-gnu/dri -ldricore -lglsl  -ldrm   -lexpat -lm -lpthread -ldl  -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMX86AsmPrinter -lLLVMX86Info -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMSystem -L/usr/lib/llvm-2.8/lib
mklib: Making Linux shared library:  r600_dri.so.tmp
g++ -fno-omit-frame-pointer -Wall -Wmissing-prototypes -std=c99 -fno-strict-aliasing -fno-builtin-memcmp -g -fno-omit-frame-pointer  -fPIC  -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -D_GNU_SOURCE -DPTHREADS -DDEBUG -DTEXTURE_FLOAT_ENABLED -DHAVE_POSIX_MEMALIGN -DUSE_XCB -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS -D__STDC_CONSTANT_MACROS -DHAVE_LLVM=0x0208 -fvisibility=hidden -o r600_dri.so.test ../../../../src/mesa/drivers/dri/common/dri_test.o r600_dri.so.tmp  -L../../../../lib -Wl,-R/usr/lib/i386-linux-gnu/dri -ldricore -lglsl  -ldrm   -lexpat -lm -lpthread -ldl   -L/usr/lib/llvm-2.8/lib  -lpthread -lffi -ldl -lm ;
r600_dri.so.tmp: undefined reference to `LLVMInitializeARMDisassembler'
collect2: ld returned 1 exit status
make[3]: *** [r600_dri.so] Error 1
make[3]: Leaving directory `/home/eosie/dev/mesa/src/gallium/targets/dri-r600'

Do you have any idea how to fix this?
Comment 7 Jose Fonseca 2012-01-31 00:39:00 UTC
(In reply to comment #6)
> 
> Do you have any idea how to fix this?

Should be fixed now. See also bug 45420.

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.