Bug 90032 - build fails, undefined reference to llvm:RTDyldMemoryManager
Summary: build fails, undefined reference to llvm:RTDyldMemoryManager
Status: RESOLVED WORKSFORME
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: 10.5
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-14 22:17 UTC by Felix von Leitner
Modified: 2017-03-22 16:14 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Felix von Leitner 2015-04-14 22:17:15 UTC
I can't build Mesa with gcc 4.9.2 and LLVM 3.6.
Here's how I run configure:

./configure --prefix=/usr/X11R7 --sysconfdir=/etc --localstatedir=/var `libdir /usr/X11R7` --with-gallium-drivers=i915,nouveau,r600 --with-dri-drivers=i965,swrast --enable-texture-float --disable-llvm-shared-libs --enable-opencl --enable-texture-float --enable-gles1 --enable-gles2 --enable-osmesa --enable-xa --enable-gbm --enable-glx-tls --with-egl-platforms="drm,x11"

Here's what happens:

make[4]: Entering directory '/tmp/mesa-10.5.3/src/gallium/targets/pipe-loader'
  CC       pipe_i915.lo
  CC       pipe_nouveau.lo
  CC       pipe_r600.lo
  CXXLD    pipe_nouveau.la
  CXXLD    pipe_i915.la
  CXXLD    pipe_r600.la
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_debug.o):(.data.rel.ro._ZTIN4llvm14format_object1ImEE[_ZTIN4llvm14format_object1ImEE]+0x10): undefined reference to `typeinfo for llvm::format_object_base'
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_misc.o):(.data.rel.ro._ZTI26DelegatingJITMemoryManager[_ZTI26DelegatingJITMemoryManager]+0x10): undefined reference to `typeinfo for llvm::RTDyldMemoryManager'
collect2: error: ld returned 1 exit status
Makefile:914: recipe for target 'pipe_i915.la' failed
make[4]: *** [pipe_i915.la] Error 1
make[4]: *** Waiting for unfinished jobs....
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_debug.o):(.data.rel.ro._ZTIN4llvm14format_object1ImEE[_ZTIN4llvm14format_object1ImEE]+0x10): undefined reference to `typeinfo for llvm::format_object_base'
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_misc.o):(.data.rel.ro._ZTI26DelegatingJITMemoryManager[_ZTI26DelegatingJITMemoryManager]+0x10): undefined reference to `typeinfo for llvm::RTDyldMemoryManager'
collect2: error: ld returned 1 exit status
Makefile:923: recipe for target 'pipe_nouveau.la' failed
make[4]: *** [pipe_nouveau.la] Error 1
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_debug.o):(.data.rel.ro._ZTIN4llvm14format_object1ImEE[_ZTIN4llvm14format_object1ImEE]+0x10): undefined reference to `typeinfo for llvm::format_object_base'
../../../../src/gallium/auxiliary/.libs/libgallium.a(lp_bld_misc.o):(.data.rel.ro._ZTI26DelegatingJITMemoryManager[_ZTI26DelegatingJITMemoryManager]+0x10): undefined reference to `typeinfo for llvm::RTDyldMemoryManager'
collect2: error: ld returned 1 exit status
Makefile:929: recipe for target 'pipe_r600.la' failed
make[4]: *** [pipe_r600.la] Error 1
make[4]: Leaving directory '/tmp/mesa-10.5.3/src/gallium/targets/pipe-loader'
Makefile:579: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/tmp/mesa-10.5.3/src/gallium'
Makefile:667: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/tmp/mesa-10.5.3/src'
Makefile:607: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/mesa-10.5.3'
Makefile.Linux:4: recipe for target 'compile' failed
make: *** [compile] Error 2
Comment 1 Jan Vesely 2015-04-14 22:30:57 UTC
Do you happen to use cmake compiled llvm?

Can you post the output of
llvm-config --cxxflags
Comment 2 Felix von Leitner 2015-04-14 22:46:42 UTC
yes, my llvm is a cmake build.

Here's the output of llvm-config:

-I/usr/include  -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

Note that I built LLVM with RTTI support because I thought that would fix this issue. It did not. Here's how I build llvm:

