0

我正在使用 LLVM 编译代码,但编译失败:

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.");
      ^

我意识到我llvm-config正在为我禁用例外。

llvm-config-12 --cxxflags --ldflags --system-libs --libs core

退货

-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

过去,我根本没有观察-fno-exceptions。一个典型的例子应该是这样的。

这种异常预防从何而来?

4

0 回答 0