clang: error: unknown argument: '-fno-enforce-eh-specs'

I followed an instruction in the internet to install gcc on my macos after changing the operating system to Big Sur:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd ~
mkdir gcc_all && cd $_
git clone git://gcc.gnu.org/git/gcc.git gcc-10
cd gcc-10
contrib/download_prerequisites
cd ..
mkdir build && cd $_


../gcc-10/configure --prefix=/usr/local/gcc-10 \
              --enable-checking=release \
              --enable-languages=c,c++,fortran \
              --disable-multilib \
              --with-sysroot=/usr/local/gcc_system_root \
              --program-suffix=-10

make -j8 
sudo make install-strip


but just after running make -j8 I am getting this error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/Library/Developer/CommandLineTools/usr/bin/make  all-am
true  DO=all multi-do # /Library/Developer/CommandLineTools/usr/bin/make
test -f config.h || (rm -f stamp-h1 && /Library/Developer/CommandLineTools/usr/bin/make stamp-h1)
g++ -std=c++11 -g -fno-enforce-eh-specs -fno-stack-protector -fno-threadsafe-statics -fno-exceptions -fno-rtti -fdebug-prefix-map=../../gcc-10/libcody/= -W -Wall -include config.h -I../../gcc-10/libcody \
	  -MMD -MP -MF buffer.d -c -o buffer.o ../../gcc-10/libcody/buffer.cc
clang: error: unknown argument: '-fno-enforce-eh-specs'
make[3]: *** [buffer.o] Error 1
make[2]: *** [all-stage1-libcody] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2
/Library/Developer/CommandLineTools/usr/bin/make  all-am
true  DO=all multi-do # /Library/Developer/CommandLineTools/usr/bin/make
test -f config.h || (rm -f stamp-h1 && /Library/Developer/CommandLineTools/usr/bin/make stamp-h1)
g++ -std=c++11 -g -fno-enforce-eh-specs -fno-stack-protector -fno-threadsafe-statics -fno-exceptions -fno-rtti -fdebug-prefix-map=../../gcc-10/libcody/= -W -Wall -include config.h -I../../gcc-10/libcody \
	  -MMD -MP -MF buffer.d -c -o buffer.o ../../gcc-10/libcody/buffer.cc
clang: error: unknown argument: '-fno-enforce-eh-specs'
make[3]: *** [buffer.o] Error 1
make[2]: *** [all-stage1-libcody] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

I searched the error but I couldn't find a way to solve the problem. Any suggestion?
It appears you're trying to build gcc using clang, right?
I'm not too knowledgeable in mac/clang, but it would appear that your g++, despite its name, is actually a symbolic link to clang++ or otherwise renamed from clang++.

-fno-enforce-eh-specs is not supported on clang (at least, that's what a cursory search tells me)
http://clang-developers.42468.n3.nabble.com/Does-clang-support-fno-enforce-eh-specs-option-of-gcc-td4028196.html

That specific flag refers to how old versions of the standard would allow constructs like:
void func() throw(foo);, and if something besides a foo is thrown, then std::unexpected is called (which I think calls std::terminate). That flag would remove this run-time check. But this usage has been deprecated and (I think?) removed as of the latest standards, although compiler extensions might still allow it to compile for backwards compatibility.

If you can't get it to work, I'd either follow a different tutorial that assumes you're using clang++ instead of g++, or try to remove that flag from the build script manually.
Last edited on
Topic archived. No new replies allowed.