Bug 70471 - undefined reference to `typeinfo for llvm::format_object_base'
Summary: undefined reference to `typeinfo for llvm::format_object_base'
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: git
Hardware: x86-64 (AMD64) All
: medium blocker
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2013-10-15 04:32 UTC by Vinson Lee
Modified: 2013-10-16 03:11 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
fix revision 1 (1.55 KB, text/plain)
2013-10-15 07:26 UTC, Alexander von Gluck
Details

Description Vinson Lee 2013-10-15 04:32:34 UTC
mesa: ce8eadb6e8adc24f675b364e0620dbf1c9e079a8 (master)

$ scons
[...]
  Linking build/linux-x86_64-debug/gallium/drivers/llvmpipe/lp_test_arit ...
build/linux-x86_64-debug/gallium/auxiliary/libgallium.a(lp_bld_debug.os):(.data.rel.ro._ZTIN4llvm14format_object1ImEE[_ZTIN4llvm14format_object1ImEE]+0x10): undefined reference to `typeinfo for llvm::format_object_base'
build/linux-x86_64-debug/gallium/auxiliary/libgallium.a(lp_bld_debug.os):(.data.rel.ro._ZTI18BufferMemoryObject[_ZTI18BufferMemoryObject]+0x10): undefined reference to `typeinfo for llvm::MemoryObject'
build/linux-x86_64-debug/gallium/auxiliary/libgallium.a(lp_bld_debug.os):(.data.rel.ro._ZTI17raw_debug_ostream[_ZTI17raw_debug_ostream]+0x10): undefined reference to `typeinfo for llvm::raw_ostream'


ce8eadb6e8adc24f675b364e0620dbf1c9e079a8 is the first bad commit
commit ce8eadb6e8adc24f675b364e0620dbf1c9e079a8
Author: Alexander von Gluck IV <kallisti5@unixzen.com>
Date:   Sat Oct 12 17:12:31 2013 +0000

    build: remove forced -fno-rtti
    
    * As discussed on the mailing list,
      forced no-rtti breaks C++ public
      API's such as the Haiku C++ libGL.so
    * -fno-rtti *can* be still set however
      instead of blindly forcing -fno-rtti,
      we can rely on the llvm-config
      --cppflags output.
      If the system llvm is built without
      rtti (default), the no-rtti flag will be
      present in llvm-config --cppflags
      (which we pick up on)
      If llvm is built with rtti
      (REQUIRES_RTTI=1), then -fno-rtti is
      removed from llvm-config --cppflags.
    * We could selectively add / remove rtti
      from various components, however mixing
      rtti and non-rtti code is tricky and
      could introduce missing symbols.
    * This needs impact tested.
    
    Reviewed-by: Francisco Jerez <currojerez@riseup.net>

:100644 100644 c68e14b44c0bc24a74e4f5870562454ac4389846 309b49385ba2dfe16d3a55f98b181ce7ba9d0348 M	configure.ac
:040000 040000 d72fe30b21c27539e9f03703b0f53967321e4e47 b65a235d75fa650f6545b2416f35ee92468a66db M	scons
:040000 040000 02c9dba57101dfb777d34fb8393623c6dd2c923b f9810052c6cd076b6644f99aa86805939ec0e563 M	src
bisect run success
Comment 1 Alexander von Gluck 2013-10-15 05:36:50 UTC
Odd. This looks like non-rtti code is getting linked against rtti code.

Was this a clean build of mesa?  (aka, running scons -c before running scons)  I don't think the build system will pick up on changes in cflags / cppflags

If this was a clean build, could you grab the output of llvm-config --cppflags
Comment 2 Alexander von Gluck 2013-10-15 05:42:52 UTC
Just did a clean mesa build on my ArchLinux machine + LLVM 3.3.  No issues seen.
Comment 3 Vinson Lee 2013-10-15 05:44:30 UTC
The build failure occurs with a clean build.

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.04
DISTRIB_CODENAME=raring
DISTRIB_DESCRIPTION="Ubuntu 13.04"

$ llvm-config --cppflags
-I/usr/lib/llvm-3.2/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS

$ llvm-config --cflags
-I/usr/lib/llvm-3.2/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -fPIC

$ llvm-config --cxxflags
-I/usr/lib/llvm-3.2/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual

$ llvm-config --ldflags
-L/usr/lib/llvm-3.2/lib  -lpthread -lffi -ldl -lm
Comment 4 Alexander von Gluck 2013-10-15 06:05:10 UTC
hm.. do you get the same results using the ./configure and a make?
Comment 5 Vinson Lee 2013-10-15 06:08:46 UTC
(In reply to comment #4)
> hm.. do you get the same results using the ./configure and a make?

configure and make passes for me.
Comment 6 Alexander von Gluck 2013-10-15 07:26:00 UTC
Created attachment 87648 [details]
fix revision 1

It's now the wee hours of the morning.  Please try the fix attached.  If it works i'll send it to mesa-dev in the morning after I get some sleep.

The LLVM_CPPFLAGS and LLVM_CXXFLAGS are used in the autotools scrips, while only LLVM_CPPFLAGS is used in scons. Removing the rtti made this bug float to the top.

We can't simply apply CXX flags to everything as they are C++ only.  The patch attached should apply the CXX flags only where needed (kind of like how the autotools one works.. src/gallium/auxiliary and gallium/drivers/llvmpipe)

If this doesn't solve the issue, let me know and i'll try other solutions and maybe setup a Debian / Ubuntu machine. (all of the machines I have locally have RTTI enabled in llvm)
Comment 7 Vinson Lee 2013-10-15 17:01:19 UTC
attachment 87648 [details] fixes the build.

Tested-by: Vinson Lee <vlee@freedesktop.org>
Comment 8 Alexander von Gluck 2013-10-16 03:11:28 UTC
Fix applied in 94d05bf. Thanks for finding this Vinson!


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.