valhalla
valhalla copied to clipboard
Add CMake option to build Valhalla with `-fno-rtti`
Some projects depending on Valhalla have a requirement to be built with -fno-rtti
flag(for various reasons, mainly due to binary size). In general there are no any issues with Valhalla and -fno-rtti
, but from time to time new changes are introduced in Valhalla which explicitly require RTTI: e.g. those ones which use typeid
or dynamic_cast
(https://github.com/valhalla/valhalla/pull/3191).
The idea is the following:
- Introduce CMake option
DISABLE_RTTI
, which applies-fno-rtti
ifON
. - Configure CI job which would check if Valhalla can be built with
DISABLE_RTTI
.
cc @valhalla/core
@SiarheiFedartsou sorry it didnt occur to me that you guys were disabling rtti. it seems to me that having a cmake flag control it doesnt make sense because even if CI can detect it you'll just have to rewrite your code to work around it. if its a hard requirement downstream we should just avoid it completely and make impossible to opt out of it (though what about our 3rd party dependencies). before we do that i would ask you, how much does it actually save on binary size?
also protobuf is loaded with typeid
, at least the version im compiling that comes with my system. iirc you build protobuf from source and disable rtti for it directly?
@kevinkreiser
also I see we actively use boost::property_tree
which requires RTTI. There is PR in Boost which fixes this, but it is being stuck for 5 years. Don't we want to get rid of this and use something like usual json or strong-typed structure instead? WDYT? I could take this work probably.
@kevinkreiser also I see we actively use
boost::property_tree
which requires RTTI. There is PR in Boost which fixes this, but it is being stuck for 5 years. Don't we want to get rid of this and use something like usual json or strong-typed structure instead? WDYT? I could take this work probably.
if you wonder how do we build Valhalla without RTTI now: we simply use patched version of boost, but want to switch to mainstream
also protobuf is loaded with typeid, at least the version im compiling that comes with my system. iirc you build protobuf from source and disable rtti for it directly?
Yes, we use GOOGLE_PROTOBUF_NO_RTTI
Yes we would like to stop using ptree and use rapidjson everywhere but it's a decent amount of work which is why we haven't already done it. If you are interested in doing some of it that would be great