Mac 編譯 OpenJDK 8

環境信息

Mac 系統信息:

apple$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.2
BuildVersion:	18C54

Xcode 版本:

apple$ xcodebuild -version
Xcode 9.2
Build version 9C40b

gcc 版本 :

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

jdk8u 源碼是從 csdn 下載,oracle 下載賊慢賊慢.....

 

編譯階段

設置環境變量:

# 設定語言選項,必須設置
export LANG=C
# Mac平臺,C編譯器不再是GCC,是clang
export CC=clang
# 跳過clang的一些嚴格的語法檢查,不然會將N多的警告作爲Error
export COMPILER_WARNINGS_FATAL=false
# 鏈接時使用的參數
export LFLAGS='-Xlinker -lstdc++'
# 是否使用clang
export USE_CLANG=true
# 使用64位數據模型
export LP64=1
# 告訴編譯平臺是64位,不然會按32位來編譯
export ARCH_DATA_MODEL=64
# 允許自動下載依賴
export ALLOW_DOWNLOADS=true
# 並行編譯的線程數,編譯時間長,爲了不影響其他工作,我選擇爲2
export HOTSPOT_BUILD_JOBS=2
# 是否跳過與先前版本的比較
export SKIP_COMPARE_IMAGES=true
# 是否使用預編譯頭文件,加快編譯速度
export USE_PRECOMPILED_HEADER=true
# 是否使用增量編譯
export INCREMENTAL_BUILD=true
# 編譯內容
export BUILD_LANGTOOLS=true
export BUILD_JAXP=true
export BUILD_JAXWS=true
export BUILD_CORBA=true
export BUILD_HOTSPOT=true
export BUILD_JDK=true
# 編譯版本
export SKIP_DEBUG_BUILD=true
export SKIP_FASTDEBUG_BUILD=false
export DEBUG_NAME=debug
# 避開javaws和瀏覽器Java插件之類的部分的build
export BUILD_DEPLOY=false
export BUILD_INSTALL=false
unset JAVA_HOME

configura  

bash configure --with-debug-level=slowdebug --with-freetype-include=/usr/local/include/freetype2 --with-freetype-lib=/usr/local/lib/

錯誤 & 解決方案

1、找不到 arm64 指令集 

Undefined symbols for architecture x86_64:
"_attachCurrentThread", referenced from:
+[ThreadUtilities getJNIEnv] in ThreadUtilities.o
+[ThreadUtilities getJNIEnvUncached] in ThreadUtilities.o
ld: symbol(s) not found for architecture x86_64

  解決方案: 

                                             截圖來自(https://www.jianshu.com/p/e53e7964db03

 

其他問題我都參考 https://www.jianshu.com/p/d9a1e1072f37 

經過一段時間後,終於看到了成功的信息(感動都快哭了,之前折騰了不少時間,從 jdk8 換到 jdk11,也換 xcode 版本)

Ubuntu 編譯可以參考  Ubuntu 編譯 JDK9  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章