【发布时间】:2018-01-10 19:22:14
【问题描述】:
我正在尝试构建 gcc5.4.0。我的配置命令看起来像这样:
../"$GCC_SRCDIR"/configure --prefix="$PREFIX" --with-sysroot="$PREFIX" --with-gxx-include-dir="$PREFIX/lib64/gcc/$TARGET/$GCC_VER/include" --enable-languages=c,c++ --disable-checking --disable-werror --disable-libmudflap --disable-libssp --disable-nls --disable-multilib --disable-libsanitizer --disable-libgomp --disable-libcilkrts --disable-libquadmath --enable-__cxa_atexit --enable-clocale=gnu --disable-bootstrap --with-system-zlib --with-pic --enable-poison-system-directories --with-plugin-ld=ld.gold
但不知何故,它似乎在构建时添加了 -fno-exceptions,因此当它继续尝试构建 libstdc++.so 时,配置脚本失败说
checking for exception model to use... configure: error: unable to detect exception model
我看到在配置 gcc 时正在打印:
checking whether gcc supports -fno-exceptions... yes`
checking whether gcc supports -fno-rtti... yes
checking whether gcc supports -fasynchronous-unwind-tables... yes
g++ -c -g -O2 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../gcc-5.4.0/gcc -I../../gcc-5.4.0/gcc/build -I../../gcc-5.4.0/gcc/../include -I../../gcc-5.4.0/gcc/../libcpp/include \
-DBASEVER="\"5.4.0\"" -DDATESTAMP="\"\"" \
-DREVISION="\"\"" \
-DDEVPHASE="\"\"" -DPKGVERSION="\"(GCC) \"" \
-DBUGURL="\"<http://gcc.gnu.org/bugs.html>\"" -o build/version.o ../../gcc-5.4.0/gcc/version.c
但我不确定为什么在我没有指定此选项时会采用 -fno-exceptions
更新
我尝试编译conftest.cpp
struct S { ~S(); };
void bar();
void foo()
{
S s;
bar();
}
使用我构建的 gcc5.4.0 和 gcc4.9.2 gcc4.9.2 有这两个 gcc5.4.0 中缺少的元素:
_Unwind_Resume
.cfi_personality
【问题讨论】:
-
您传递给
configure的标志之一是否会导致禁用异常? -
我不这么认为,因为过去构建 gcc-4.9.2 时使用了相同的标志。
-
由于要求是找到最小的完整示例,我建议你不要假设而是找出来!
-
您是否查看了相应的 config.log 以了解异常模型检测如何失败的详细信息? gcc在编译编译器的时候可能会选择使用-fno-exceptions,但是在编译标准库的时候显然不会。
-
config.log 中没有额外的消息。它打印的只是
configure:15141: $? = 0 configure:15170: error: unable to detect exception model配置脚本在 4 个中查找其中之一:_Unwind_SjLj_Resume _Unwind_SjLj_Register _Unwind_Resume __cxa_end_cleanup在生成的 .s 中,但不存在
标签: exception gcc build libstdc++