使用fno-exceptions构建gcc

时间:2018-01-10 19:22:15

标签: exception gcc build libstdc++

我正在尝试构建gcc5.4.0。我的configure命令如下所示:

../"$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

但不知怎的,似乎在构建时是addind -fno-exceptions,因为当它继续并尝试构建libstdc ++时。所以,configure脚本失败说

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

1 个答案:

答案 0 :(得分:0)

结果“ - disable-bootstrap --with-system-zlib”似乎禁用了异常。删除它们,现在conftest.cpp在使用新gcc生成的程序集中有_Unwind_Resume。谢谢Ulrich Eckhardt。