Build OpenJDK9 on macOS Sierra

獨木發表於2017-07-01

1. Get the source code:

hg clone http://hg.openjdk.java.net/jdk9/jdk9 jdk9
cd jdk9
sh get_source.sh

 

It may fail due to GFW. One alternative solution is fetching the code on an abroad VPS. 

 

2. Build OpenJDK9

 

The gcc command has been used by macOS clang。

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

  

The configure command:

./configure --with-freetype=/usr/local/Cellar/freetype/2.8 --enable-debug --with-target-bits=64 --disable-warnings-as-errors

--with-freetype=/usr/local/Cellar/freetype/2.8

Though freetype is installed via  

brew intall freetype

But script configure cannot find it by default. The freetype prefix has to be specified explicitly.

--disable-warnings-as-errors

To skip compiling error in [1]:

 

instantiation of variable 'TreeChunk<Metachunk, FreeList<Metachunk> >::_min_tree_chunk_size' required here, but no definition is available [-Wundefined-var-template]
    return _min_tree_chunk_size;
           ^

  

It's kind of exciting to see the following messages after so much struggling.

 

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
Compiling 4 files for BUILD_JIGSAW_TOOLS
Stopping sjavac server
Finished building target 'default (exploded-image)' in configuration 'macosx-x86_64-normal-server-fastdebug'

 

The version info of new build java:

$ bin/java --version
openjdk 9-internal
OpenJDK Runtime Environment (fastdebug build 9-internal+0-adhoc.Hu.jdk9)
OpenJDK 64-Bit Server VM (fastdebug build 9-internal+0-adhoc.Hu.jdk9, mixed mode)

 

Reference:

[1] http://mail.openjdk.java.net/pipermail/build-dev/2017-May.txt

相關文章