Я хочу собрать jdk9, но столкнулся со следующей проблемой.
Я использую gcc&g ++ версия 5.3.0 (Homebrew gcc 5.3.0) на OSX El Capitan.
Я также пытался использовать 4.9.3, но все тот же.
Вот как я встретил проблему:
➜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
Затем я получил следующий журнал ошибок:
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
Но когда я использовал --enable-debug --disable-warnings-as-errors
конфигурация и make
В полученной цели ошибки не было.
Похоже, это как-то связано с --enable-native-coverage
вариант и -with-toolchain-type=gcc
вариант, учитывая, что по умолчанию набор инструментов будет clang
(но набор инструментов должен быть gcc
делать --enable-native-coverage
работать), но как мне это исправить?
-mstack-alignment=n
опция лязга, не распознаваемая gcc.
Соответствующая опция gcc -mpreferred-stack-boundary=n
.
Обратите внимание, что они не являются точно синонимами. За -mstack-alignment=n
, n
это просто желаемое количество выравнивания. За -mpreferred-stack-boundary=n
,
2 ^n
желаемое количество выравнивания, так что:
-mstack-alignment=16 = -mpreferred-stack-boundary=4
Обратите внимание, что n
= 4 по умолчанию для -mpreferred-stack-boundary
, поэтому для gcc вы можете просто пропустить эту опцию.
Других решений пока нет …