Needed compiler settings (disable exceptions, disable RTTI, -std=c++17)

Is it true, that in order for using LLVM one would need the following settings:

  • -fno-exceptions
  • -fno-rtti
  • -std=c++17

Or is this just an artifact of what was used when the LLVM libraries were compiled?
What sense is there in disabling RTTI or exceptions?

And object files compiled with different std settings cannot call into each other?

Thanks

A standard build/installation of LLVM is built without exceptions, without RTTI and with C++17. Exceptions and RTTI and non-zero overhead abstractions and LLVM has its own replacements. LLVM switched from C++14 to C++17 last year, Thus, standard LLVM is built with C++17.

If you want to use, it will cause you less trouble, if you use the same settings. But building you applications with c++20 may work.

Certainly I’ve had to use -std=c++17 to get some LLVM headers to compile. It’s the dialect that LLVM is written in, after all. It does kind of impose that as the minimum dialect on any downstream projects, which is not a consideration that I’ve seen come up in any discussion about the dialect LLVM uses, but it’s an inevitable consequence.

LLVM itself does not make use of RTTI or exceptions, and they carry time and space costs, so that’s why it is built with -fno-rtti -fno-exceptions. My own projects don’t use those either so I have no info about mixing RTTI/exception-using projects with LLVM.