Hi all, currently (-> llvm 19.1.4) i cannot have both flag-new and llvm exceptions in the same build. Ist there any work in progress effort about this?
Thx Franz
What exactly do you mean by this?
If i build llvm (version 19.1.4) with flang enabled and LLVM_ENABLE_EH=ON cmake bails out with an error saying that this is not supported yet.
Could you post the exact error message. Does this occur with the current main branch as well?
It is better to use the main branch for flang. Issues that are present in the releases may have already been fixed on the main branch.
It’s disable because the flang runtime does not link with the C++ std lib and does not use exception.
So if i want 1) to program (base) llvm with exceptions and 2) use flang i need two different llvm installations?
You only need LLVM_ENABLE_EH on if you’re writing your own code with exceptions that might propagate up through LLVM functions. If you’re only calling down into LLVM it’s safe to not have it enabled even if your own code has exceptions enabled.
In the actual LLVM source, exceptions are never thrown not caught in either case. So adding the flag doesn’t get you any extra error handling or anything.
OK thanks. Does the same (mutatis mutandis) apply to enabling RTTI (for llvm)?
I don’t think it is safe to mix RTTI enabled code and non-RTTI enabled code; for example if you try to inherit from a class in a library that was built without RTTI and you are using RTTI then things will fail.
LLVM has its own RTTI-like things you can use without enabling RTTI though.
It’s possible that we could remove the cmake error and allow compiling flang with EH/RTTI but unconditionally disable them in the Runtimes so they still aren’t used there. That might be a better solution that blanket disabling them.
In general, though, if you want to use clang/flang as compilers, and you also want to use LLVM as a library for your own project with RTTI/EH enabled, I would recommend having a separate build for those two things. The performance of your clang/flang built with RTTI/EH will likely be lower than without, and for no benefit to them as compilers. Also, even clang isn’t tested anywhere near as extensively with RTTI/EH as without. So having a separate build of LLVM for library usage would probably be better; bear in mind that that build of LLVM would only need ENABLE_PROJECTS to contain the things you want to actually use as libraries (or even be empty if you only want to use things from the llvm/ subdir) and so won’t be as big or take as long to build as one that includes flang and clang!
Thanks again