gcc: error: unrecognized command line option '-mstack-alignment=16' when building openjdk9 on MacOSX
<p>I want to build jdk9 but I encountered the following problem.
I am using gcc&amp;g++ version 5.3.0 (Homebrew gcc 5.3.0) on OSX El Capitan.
I also tried using 4.9.3, but still the same.</p>

<p>Here is how I met the problem:</p>

<pre><code>➜openjdk9 bash ./configure --enable-native-coverage --with-toolchain-type=gcc -disable-warnings-as-errors
➜openjdk9 cd build/macosx-x86_64-normal-server-release
➜macosx-x86_64-normal-server-release make
</code></pre>

<p>Then I got the following error log:</p>

<pre><code>Building target 'default (exploded-image)' in configuration 'macosx-x86_64-normal-server-release'
Building JVM variant 'server' with features 'all-gcs cds compiler1 compiler2 dtrace fprof jni-check jvmci jvmti management nmt services vm-structs'
Compiling 8 files for BUILD_TOOLS_LANGTOOLS
Creating adlc from 13 file(s)
Compiling 2 files for BUILD_JVMTI_TOOLS
Creating libjsig.dylib from 1 file(s)
gcc: error: unrecognized command line option '-mstack-alignment=16'
make[4]: *** [/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/build/macosx-x86_64-normal-server-release/hotspot/libjsig/objs/jsig.o] Error 1
make[3]: *** [jsig] Error 2
make[3]: *** Waiting for unfinished jobs....
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp: In constructor 'Arena::Arena(size_t)':
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:31:7: error: non-placement deallocation function 'static void Chunk::operator delete(void*, size_t)' [-fpermissive]
 void  Chunk::operator delete(void* p, size_t length) {
       ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:60:52: error: selected for placement delete [-fpermissive]
   _first = _chunk = new (init_size) Chunk(init_size);
                                                    ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp: In constructor 'Arena::Arena()':
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:31:7: error: non-placement deallocation function 'static void Chunk::operator delete(void*, size_t)' [-fpermissive]
 void  Chunk::operator delete(void* p, size_t length) {
       ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:67:66: error: selected for placement delete [-fpermissive]
   _first = _chunk = new (Chunk::init_size) Chunk(Chunk::init_size);
                                                                  ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp: In member function 'void* Arena::grow(size_t)':
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:31:7: error: non-placement deallocation function 'static void Chunk::operator delete(void*, size_t)' [-fpermissive]
 void  Chunk::operator delete(void* p, size_t length) {
       ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:97:31: error: selected for placement delete [-fpermissive]
   _chunk = new (len) Chunk(len);
                               ^
make[4]: *** [/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/build/macosx-x86_64-normal-server-release/hotspot/variant-server/tools/adlc/objs/arena.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [variant-server-gensrc] Error 2
make[2]: *** [hotspot] Error 1
make[2]: *** Waiting for unfinished jobs....

ERROR: Build failed for target 'default (exploded-image)' in configuration 'macosx-x86_64-normal-server-release' (exit code 2)
=== Output from failing command(s) repeated here ===
* For target hotspot_libjsig_objs_jsig.o:
gcc: error: unrecognized command line option '-mstack-alignment=16'
* For target hotspot_variant-server_tools_adlc_objs_arena.o:
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp: In constructor 'Arena::Arena(size_t)':
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:31:7: error: non-placement deallocation function 'static void Chunk::operator delete(void*, size_t)' [-fpermissive]
 void  Chunk::operator delete(void* p, size_t length) {
       ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:60:52: error: selected for placement delete [-fpermissive]
   _first = _chunk = new (init_size) Chunk(init_size);
                                                    ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp: In constructor 'Arena::Arena()':
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:31:7: error: non-placement deallocation function 'static void Chunk::operator delete(void*, size_t)' [-fpermissive]
 void  Chunk::operator delete(void* p, size_t length) {
       ^
/Users/weizhaoy/Documents/STAP/Research/jdk9/openjdk9/hotspot/src/share/vm/adlc/arena.cpp:67:66: error: selected for placement delete [-fpermissive]
   ... (rest of output omitted)
=== End of repeated output ===
No indication of failed target found.
Hint: Try searching the build log for '] Error'.
Hint: If caused by a warning, try configure --disable-warnings-as-errors.

make[1]: *** [main] Error 1
make: *** [default] Error 2
</code></pre>

<p>But when I used the <code>--enable-debug --disable-warnings-as-errors</code> configuration and <code>make</code> the resulting target, there was no error.</p>

<p>Looks like it may have something to do with the <code>--enable-native-coverage</code> option and the <code>-with-toolchain-type=gcc</code> option, considering by default the toolchain would be <code>clang</code> (but the toolchain must be <code>gcc</code> to make <code>--enable-native-coverage</code> work), but how do I fix it?</p>