Bug 48697

Summary: --with-llvm-shared-libs build fails for some drivers.
Product: Mesa Reporter: Jan Vesely <jv356>
Component: OtherAssignee: mesa-dev
Status: RESOLVED NOTABUG QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Link to llvm shared libs.
config log

Description Jan Vesely 2012-04-14 14:29:07 UTC
Created attachment 59987 [details] [review]
Link to llvm shared libs.

Commit 7d87c71a70c95d4fe3a94676128fd9524f048112 introduced an option --with-llvm-shared-libs that works with r300g, but linking fails for other drivers.

The attached patch fixes this option for drivers that use Makefile.dri (tested on nouveau).
Comment 1 Tom Stellard 2012-04-14 15:21:24 UTC
I can't reproduce this.  I think you might get this error if you upgrade LLVM and then build mesa without re-running autogen.sh.  Can you re-run autogen.sh and try again.  If it still doesn't work can you post your config.log and also the build output.
Comment 2 Jan Vesely 2012-04-14 18:21:10 UTC
I used to call autoreconf -vfi and ./configure instead of autogen.sh (should be the same).

After make distclean and a fresh start it still fails for me with error:

g++ -Wall -march=native -O3 -fno-builtin-memcmp -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-strict-aliasing -fno-builtin-memcmp -m64 -Wall -march=native -O3 -fno-builtin-memcmp  -fPIC  -DUSE_X86_64_ASM -D_GNU_SOURCE -DPTHREADS -DTEXTURE_FLOAT_ENABLED -DHAVE_POSIX_MEMALIGN -DUSE_XCB -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS -D__STDC_CONSTANT_MACROS -DHAVE_LLVM=0x0300 -fvisibility=hidden -o nouveau_dri.so.test ../../../../src/mesa/drivers/dri/common/dri_test.o nouveau_dri.so.tmp  -L../../../../lib -Wl,-R/usr/local/lib/dri -ldricore -lglsl  -ldrm   -lexpat -lm -lpthread -ldl -ldrm_nouveau    -L/usr/lib64/llvm  -lpthread -lffi -ldl -lm ;
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libLLVM-3.0.so, needed by nouveau_dri.so.tmp, not found (try using -rpath or -rpath-link)

followed by dozens of udefined reference to errors
LLVM-3.0.so is in /usr/lib64/llvm

the commandline used for autogen:

NOUVEAU_LIBS="-L/home/me/drm/nouveau/.libs/ -ldrm_nouveau" NOUVEAU_CFLAGS="-I /home/me/drm/include/drm/ -I /home/me/drm/nouveau/" CFLAGS="-Wall -march=native -O3 -fno-builtin-memcmp" CXXFLAGS="-Wall -march=native -O3 -fno-builtin-memcmp" ./autogen.sh --enable-texture-float --enable-xvmc --enable-vdpau --with-gallium-drivers=nouveau,swrast --with-dri-drivers= --disable-egl --enable-64-bit --enable-gallium-g3dvl --with-dri-drivers=i965 --with-llvm-shared-libs

using NOUVEAU_LIBS and NOUVEAU_CFLAGS needed additional patches that replace call to pkg-config with these variables, it is not related to this bug (I experienced it before the nouveau changes).
Comment 3 Jan Vesely 2012-04-14 18:21:59 UTC
Created attachment 60000 [details]
config log
Comment 4 Tom Stellard 2012-04-14 18:35:04 UTC
First of all, I'm not quite sure why nouveau is trying to link with LLVM, but the problem is the linker can't find libLLVM-3.0.  Your LLVM_LDFLAGS look wrong to me.  They have /usr/lib64/llvm as the path to the LLVM libs, but starting with LLVM 3.0, which is what you appear to have, the libraries should be located in /usr/lib64.

What does llvm-config --ldflags output and can you find on your system where libLLVM-3.0.so is installed?  I'm guessing it's in /usr/lib64/.
Comment 5 Tom Stellard 2012-04-14 18:40:40 UTC
(In reply to comment #4)
> First of all, I'm not quite sure why nouveau is trying to link with LLVM, but
> the problem is the linker can't find libLLVM-3.0.  Your LLVM_LDFLAGS look wrong
> to me.  They have /usr/lib64/llvm as the path to the LLVM libs, but starting
> with LLVM 3.0, which is what you appear to have, the libraries should be
> located in /usr/lib64.
> 
> What does llvm-config --ldflags output and can you find on your system where
> libLLVM-3.0.so is installed?  I'm guessing it's in /usr/lib64/.

Sorry, I missed the part of your comment when you said that libLLVM-3.0.so was installed in /usr/lib64/llvm.  I think you need to add /usr/lib64/llvm to your LD_LIBRARY_PATH for it to work.
Comment 6 Jan Vesely 2012-04-14 20:52:09 UTC
You were right, adding /usr/lib/llvm to LD_LIBRARY_PATH fixes the issue.
Thanks, and sorry for the noise.
Comment 7 Andreas Boll 2012-09-13 11:23:04 UTC
(In reply to comment #6)
> You were right, adding /usr/lib/llvm to LD_LIBRARY_PATH fixes the issue.
> Thanks, and sorry for the noise.

Closing.
Comment 8 Jan Vesely 2012-09-13 11:39:05 UTC
sry to bring back this one.
adding /usr/lib/llvm to LD_LIBRARY_PATH is only a workaround.
the real fix is adding -l llvm to linker flags.

The problem is that drivers include libgallium.a, this archive needs llvm symbols, but the information is lost because there is no .la file. Thus everything that includes libgallium.a needs to add -l llvm.

The fact that linker links to libraries in LD_LIBRARY_PATH only hides the real issue.

The real fix would be to convert libgallium.a to automake. it would create .la file and preserve the information about necessary linker flags.

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.