前言

最近拜读《深入理解Java虚拟机》一书。书中第一章要求,自己编译Java虚拟机。我尝试的编译了一下,发现随着Mac和Code版本的不断更新,要做到编译书中提及的OpenJDK1.7已经非常的困难。至此,将编译过程纪录于此,以慰后继来者。

PS: 编译的整个流程花费了2天多的时间,准备周日晚上编译完就睡的,结果编译到第二天白天还没完成。编译期间失败大概有100多次,最后还是将问题一一解决了。不要放弃,有可能解决了这个问题,下一步就是成功!
另外,听说Mac当前版本编译OpenJDK1.9较为容易,大家未开始前可以转编译OpenJDK1.9过程会容易一下。


环境准备

  • Mac 10.14
  • XCode 10.1
  • Command_Line_Tools_macOS_10.14_for_Xcode_10.1.dmg
  • Cups 2.2.9
  • Ant 1.7.1
  • Bootstrap JDK 1.7.0_75/1.8.0_102

各文件下载地址:
OpenJDK源码
Mac阵营(XCode & Command_Line_Tools)
Cups
Cups Github
Ant
JDK

注: 1.Oracle JDK 1.6没有Mac版本的官方版,linux版本的我没装上。
2. OpenJDK没使用hg这样的管理工具,直接下载的现成的包。我下载的版本为openjdk-7u75-src-b13-18_dec_2014.zip


环境变量设置

export LANG=C

#export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home


#export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

#1.7.0.jdk
export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

#export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
#jdk1.7.0_75.jdk

export ALLOW_DOWNLOADS=true

export HOTSPOT_BUILD_JOBS=4
export ALT_PARALLEL_COMPILE_JOBS=4

export SKIP_COMPARE_IMAGES=true

export USE_PRECOMPILED_HEADER=true

export BUILD_LANGTOOLS=true
#export BUILD_JAXP=false
#export BUILD_JAXWS=false
#export BUILD_CORBA=false
export BUILD_HOTSPOT=true
export BUILD_JDK=true

#export SKIP_DEBUG_BUILD=false
#export SKIP_FASTDEBUG_BUILD=true
#export DEBUG_NAME=debug

export BUILD_DEPLOY=false
export BUILD_INSTALL=false
export ALT_OUTPUTDIR=/Users/Sean/Software/OpenJDK/build

unset JAVA_HOME
unset CLASSPATH

make 2>&1 | tee $ALT_OUTPUTDIR/build.log

执行最后make命令操作前,可以make sanity查看下环境变量是否有错误发生。
查看编译过程 用于定位问题:
make --debug=all 2>&1 | tee $ALT_OUTPUTDIR/build.log
选择llvm-c++安装

第二种调试命令
make CC=clang COMPILER_WARNINGS_FATAL=false LFLAGS=’-Xlinker -lstdc++’ USE_CLANG=true LP64=1 LANG=C ALT_BOOTDIR=$JAVA_HOME ARCH_DATA_MODEL=64 HOTSPOT_BUILD_JOBS=8 all


问题纪录

  • Q1. make: *** No targets specified and no makefile found. Stop.

因为make命令执行的目录下没有Makefile文件,到根目录执行即可。

  • Q2. org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0

(cd  ./langtools/make && \
	  /Library/Developer/CommandLineTools/usr/bin/make JDK_TOPDIR=/Users/Sean/Software/OpenJDK/openjdk/jdk JDK_MAKE_SHARED_DIR=/Users/Sean/Software/OpenJDK/openjdk/jdk/make/common/shared EXTERNALSANITYCONTROL=true SOURCE_LANGUAGE_VERSION=7 TARGET_CLASS_VERSION=7 MILESTONE=internal BUILD_NUMBER=b00 JDK_BUILD_NUMBER=b00 FULL_VERSION=1.7.0-internal-sean_2018_12_03_04_40-b00 PREVIOUS_JDK_VERSION=1.6.0 JDK_VERSION=1.7.0 JDK_MKTG_VERSION=7 JDK_MAJOR_VERSION=1 JDK_MINOR_VERSION=7 JDK_MICRO_VERSION=0 PREVIOUS_MAJOR_VERSION=1 PREVIOUS_MINOR_VERSION=6 PREVIOUS_MICRO_VERSION=0 ARCH_DATA_MODEL=64 COOKED_BUILD_NUMBER=0 ALT_OUTPUTDIR=/Users/Sean/Software/OpenJDK/build/langtools ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home all)
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home ANT_OPTS=-Djava.io.tmpdir='/Users/Sean/Software/OpenJDK/build/langtools/build/ant-tmp' ant -Djdk.version=1.7.0 -Dfull.version='1.7.0-internal-sean_2018_12_03_04_40-b00'  -Dmilestone=internal -Dbuild.number=b00 -Djavac.target=7 -Djavac.source=7 -Dboot.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home -Dimport.jdk=/Users/Sean/Software/OpenJDK/openjdk/jdk -Dbuild.dir=/Users/Sean/Software/OpenJDK/build/langtools/build -Ddist.dir=/Users/Sean/Software/OpenJDK/build/langtools/dist build
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
make[2]: *** [build] Error 1
make[1]: *** [langtools-build] Error 2
make: *** [build_product_image] Error 2

