Bug 109202 - nv50_ir.cpp:749:19: error: cannot use typeid with -fno-rtti
Summary: nv50_ir.cpp:749:19: error: cannot use typeid with -fno-rtti
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2019-01-01 01:16 UTC by Vinson Lee
Modified: 2019-05-02 11:35 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description Vinson Lee 2019-01-01 01:16:06 UTC
meson build error

In file included from ../src/util/bitscan.h:32:0,
                 from ../src/util/u_math.h:49,
                 from ../src/gallium/auxiliary/util/u_box.h:5,
                 from ../src/gallium/auxiliary/util/u_inlines.h:40,
                 from ../src/gallium/drivers/nouveau/codegen/nv50_ir_util.h:36,
                 from ../src/gallium/drivers/nouveau/codegen/nv50_ir.h:34,
                 from ../src/gallium/drivers/nouveau/codegen/nv50_ir.cpp:23:
../src/gallium/drivers/nouveau/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’:
../src/gallium/drivers/nouveau/codegen/nv50_ir.cpp:749:19: error: cannot use typeid with -fno-rtti
    assert(typeid(*i) == typeid(*this));
Comment 1 Dylan Baker 2019-01-01 03:18:19 UTC
You've either added -no-rtti or are using llvm built without rtti. I can make this a hard error.
Comment 2 Ilia Mirkin 2019-01-02 19:04:10 UTC
(In reply to Dylan Baker from comment #1)
> You've either added -no-rtti or are using llvm built without rtti. I can
> make this a hard error.

Out of curiosity, how does the autotools build deal with this?

Also, I think that this only comes up in one assert in nouveau, so when asserts are disabled (e.g. release builds), it wouldn't bring up a compile error.

It would also be fine to add a #ifdef rtti + #warning or something (does one know in the source if rtti is enabled somehow?).
Comment 3 Dylan Baker 2019-01-02 20:08:19 UTC
I don't think that the compiler gives you any way to know, we'd have to pass some a #define ourselves.

autotools just adds it to LLVM targets (radeonsi, llvmpipe, etc). That feels really dangerous to me though, as building with/without rtti changes the ABI and my understanding is that there's no requirement for code with rtti to correctly link with code not using rtti.
Comment 4 Eric Engestrom 2019-05-02 11:35:59 UTC
Marking as FIXED since Dylan made it a meson error to do this:

commit a2596450ac7330c8965c819491038fb1ad454333
Author: Dylan Baker <dylan@pnwbakers.com>
Date:   Mon Dec 31 19:23:52 2018 -0800

    meson: Error out if building nouveau and using LLVM without rtti
    Nouveau requires rtti. Often LLVM is configured without rtti, and code
    with and without cannot be linked safely. Lets just error out if nouveau
    is requested and llvm is built without rtti.
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109202
    Fixes: c5a97d658ec19cc02719d7f86c1b0715e3d9ffc4
           ("meson: fix builds against LLVM built without rtti")
    Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>

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.