Bug 103543

Summary: meson targets which link libgallium.a have unresolved symbol llvm::RTDyldMemoryManager
Product: Mesa Reporter: tjbugs
Component: OtherAssignee: mesa-dev
Status: NEW --- QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: vedran
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
i915 platform: i915 features:
Attachments: full compile log
log of autotools build
build errors

Description tjbugs 2017-11-02 10:31:25 UTC
Created attachment 135208 [details]
full compile log

src/gallium/auxiliary/libgallium.a(gallivm_lp_bld_misc.cpp.o):(.data.rel.ro._ZTI26DelegatingJITMemoryManager[_ZTI26DelegatingJITMemoryManager]+0x10): undefined reference to `typeinfo for llvm::RTDyldMemoryManager'

I tried various options, but anything involving llvm fails for me
[1290/1291] Linking target src/gallium/targets/osmesa/libOSMesa.so.8.0.0.
FAILED: src/gallium/targets/osmesa/libOSMesa.so.8.0.0
[1291/1291] Linking target src/gallium/targets/dri/libgallium_dri.so.
FAILED: src/gallium/targets/dri/libgallium_dri.so

I need radeon support.
full compile log attached.
I used these options:

gles1=false gles2=false
valgrind=false libunwind=false selinux=false 

using llvm-5.0.0; I also tried 5.0.1 and 6

I got something similar trying mesa-17.3, however the autotools build works in that case.
Comment 1 Dylan Baker 2017-11-02 23:01:37 UTC
I'm having trouble reproducing your problem. I have gcc 7.2.0 and LLVM 5.0.0 and with the same options:

CFLAGS="-march=native -mtune=native -m64 -pipe -O3" CXXFLAGS="-march=native -mtune=native -m64 -pipe -O3" meson build -Ddri-drivers=r200 -Dgallium-drivers=swrast -Dvulkan-drivers=amd -Dplatforms=x11,wayland,drm -Dglx=dri -Dgles1=false -Dgles2=false -Dvalgrind=false -Dlibunwind=false -Dselinux=false -Dosmesa=gallium

It compiles and links fine for me.

As an aside, since you're passing -O3, you should also pass --buildtype=plain, so that meson doesn't add -g and -O options.

Two questions for you:
Are you compiling LLVM yourself?
Does the build work with autotools?
Comment 2 Dylan Baker 2017-11-02 23:03:41 UTC
Also, I noticed you're using meson from git, are you building with upstream master, or do you have additional patches?
Comment 3 tjbugs 2017-11-03 08:17:55 UTC
1. I reverted to meson-0.43.0 built from the release tarball.
2. I am now using llvm-5.0.0 built from the release tarball, with the following options:
3. I now specify buildtype=plain

the mesa build still fails in the same way using git commit 57372c5a42969afe6c7afd6a0389a92e3e1a5178

4. I will now try to build the same code using autotools.
I know that the 17.3 branch builds correctly using autotools.
Comment 4 Michel Dänzer 2017-11-03 08:30:01 UTC
(In reply to tjbugs from comment #3)
> [...] -DBUILD_SHARED_LIBS=1 [...]

Don't enable BUILD_SHARED_LIBS, it's only for LLVM developers. Enable LLVM_LINK_LLVM_DYLIB instead.
Comment 5 tjbugs 2017-11-03 09:08:54 UTC
Created attachment 135221 [details]
log of autotools build

autotools builds master branch, however some of the options are different
Comment 6 tjbugs 2017-11-03 16:32:53 UTC
I rebuilt llvm with LLVM_LINK_LLVM_DYLIB.
That now installs lots of .sa libraries  and an enormous /usr/lib/libLLVM-5.0.so

I then auccessfully rebuilt mesa using autotools, but the mesaon build still fails, although with a much shorter list of link libraries.

[1341/1342] Linking target src/gallium/targets/osmesa/libOSMesa.so.8.0.0.
FAILED: src/gallium/targets/osmesa/libOSMesa.so.8.0.0
ccache c++  -o src/gallium/targets/osmesa/libOSMesa.so.8.0.0 'src/gallium/targets/osmesa/OSMesa@sha/target.c.o' -Wl,--no-undefined -Wl,--as-needed -shared -fPIC -Wl,--start-group -Wl,-soname,libOSMesa.so.8 -Wl,--whole-archive src/gallium/state_trackers/osmesa/libosmesa_st.a -Wl,--no-whole-archive -march=native -mtune=native -m64 -pipe -O3 src/mesa/libmesa_gallium.a src/compiler/glsl/libglsl.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/compiler/glsl/glcpp/libglcpp.a src/util/libmesa_util.a src/gallium/auxiliary/libgallium.a src/mapi/glapi/libglapi_static.a src/gallium/winsys/sw/null/libws_null.a src/gallium/drivers/trace/libtrace.a src/gallium/drivers/softpipe/libsoftpipe.a src/mapi/shared-glapi/libglapi.so src/gallium/drivers/llvmpipe/libllvmpipe.a -pthread -Wl,--gc-sections -Wl,--version-script /var/git/mesalib/src/gallium/targets/osmesa/osmesa.sym -L/usr/lib -lLLVM-5.0 -Wl,--end-group -lz -ldrm -L/usr/lib -lLLVM-5.0 -ldl -lm -L/usr/lib -lLLVM-5.0 '-Wl,-rpath,$ORIGIN/:$ORIGIN/../../../mapi/shared-glapi' -Wl,-rpath-link,/var/git/x86_64/mesa/src/gallium/targets/osmesa:/var/git/x86_64/mesa/src/mapi/shared-glapi
src/gallium/auxiliary/libgallium.a(gallivm_lp_bld_misc.cpp.o):(.data.rel.ro._ZTI26DelegatingJITMemoryManager[_ZTI26DelegatingJITMemoryManager]+0x10): undefined reference to `typeinfo for llvm::RTDyldMemoryManager'
collect2: error: ld returned 1 exit status
Comment 7 Vedran Miletić 2018-01-22 17:06:43 UTC
I can reproduce on Fedora 27 and Fedora 28 (rawhide) with various LLVM versions from 3.9 onwards. What info could be helpful?
Comment 8 Vedran Miletić 2018-01-22 17:08:04 UTC
Created attachment 136898 [details]
build errors
Comment 9 Dylan Baker 2018-01-24 22:40:50 UTC
Can you try building with git tip again? A patch just landed that fixes the way the meson build calculates the LLVM version string for the pre-processor. I'm not sure if that will fix it, but it's worth trying. If it doesn't I'll install fedora and see if I can reproduce and fix it.

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.