因为使用低版本的JDK去解析高版本的Jar包文件导致,我的是因为Ant版本过高导致,转成1.7.1即可。我知道你们都喜欢brew install ant,但是还是brew uinstall ant,然后手动安装吧。

参考:
1. spring boot项目创建过程中遇到的问题(一):Exception in thread “main” java.lang.UnsupportedClassVersionError
执行ant命令报错Unsupported major.minor version 52.0
使用Ant编译遇到的问题

  • Q3. freetype错误/ALSA(声卡)错误
ERROR: FreeType version  2.3.0  or higher is required.
/bin/mkdir -p /Users/Sean/Software/OpenJDK/build/btbins
rm -f /Users/Sean/Software/OpenJDK/build/btbins/freetype_versioncheck
Failed to build freetypecheck.

ERROR: You do not have access to valid Cups header files.
     Please check your access to
          /usr/include/cups/cups.h
      and/or check your value of ALT_CUPS_HEADERS_PATH,
      CUPS is frequently pre-installed on many systems,
      or may be downloaded from http://www.cups.org

Exiting because of the above error(s).

make: *** [post-sanity] Error 1

Mac 新版本安装Quartz即可,下载地址:Quartz
第一章 Mac os下编译openJDK 7
自己编译JDK的时候遇到的问题记录

  • Q4. build 问题