cd build && REQUIRES_RTTI=1 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_LIBDIR_SUFFIX=64 -DBUILD_SHARED_LIBS=ON
Comment 3 Jan Vesely 2015-04-14 23:10:55 UTC
you can try building mesa without rtti, to confirm that rtti is indeed an issue.

you can also try building llvm with a patch from here:
https://llvm.org/bugs/show_bug.cgi?id=14200

afair, the configuration setting should be LLVM_ENABLE_RTTI=1, I'm not sure how it interacts with the REQUIRES_LLVM internal variable. someone else might know better
Comment 4 Felix von Leitner 2015-04-14 23:33:26 UTC
I tried to compile mesa without RTTI, but the build fails.

CXX="g++ -fno-rtti" ./configure --prefix=/usr/X11R7 --sysconfdir=/etc --localstatedir=/var `libdir /usr/X11R7` --with-gallium-drivers=i915,nouveau,r600 --with-dri-drivers=i965,swrast --enable-texture-float --disable-llvm-shared-libs --enable-opencl --enable-texture-float --enable-gles1 --enable-gles2 --enable-osmesa --enable-xa --enable-gbm --enable-glx-tls --with-egl-platforms="drm,x11"

The error message is that you can't use typeid (this was some debug macro in the nv50 driver) without rtti. I never turned on debug mode. I'm now trying to build with --disable-debug.
Comment 5 Felix von Leitner 2015-04-14 23:37:57 UTC
Did not help. Here's the error message:

In file included from ../../../../src/gallium/auxiliary/util/u_inlines.h:36:0,
                 from ./codegen/nv50_ir_util.h:36,
                 from ./codegen/nv50_ir.h:34,
                 from codegen/nv50_ir.cpp:23:
codegen/nv50_ir.cpp: In member function ‘virtual nv50_ir::Instruction* nv50_ir::Instruction::clone(nv50_ir::ClonePolicy<nv50_ir::Function>&, nv50_ir::Instruction*) const’:
codegen/nv50_ir.cpp:742:19: error: cannot use typeid with -fno-rtti
    assert(typeid(*i) == typeid(*this));
                   ^
../../../../src/gallium/auxiliary/util/u_debug.h:188:41: note: in definition of macro ‘debug_assert’
 #define debug_assert(expr) (void)(0 && (expr))
                                         ^
codegen/nv50_ir.cpp:742:4: note: in expansion of macro ‘assert’
    assert(typeid(*i) == typeid(*this));
    ^
codegen/nv50_ir.cpp:742:33: error: cannot use typeid with -fno-rtti
    assert(typeid(*i) == typeid(*this));
                                 ^
../../../../src/gallium/auxiliary/util/u_debug.h:188:41: note: in definition of macro ‘debug_assert’
 #define debug_assert(expr) (void)(0 && (expr))
                                         ^
codegen/nv50_ir.cpp:742:4: note: in expansion of macro ‘assert’
    assert(typeid(*i) == typeid(*this));
    ^
