I was compiling a code using LLVM and it failed compiling:
In file included from main.cpp:8:
In file included from /usr/lib/llvm-12/include/llvm/IR/LLVMContext.h:19:
In file included from /usr/lib/llvm-12/include/llvm/Support/CBindingWrapping.h:17:
/usr/lib/llvm-12/include/llvm/Support/Casting.h:309:7: error: cannot use 'throw' with exceptions disabled
throw runtime_error("Address sanitizer is not turned on.");
^
I realized my llvm-config
is disabling the exceptions for me.
llvm-config-12 --cxxflags --ldflags --system-libs --libs core
Returns
-I/usr/lib/llvm-12/include -std=c++14 -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-L/usr/lib/llvm-12/lib
-lLLVM-12
In the past, I was not observing -fno-exceptions
at all. A typical example should look like this.
Where does this exception prevention come from?