build-bootstrap-javac:
    [javac] Compiling 134 source files to /Users/Sean/Software/OpenJDK/build/langtools/build/bootstrap/classes
    [javac] /Users/Sean/Software/OpenJDK/openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java:2182: 警告: [overrides] 类Resolve.InapplicableSymbolsError.Candidate覆盖了 equals, 但该类或任何超类都未覆盖 hashCode 方法
    [javac]         private class Candidate {
    [javac]                 ^
    [javac] 错误: 发现警告, 但指定了 -Werror
    [javac] 1 个错误
    [javac] 1 个警告

BUILD FAILED
/Users/Sean/Software/OpenJDK/openjdk/langtools/make/build.xml:452: The following error occurred while executing this line:
/Users/Sean/Software/OpenJDK/openjdk/langtools/make/build.xml:795: Compile failed; see the compiler error output for details.

Total time: 4 seconds

解决办法:不太记得怎么解决的。貌似jdk1.8换成jdk1.7,还是freetype没装导致。

  • Q5. 乱码问题
/Users/Sean/Software/OpenJDK/build/corba/gensrc/com/sun/corba/se/spi/activation/Locator.java:6: 错误: 编码ascii的不可映射字符
* ���IDL-to-Java ��������� (���������), ������ "3.2"������
 ^

查看上下文可以发现:

 BOOT_JAVAC_CMD = /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/javac  -J-XX:ThreadStackSize=1536 -J-XX:-PrintVMOptions -J-XX:+UnlockDiagnosticVMOptions -J-XX:-LogVMOutput -J-Djava.awt.headless=true -J-Xmx512m -J-Xms512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -encoding ascii -source 6 -target 6 -XDignore.symbol.file=true
JAVAC_CMD = /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Djava.awt.headless=true -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -Xbootclasspath/p:/Users/Sean/Software/OpenJDK/build/langtools/dist/bootstrap/lib/javac.jar -jar /Users/Sean/Software/OpenJDK/build/langtools/dist/bootstrap/lib/javac.jar  -source 7 -target 7 -encoding ascii -Xbootclasspath:/Users/Sean/Software/OpenJDK/build/classes

里面的编码是ascii,在文件下搜索ascii,然后都改成utf-8即可。
其次,还不放心,添加encoding编译
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
参考:
关于编译openjdk过程的一个编码错误

  • Q6. ALT_CUPS_HEADERS_PATH | cups错误

下载cups,并且export ALT_CUPS_HEADERS_PATH=xxx
参考:
mac下编译openjdk1.7经验

  • Q7. llvm-gcc & llvm-g++
make: *** [post-sanity] Error 1
sh-3.2# ./openjdk_install.sh
/bin/sh: /Library/Developer/CommandLineTools/usr/bin/llvm-gcc: No >such file or directory
/bin/sh: /Library/Developer/CommandLineTools/usr/bin/llvm-gcc: No >such file or directory

/bin/sh: /Library/Developer/CommandLineTools/usr/bin/llvm-g++: No such file or directory
make[5]: *** [/Users/Sean/Software/OpenJDK/build/tmp/sun/javax.sound/jsound/obj64/PLATFORM_API_MacOSX_Utils.o] Error 127
make[5]: *** Waiting for unfinished jobs....
3 warnings generated.
18 warnings generated.

解决办法:
sudo ln -s /usr/bin/llvm-g++ /Library/Developer/CommandLineTools/usr/bin/llvm-g++
sudo ln -s /usr/bin/llvm-gcc /Library/Developer/CommandLineTools/usr/bin/llvm-gcc

  • Q8. warning 转义错误
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/formssel.cpp:3352:8: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]
 if( !this ) return;
     ~^~~~
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/output_c.cpp:3062:33: warning: '&&' within '||' [-Wlogical-op-parentheses]
       instr->_matrule != NULL &&
       ~~~~~~~~~~~~~~~~~~~~~~~~^~
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/output_c.cpp:3062:33: note: place parentheses around the '&&' expression to silence this warning
       instr->_matrule != NULL &&
                               ^
       (
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/output_c.cpp:3779:18: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
   while ( comp = comp_list.post_match_iter() ) {
           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/output_c.cpp:3779:18: note: place parentheses around the assignment to silence this warning
   while ( comp = comp_list.post_match_iter() ) {
                ^
           (                                 )
/Users/Sean/Software/OpenJDK/openjdk/hotspot/src/share/vm/adlc/output_c.cpp:3779:18: note: use '==' to turn this assignment into an equality comparison
   while ( comp = comp_list.post_match_iter() ) {
                ^
                ==
1 warning generated.
2 warnings generated.
2 warnings generated.
Making adlc
llvm-g++ -Xlinker -lstdc++ -m64 -o ../generated/adfiles/adlc ../generated/adfiles/adlparse.o ../generated/adfiles/archDesc.o ../generated/adfiles/arena.o ../generated/adfiles/dfa.o ../generated/adfiles/dict2.o ../generated/adfiles/filebuff.o ../generated/adfiles/forms.o ../generated/adfiles/formsopt.o ../generated/adfiles/formssel.o ../generated/adfiles/main.o ../generated/adfiles/adlc-opcodes.o ../generated/adfiles/output_c.o ../generated/adfiles/output_h.o
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[8]: *** [../generated/adfiles/adlc] Error 1
make[7]: *** [ad_stuff] Error 2
make[6]: *** [product] Error 2
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
make[2]: *** [universal_product] Error 2
make[1]: *** [hotspot-build] Error 2
make: *** [build_product_image] Error 2

关掉warning警告,继续执行即可。
export COMPILER_WARNINGS_FATAL=false
参考:
第一章 Mac os下编译openJDK 7

  • Q9. ld: library not found for -lstdc++
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:1965:41: note: 'CMDeviceProfileID' has been explicitly marked deprecated here
typedef UInt32                          CMDeviceProfileID DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
                                        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:2020:3: warning: 'CMProfileLocation' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
  CMProfileLocation   profileLoc;             /* The profile's location */
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:1602:3: note: 'CMProfileLocation' has been explicitly marked deprecated here
} CMProfileLocation DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:2022:3: warning: 'CMDeviceProfileScope' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
  CMDeviceProfileScope  profileScope;         /* The scope this profile applies to */
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:1986:18: note: 'CMDeviceProfileScope' has been explicitly marked deprecated here
} CMDeviceScope, CMDeviceProfileScope DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:2034:3: warning: 'CMDeviceProfileInfo' is deprecated: first deprecated in macOS 10.6 [-Wdeprecated-declarations]
  CMDeviceProfileInfo  profiles[1];           /* The profile info records */
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks/QD.framework/Headers/ColorSyncDeprecated.h:2015:3: note: 'CMDeviceProfileInfo' has been explicitly marked deprecated here
} CMDeviceProfileInfo DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER;
  ^
/Users/Sean/Software/OpenJDK/openjdk/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m:27:9: fatal error: 'JavaNativeFoundation/JavaNativeFoundation.h' file not found
#import <JavaNativeFoundation/JavaNativeFoundation.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 warnings and 1 error generated.
make[8]: *** [libsaproc.dylib] Error 1
make[8]: *** Waiting for unfinished jobs....
660 warnings generated.
make[7]: *** [the_vm] Error 2
make[6]: *** [product] Error 2
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
make[2]: *** [universal_product] Error 2
make[1]: *** [hotspot-build] Error 2
make: *** [build_product_image] Error 2

修改:Software⁩ ▸ ⁨OpenJDK⁩ ▸ ⁨openjdk⁩ ▸ ⁨hotspot⁩ ▸ ⁨make⁩ ▸ ⁨bsd⁩ ▸ ⁨makefiles⁩/saproc.make 文件内

>#/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks
#OTHER_CFLAGS = \
#         -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
#       -F/System/Library/Frameworks/CoreGraphics.framework \
#	     -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks

OTHER_CFLAGS = \
      -F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Frameworks \
      -F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Frameworks \
     -F/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Frameworks

注意后面的地址写成自己的仓库地址即可。

  • Q10. 类库问题2
make[5]: Nothing to be done for `sources'.
Building lib:/Users/Sean/Software/OpenJDK/build/lib/libjava.dylib
Begin parallel compiles: /Users/Sean/Software/OpenJDK/openjdk/jdk/make/java/java
/Library/Developer/CommandLineTools/usr/bin/llvm-gcc -Os -x objective-c    -fno-strict-aliasing -fPIC -W -Wall  -Wno-unused -Wno-parentheses -pipe -m64 -fno-omit-frame-pointer -D_LITTLE_ENDIAN -F/System/Library/Frameworks/JavaVM.framework/Frameworks -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks -I/usr/X11R6/include -D_DARWIN_UNLIMITED_SELECT -DJDK_MAJOR_VERSION='"1"' -DJDK_MINOR_VERSION='"7"' -DJDK_MICRO_VERSION='"0"' -DJDK_BUILD_NUMBER='"b00"'   -DNDEBUG -DARCH='"x86_64"' -Dx86_64 -D_ALLBSD_SOURCE -DRELEASE='"1.7.0-internal"' -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT -DMACOSX -D_LP64=1 -I/usr/X11R6/include -D_DARWIN_UNLIMITED_SELECT -I. -I/Users/Sean/Software/OpenJDK/build/tmp/java/java.lang/java/CClassHeaders -I../../../src/macosx/javavm/export -I../../../src/share/javavm/export -I../../../src/share/native/java/lang/fdlibm/include -I../../../src/share/native/java/io -I../../../src/solaris/native/java/io -I../../../src/solaris/native/java/util -I../../../src/share/native/common -I../../../src/solaris/native/common -I../../../src/share/native/java/lang -I../../../src/solaris/native/java/lang -DRELEASE='"1.7.0-internal"' -DARCHPROPNAME='"x86_64"' -DALT_CODESET_KEY=_NL_CTYPE_CODESET_NAME    -c -o /Users/Sean/Software/OpenJDK/build/tmp/java/java.lang/java/obj64/java_props_macosx.o  ../../../src/solaris/native/java/lang/java_props_macosx.c
In file included from ../../../src/solaris/native/java/lang/java_props_macosx.c:34:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:48:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSKeyedArchiver.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:12:9: fatal error: 'CoreGraphics/CGBase.h' file not found
#import <CoreGraphics/CGBase.h>
        ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [/Users/Sean/Software/OpenJDK/build/tmp/java/java.lang/java/obj64/java_props_macosx.o] Error 1
make[4]: *** [library_parallel_compile] Error 2
make[3]: *** [all] Error 1
make[2]: *** [all] Error 1
make[1]: *** [jdk-build] Error 2
make: *** [build_product_image] Error 2

解决办法 同上 改地址即可。

  • Q11. openjdk ‘JavaNativeFoundation/JavaNativeFoundation.h’ file not found

因为Xcode之前有 xxx-for-java-command-lines-tools安装包,然后所有的仓库地址都是System/Library/Frameworks/,现在全部改成/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/了,所以参考上面这个改正一下即可。
解决办法 同上具体地址可以sudo su ; cd /; find . -name "*JavaNativeFoundation.h*"查找一下就能发现了。
参考:
JDK7 build on mac os fails: JavaNativeFoundation.h: No such file

  • Q12. openjdk note: expanded from macro ‘NEW_C_HEAP_ARRAY2’

因为变量被删除了 改正即可。
MacosxDebuggerLocal.m 文件491行左右
Macintosh HD⁩ ▸ ⁨用户⁩ ▸ ⁨Sean⁩ ▸ ⁨Software⁩ ▸ ⁨OpenJDK⁩ ▸ ⁨openjdk⁩ ▸ ⁨hotspot⁩ ▸ ⁨agent⁩ ▸ ⁨src⁩ ▸ ⁨os⁩ ▸ ⁨bsd⁩

//if ((res = ptrace(PT_ATTACH, pid, 0, 0)) < 0) {
  if ((res = 10) < 0) {

参考:
Mac OSX 10.12.1 编译 Openjdk 9

  • Q13. clang: error: unknown argument: ‘-fpch-deps’

Macintosh HD⁩ ▸ ⁨用户⁩ ▸ ⁨Sean⁩ ▸ ⁨Software⁩ ▸ ⁨OpenJDK⁩ ▸ ⁨tmp⁩ ▸ ⁨openjdk⁩ ▸ ⁨hotspot⁩ ▸ ⁨make⁩ ▸ ⁨bsd⁩ ▸ ⁨makefiles⁩>gcc.make

hotspot/make/bsd/makefiles/gcc.make(line 334)
diff --git a/src/share/vm/code/relocInfo.hpp b/src/share/vm/code/relocInfo.hpp
--- a/src/share/vm/code/relocInfo.hpp
+++ b/src/share/vm/code/relocInfo.hpp
@@ -364,7 +364,7 @@
 // "immediate" in the prefix header word itself.  This optimization
  // is invisible outside this module.)

-  inline friend relocInfo prefix_relocInfo(int datalen = 0);
+  inline friend relocInfo prefix_relocInfo(int datalen);

protected:
// an immediate relocInfo optimizes a prefix with one 10-bit unsigned value
@@ -459,7 +459,7 @@
 return relocInfo(relocInfo::none, relocInfo::offset_limit() - relocInfo::offset_unit);
}

-inline relocInfo prefix_relocInfo(int datalen) {
+inline relocInfo prefix_relocInfo(int datalen = 0) {
  assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
  return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
}

参考:
Mac OSX 10.9 上build openjdk8和openjdk7
8033057: clang: friend declaration specifying a default argument must be a definition
Reviewed-by:

  • Q14. 编译库dylib错误
make[9]: `/Users/Sean/Software/OpenJDK/build/hotspot/outputdir/bsd_amd64_compiler2/product/../generated/sa-jdi.jar' is up to date.
echo "dtrace headers generated"
dtrace headers generated
make[8]: `precompiled.hpp.gch' is up to date.
echo "Doing vm.make build:"
Doing vm.make build:
All done.
cd bsd_amd64_compiler2/product && ./test_gamma
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Error occurred during initialization of VM
Unable to load native library: dlopen(/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libjava.dylib, 1): Symbol not found: _JVM_GetClassTypeAnnotations
  Referenced from: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libjava.dylib
  Expected in: ./libjvm.dylib
 in /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libjava.dylib
Using java runtime at: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
make[6]: *** [product] Error 1
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
make[2]: *** [universal_product] Error 2
make[1]: *** [hotspot-build] Error 2
make: *** [build_product_image] Error 2
localhost:openjdk Sean$ export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

删除重新编译,可能和之前的错误有关导致的中间错误。

  • Q15. 32位显卡问题
/Library/Developer/CommandLineTools/usr/bin/llvm-gcc -arch x86_64 -DNDEBUG -DARCH='"x86_64"' -Dx86_64 -D_ALLBSD_SOURCE -DRELEASE='"1.7.0-internal"' -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT -DMACOSX -D_LP64=1 -I/usr/X11R6/include -D_DARWIN_UNLIMITED_SELECT -I. -I/Users/Sean/Software/OpenJDK/build/tmp/sun/sun.awt.X11/xawt/CClassHeaders -I../../../src/macosx/javavm/export -I../../../src/share/javavm/export -I../../../src/share/native/common -I../../../src/solaris/native/common -I../../../src/share/native/sun/awt/X11 -I../../../src/solaris/native/sun/awt/X11   -I/Users/Sean/Software/OpenJDK/openjdk/cups-2.2.9 -DXAWT -DXAWT_HACK -I/Users/Sean/Software/OpenJDK/build/tmp/sun/sun.awt.X11/xawt/../../sun.awt/awt/CClassHeaders -I../../../src/solaris/native/sun/awt -I../../../src/solaris/native/sun/xawt -I../../../src/solaris/native/sun/jdga -I../../../src/share/native/sun/awt/debug -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/java2d -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/font -I../../../src/solaris/native/sun/java2d -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/java2d/opengl -I../../../src/solaris/native/sun/java2d/opengl -I../../../src/solaris/native/sun/java2d/x11 -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/alphacomposite -I../../../src/share/native/sun/awt/medialib -I../../../src/solaris/native/sun/awt/medialib -I../../../src/solaris/native/sun/font -I../../../src/share/native/sun/awt -I../../../src/solaris/native/sun/awt -DX11_PATH=\"/usr/X11R6\" -DPACKAGE_PATH=\"/opt/local\" -DINTERNAL_BUILD -o /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32 /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32.c

/bin/mkdir -p /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator
rm -f /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32
/Library/Developer/CommandLineTools/usr/bin/llvm-gcc -arch i386 -DNDEBUG -DARCH='"x86_64"' -Dx86_64 -D_ALLBSD_SOURCE -DRELEASE='"1.7.0-internal"' -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT -DMACOSX -D_LP64=1 -I/usr/X11R6/include -D_DARWIN_UNLIMITED_SELECT -I. -I/Users/Sean/Software/OpenJDK/build/tmp/sun/sun.awt.X11/xawt/CClassHeaders -I../../../src/macosx/javavm/export -I../../../src/share/javavm/export -I../../../src/share/native/common -I../../../src/solaris/native/common -I../../../src/share/native/sun/awt/X11 -I../../../src/solaris/native/sun/awt/X11   -I/Users/Sean/Software/OpenJDK/openjdk/cups-2.2.9 -DXAWT -DXAWT_HACK -I/Users/Sean/Software/OpenJDK/build/tmp/sun/sun.awt.X11/xawt/../../sun.awt/awt/CClassHeaders -I../../../src/solaris/native/sun/awt -I../../../src/solaris/native/sun/xawt -I../../../src/solaris/native/sun/jdga -I../../../src/share/native/sun/awt/debug -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/java2d -I../../../src/share/native/sun/java2d/loops -I../../../src/share/native/sun/awt/image/cvutils -I../../../src/share/native/sun/awt/image -I../../../src/share/native/sun/font -I../../../src/solaris/native/sun/java2d -I../../../src/share/native/sun/java2d/pipe -I../../../src/share/native/sun/java2d/opengl -I../../../src/solaris/native/sun/java2d/opengl -I../../../src/solaris/native/sun/java2d/x11 -I../../../src/share/native/sun/dc/path -I../../../src/share/native/sun/dc/doe -I../../../src/share/native/sun/awt/alphacomposite -I../../../src/share/native/sun/awt/medialib -I../../../src/solaris/native/sun/awt/medialib -I../../../src/solaris/native/sun/font -I../../../src/share/native/sun/awt -I../../../src/solaris/native/sun/awt -DX11_PATH=\"/usr/X11R6\" -DPACKAGE_PATH=\"/opt/local\" -DINTERNAL_BUILD -o /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32 /Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32.c
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
 "___stack_chk_fail", referenced from:
    _main in sizer-17ffb5.o
 "___stack_chk_guard", referenced from:
     _main in sizer-17ffb5.o
 "_printf", referenced from:
    _main in sizer-17ffb5.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** >>[/Users/Sean/Software/OpenJDK/build/gensrc/sun/awt/X11/generator/sizer.32] Error 1
make[3]: *** [all] Error 1
make[2]: *** [all] Error 1
make[1]: *** [jdk-build] Error 2
make: *** [build_product_image] Error 2

这个问题有点搞,因为32问题,类库里面少了32位的东西。看看libSystem.tbd这个问题

localhost:~ Sean$ cat /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
--- !tapi-tbd-v3
archs:           [ x86_64 ]
uuids:           [ 'x86_64: D5AFCC78-2AC2-37EB-B0EF-BB00FD38ED00' ]
platform:        macosx
install-name:    /usr/lib/libSystem.B.dylib
current-version: 1252.200.5
objc-constraint: none
exports:
 - archs:           [ x86_64 ]
  re-exports:      [ /usr/lib/system/libcache.dylib, >/usr/lib/system/libcommonCrypto.dylib,
                      /usr/lib/system/libcompiler_rt.dylib, >/usr/lib/system/libcopyfile.dylib,
                      /usr/lib/system/libcorecrypto.dylib, >/usr/lib/system/libdispatch.dylib,
                      /usr/lib/system/libdyld.dylib, >/usr/lib/system/libkeymgr.dylib,
                      /usr/lib/system/liblaunch.dylib, >/usr/lib/system/libmacho.dylib,
                      /usr/lib/system/libquarantine.dylib, >/usr/lib/system/libremovefile.dylib,
                     /usr/lib/system/libsystem_asl.dylib, >/usr/lib/system/libsystem_blocks.dylib,
                      /usr/lib/system/libsystem_c.dylib, >/usr/lib/system/libsystem_configuration.dylib,
                      /usr/lib/system/libsystem_coreservices.dylib, >/usr/lib/system/libsystem_darwin.dylib,
                      /usr/lib/system/libsystem_dnssd.dylib, >/usr/lib/system/libsystem_info.dylib,
                      /usr/lib/system/libsystem_kernel.dylib, >/usr/lib/system/libsystem_m.dylib,
                     /usr/lib/system/libsystem_malloc.dylib, >/usr/lib/system/libsystem_networkextension.dylib,
                      /usr/lib/system/libsystem_notify.dylib, >/usr/lib/system/libsystem_platform.dylib,
                      /usr/lib/system/libsystem_pthread.dylib, >/usr/lib/system/libsystem_sandbox.dylib,
                      /usr/lib/system/libsystem_secinit.dylib, >/usr/lib/system/libsystem_symptoms.dylib,
                      /usr/lib/system/libsystem_trace.dylib, >/usr/lib/system/libunwind.dylib,
                      /usr/lib/system/libxpc.dylib ]
   symbols:         [ 'R8289209$_close', 'R8289209$_fork', 'R8289209$_fsync', 'R8289209$_getattrlist',
                      'R8289209$_getrlimit', 'R8289209$_getxattr', 'R8289209$_open',
                     'R8289209$_pthread_attr_destroy', 'R8289209$_pthread_attr_init',
                     'R8289209$_pthread_attr_setdetachstate', 'R8289209$_pthread_create',
                     'R8289209$_pthread_mutex_lock', 'R8289209$_pthread_mutex_unlock',
                     'R8289209$_pthread_self', 'R8289209$_ptrace', 'R8289209$_read',
                     'R8289209$_setattrlist', 'R8289209$_setrlimit', 'R8289209$_sigaction',
                     'R8289209$_stat', 'R8289209$_sysctl', 'R8289209$_time', 'R8289209$_unlink',
                    'R8289209$_write', ___crashreporter_info__, _libSystem_atfork_child,
                     _libSystem_atfork_parent, _libSystem_atfork_prepare, _mach_init_routine ]
...

确实没有i386,查了下发现这个是32位系统的。(32后面基本不会用到这样改没什么问题)然后想了个土办法``
cp sizer.32.c size32; chmod 755 sizer.32.c
如果64位一样报错的话,相同的办法修改即可。
cp sizer.64.c size64; chmod 755 sizer.64.c
Macintosh HD⁩ ▸ ⁨用户⁩ ▸ ⁨Sean⁩ ▸ ⁨Software⁩ ▸ ⁨OpenJDK⁩ ▸ ⁨openjdk⁩ ▸ ⁨jdk⁩ ▸ ⁨make⁩ ▸ ⁨sun⁩ ▸ ⁨lwawt⁩ /⁨ awt⁩ /xxawt
注要是这几个awt的makefile文件里面会用到,看下即可。

  • Q16. 十年问题
Done with parallel compiles: /Users/Sean/Software/OpenJDK/openjdk/jdk/make/java/java
rm -f /Users/Sean/Software/OpenJDK/build/lib/currency.data
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Djava.awt.headless=true -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -jar /Users/Sean/Software/OpenJDK/build/btjars/generatecurrencydata.jar -o /Users/Sean/Software/OpenJDK/build/lib/currency.data.temp \
		< ../../../src/share/classes/java/util/CurrencyData.properties
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Error: time is more than 10 years from present: 1136059200000
java.lang.RuntimeException: time is more than 10 years from present: 1136059200000
	at build.tools.generatecurrencydata.GenerateCurrencyData.makeSpecialCaseEntry(GenerateCurrencyData.java:285)
	at build.tools.generatecurrencydata.GenerateCurrencyData.buildMainAndSpecialCaseTables(GenerateCurrencyData.java:225)
	at build.tools.generatecurrencydata.GenerateCurrencyData.main(GenerateCurrencyData.java:154)
make[4]: *** [/Users/Sean/Software/OpenJDK/build/lib/currency.data] Error 1
make[3]: *** [all] Error 1
make[2]: *** [all] Error 1
make[1]: *** [jdk-build] Error 2
make: *** [build_product_image] Error 2

解决办法
修改CurrencyData.properties(路径:jdk/src/share/classes/java/util/CurrencyData.properties)
修改108行
AZ=AZM;2009-12-31-20-00-00;AZN
修改381行
MZ=MZM;2009-06-30-22-00-00;MZN
修改443行
RO=ROL;2009-06-30-21-00-00;RON
修改535行
TR=TRL;2009-12-31-22-00-00;TRY
修改561行
VE=VEB;2009-01-01-04-00-00;VEF
参考:
第一章 Mac os下编译openJDK 7

  • Q17. test_gamma报错
注释build/macosx-x86_64-debug/hotspot/outputdir/bsd_amd64_compiler2/jvmg/test_gamma中的测试代码,在最后一行
#./${GAMMA_PROG} -Xbatch -showversion Queens < /dev/null
  • Q18. libTIFF.dylib无法找到
cd bsd_amd64_compiler2/product && ./test_gamma
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Error occurred during initialization of VM
Unable to load native library: dlopen(/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libjava.dylib, 1): Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
  Expected in: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
Using java runtime at: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
make[6]: *** [product] Error 1
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
make[2]: *** [universal_product] Error 2
make[1]: *** [hotspot-build] Error 2
make: *** [build_product_image] Error 2

解决办法(因为类库地址换了):
cd /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/
sudo mv libjpeg.dylib libjpeg.dylib.bak
sudo ln -s /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib libJPEG.dylib

sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks//ImageIO.framework/Versions/A/Resources/libJPEG.dylib /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libJPEG.dylib

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/

参考:Mac 10.12.4 编译 openJDK7 记录

  • Q19. RMIConnectionImpl_Stub.java文件无法找到
This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
File `all' does not exist.
  File `build' does not exist.
    File `stubs' does not exist.
     File >`/Users/Sean/Software/OpenJDK/build/classes/javax/management/remote/rmi/RMIServerImpl_Stub.class' does not exist.
     Must remake target `/Users/Sean/Software/OpenJDK/build/classes/javax/management/remote/rmi/RMIServerImpl_Stub.class'.
/bin/mkdir -p >/Users/Sean/Software/OpenJDK/build/classes/javax/management/remote/rmi
rm -f /Users/Sean/Software/OpenJDK/build/classes/javax/management/remote/rmi/RMIServerImpl_Stub.class
/Users/Sean/Software/OpenJDK/build/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Djava.awt.headless=true -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -cp /Users/Sean/Software/OpenJDK/build/classes sun.rmi.rmic.Main -classpath "/Users/Sean/Software/OpenJDK/build/classes"    \
               -d /Users/Sean/Software/OpenJDK/build/classes              \
               -v1.2                           \
               -keepgenerated                  \
               javax.management.remote.rmi.RMIServerImpl

解决办法(自己解决):
因为有两个文件没有编译导致,导致在后续rm命令时候无法找到文件。

cd /Users/Sean/Software/OpenJDK/build/classes/javax/management/remote/rmi/
javac RMIServerImpl_Stub.java
javac RMIConnectionImpl_Stub.java

这个是编译RMI模块出现的问题,如果自己随便搞会导致后面打成的包里面出现问题,所以需要用javac编译。有很多人说莫名奇妙就好了,是内存问题,这个简直就是搞笑的。

  • Q20. 上述问题引申问题
Using boot class path = [/Users/Sean/Software/OpenJDK/build/tmp/rt-orig.jar, /Users/Sean/Software/OpenJDK/build/langtools/dist/bootstrap/lib/javac.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/resources.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/sunrsasign.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/jsse.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/jce.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/charsets.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/jfr.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/classes, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/sunec.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/dnsns.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/localedata.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar, /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext/zipfs.jar, /System/Library/Java/Extensions/MRJToolkit.jar]
警告: /Users/Sean/Software/OpenJDK/build/tmp/rt-orig.jar(javax/management/remote/rmi/RMIConnectionImpl_Stub.class): 主版本 52 比 51 新, 此编译器支持最新的主版本。
  建议升级此编译器。
错误: 错误的类文件: /Users/Sean/Software/OpenJDK/build/tmp/rt-orig.jar(javax/management/remote/rmi/RMIServerImpl_Stub.class)
    类文件包含错误的类: javax.management.remote.rmi.RMIJRMPServerImpl
    请删除该文件或确保该文件位于正确的类路径子目录中。
1 个错误
3 个警告
make[2]: *** [initial-image-jdk] Error 1
make[1]: *** [jdk-build] Error 2
make: *** [build_product_image] Error 2

之前没有用javac编译,直接随便创建一个文件导致的这个问题。困扰好久。javac编译即可。做法见上。

PS: 一共经历快20多个问题,才折磨结束。勇士们,还是编译OpenJDK1.9去吧。环境和类库的地址的变化导致了这样一系列的问题。后续就是如何调试OpenJDK和使用Hostpot虚拟机了。


成功标志

  Successfully remade target file `server-jdk-image'.
Must remake target `images'.
Successfully remade target file `images'.
 File `images' does not exist.
Target `images' is double-colon and has no prerequisites.
Must remake target `images'.
>>>Finished making images @ Wed Dec  5 02:27:07 CST 2018 ...
Successfully remade target file `images'.
########################################################################
##### Leaving jdk for target(s) sanity all docs images             #####
########################################################################
##### Build time 00:05:27 jdk for target(s) sanity all docs images #####
########################################################################

    Successfully remade target file `jdk-build'.
   Prerequisite `jdk-build' of target `/Users/Sean/Software/OpenJDK/build/bin/java' does not exist.
Must remake target `generic_build_repo_series'.
Successfully remade target file `generic_build_repo_series'.
 File `generic_build_repo_series' does not exist.
Target `generic_build_repo_series' is double-colon and has no prerequisites.
Must remake target `generic_build_repo_series'.
#-- Build times ----------
Target all_product_build
Start 2018-12-05 02:20:50
End   2018-12-05 02:27:07
00:00:19 corba
00:00:17 hotspot
00:00:03 jaxp
00:00:08 jaxws
00:05:27 jdk
00:00:03 langtools
00:06:17 TOTAL
-------------------------
Successfully remade target file `generic_build_repo_series'.
      Successfully remade target file `build_product_image'.
    Must remake target `product_build'.
    Successfully remade target file `product_build'.
  Must remake target `all_product_build'.
  Successfully remade target file `all_product_build'.
Must remake target `all'.
Successfully remade target file `all'.

Tips

  • javacjavap

javac 用来编译 ABC.java 文件,将之转换为ABC.class文件;javap是反编译工具,用来读取ABC.class文件内内容工具。两者都是JDK的bin目录自带的工具。
参考: 反编译class文件并重新编译的方法
怎样加Java文件编译成class文件

  • Makefile missing separator. Stop.怎么解决

遇到这个问题,一般是Makefile文件被改错了。因为Makefile文件要求每个命令前是需要以TAB作为分隔符号。好好检查报错的Makefile文件。
Makefile missing separator. Stop.怎么解决


Others

一路下来,本地编译OpenJDK实属不易。有很多人通过虚拟机安装和Docker版本安装会轻松很多。

参考文章:
修改,编译,GDB调试openjdk8源码(docker环境下)

为什么要编译OpenJDK?
之前突然想到这个问题。编译好处在于可以定制化调试参数,定制化查看源码研究。而别人编译好的JDK二进制文件是无法修改的。这就是编译的好处。当然,运维,还是直接安装,类如rpmyum installapt-get省事的多。


Reference

[1]. 《深入理解Java虚拟机》
[2]. 第一章 Mac os下编译openJDK 7
[3]. Mac OSX 10.9 上build openjdk8和openjdk7
[4]. Mac OSX 10.9 上build openjdk8和openjdk7
[5]. Mac OSX 10.12.1 编译 Openjdk 9
[6]. Compiling OpenJDK 9 on OSX 10.11.x (El Capitan) / Xcode 7.3.1(这个patch的方法我没成功)
[7]. Mac 10.12.4 编译 openJDK7 记录


[1]. openJDK7源码编译和Hotspot调试
[2]. OpenJDK9 Hotspot java 虚拟机入口

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