Makefile:1225: recipe for target 'codegen/nv50_ir.lo' failed
Comment 6 Ilia Mirkin 2015-04-14 23:39:34 UTC
(In reply to Felix von Leitner from comment #5)
> Did not help. Here's the error message:
> 
> In file included from
> ../../../../src/gallium/auxiliary/util/u_inlines.h:36:0,
>                  from ./codegen/nv50_ir_util.h:36,
>                  from ./codegen/nv50_ir.h:34,
>                  from codegen/nv50_ir.cpp:23:
> codegen/nv50_ir.cpp: In member function ‘virtual nv50_ir::Instruction*
> nv50_ir::Instruction::clone(nv50_ir::ClonePolicy<nv50_ir::Function>&,
> nv50_ir::Instruction*) const’:
> codegen/nv50_ir.cpp:742:19: error: cannot use typeid with -fno-rtti
>     assert(typeid(*i) == typeid(*this));

If there's a #ifdef rtti type of thing, happy to apply a patch that does puts these asserts into an ifdef. I don't think that nouveau relies on rtti for actual operation.
Comment 7 Jan Vesely 2015-04-14 23:43:25 UTC
(In reply to Ilia Mirkin from comment #6)
> (In reply to Felix von Leitner from comment #5)
> > Did not help. Here's the error message:
> > 
> > In file included from
> > ../../../../src/gallium/auxiliary/util/u_inlines.h:36:0,
> >                  from ./codegen/nv50_ir_util.h:36,
> >                  from ./codegen/nv50_ir.h:34,
> >                  from codegen/nv50_ir.cpp:23:
> > codegen/nv50_ir.cpp: In member function ‘virtual nv50_ir::Instruction*
> > nv50_ir::Instruction::clone(nv50_ir::ClonePolicy<nv50_ir::Function>&,
> > nv50_ir::Instruction*) const’:
> > codegen/nv50_ir.cpp:742:19: error: cannot use typeid with -fno-rtti
> >     assert(typeid(*i) == typeid(*this));
> 
> If there's a #ifdef rtti type of thing, happy to apply a patch that does
> puts these asserts into an ifdef. I don't think that nouveau relies on rtti
> for actual operation.

[0] suggests that __GXX_RTTI should do the trick. not sure how portable it is though.

[0]https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
Comment 8 Felix von Leitner 2015-04-14 23:43:58 UTC
Hah, this is actually quite funny.

src/gallium/auxiliary/util/u_debug.h

185 #ifdef DEBUG
186 #define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
187 #else
188 #define debug_assert(expr) (void)(0 && (expr))
199 #endif


So even if you turn off debugging, you still evaluate expr, which contains the typeid.

I added another line before 188 that #defines typeid(a) to 0, let's see what happens.
Comment 9 Felix von Leitner 2015-04-14 23:45:10 UTC
That fixed that problem, but there is another one:

api/event.cpp: In function ‘cl_int clGetEventProfilingInfo(cl_event, cl_profiling_info, size_t, void*, size_t*)’:
api/event.cpp:255:58: error: ‘dynamic_cast’ not permitted with -fno-rtti
    hard_event &hev = dynamic_cast<hard_event &>(obj(d_ev));
                                                          ^
In file included from ./core/event.hpp:28:0,
                 from api/event.cpp:24:
./core/object.hpp: In instantiation of ‘static void clover::detail::descriptor_traits<T, D>::validate(D*) [with T = clover::soft_event; D = _cl_event]’:
./core/object.hpp:147:50:   required from ‘typename clover::detail::descriptor_traits<T, D>::object_type& clover::obj(D*) [with T = clover::soft_event; D = _cl_event; typename clover::detail::descriptor_traits<T, D>::object_type = clover::soft_event]’
api/event.cpp:42:36:   required from here
./core/object.hpp:71:17: error: ‘dynamic_cast’ not permitted with -fno-rtti
                 !dynamic_cast<object_type *>(o))
                 ^
Makefile:893: recipe for target 'api/libclover_la-event.lo' failed

That appears to be opencl related, not nv50.
Sigh.
Comment 10 Jan Vesely 2015-04-15 17:36:44 UTC
(In reply to Felix von Leitner from comment #9)
> That fixed that problem, but there is another one:
>                  ^
> Makefile:893: recipe for target 'api/libclover_la-event.lo' failed
> 
> That appears to be opencl related, not nv50.
> Sigh.

ah, yes clover is very c++. However, if the original action (linking pipe_r600.la) completed successfully then it's rtti problem in LLVM.

Can you try rebuilding LLVM with the linked llvm patch to make sure rtti is reported correctly and/or building with LLVM_ENABLE_RTTI, either using ccmake, or cmake -DLLVM_ENABLE_RTTI=1 ?
Comment 11 Felix von Leitner 2015-04-15 22:01:37 UTC
Good news! It works now that I recompiled llvm with RTTI support!

I thought I had RTTI in my LLVM but I was doing it wrong.
For the record: the right way to build LLVM with RTTI support is:

cmake [path-to-llvm-sources] -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLLVM_LIBDIR_SUFFIX=64 -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_RTTI=1

(the -DLLVM_ENABLE_RTTI=1 part is the important part)
Comment 12 Vedran Miletić 2017-03-22 16:14:23 UTC
Resolving per comment #11.


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.