Ubuntu 14.04 LTS 下編譯OpenJDK 8


1,機器硬件詳情

$uname -a
Linux K-Lenovo 3.16.0-57-generic #77~14.04.1-Ubuntu SMP Thu Dec 17 23:20:32 UTC 2015 i686 athlon i686 GNU/Linux

2,源碼下載地址

http://download.java.net/openjdk/jdk8/promoted/b132/openjdk-8-src-b132-03_mar_2014.zip

3,遇到的問題

3.1,依賴的軟件

      這些依賴的軟件在 README-builds.html中均有提及,只是包名發生了變化
X11

checking for X11/extensions/shape.h… no
configure: error: Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). You might be able to fix this by running ‘sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev’.
configure exiting with result code 1

cup

configure: error: Could not find cups! You might be able to fix this by running ‘sudo apt-get install libcups2-dev’.
configure exiting with result code 1

freeType

checking for FREETYPE… no
configure: error: Could not find freetype! You might be able to fix this by running ‘sudo apt-get install libfreetype6-dev’.
configure exiting with result code 1

alsa

checking for alsa/asoundlib.h… no
configure: error: Could not find alsa! You might be able to fix this by running ‘sudo apt-get install libasound2-dev’.
configure exiting with result code 1

cclplus

Generating precompiled header precompiled.hpp.gch
cc1plus: error: the “stabs” debug format cannot be used with pre-compiled headers [-Werror=deprecated]
cc1plus: all warnings being treated as errors
make[6]: *** [precompiled.hpp.gch] Error 1
make[5]: *** [the_vm] Error 2
make[4]: *** [product] Error 2
make[3]: *** [generic_build2] Error 2
make[2]: *** [product] Error 2
make[1]: *** [/home/shaw/downloads/openjdk/build/linux-x86-normal-server-release/hotspot/_hotspot.timestamp] Error 2
make: *** [hotspot-only] Error 2

cc1plus: error: the “stabs” debug format cannot be used with pre-compiled headers [-Werror=deprecate]

因為高版本的gcc不再支持stabs,解決辦法:在make命令中加上 DEBUG_BINARIES=true

cc1plus all warnings being treated as errors

vim ./hotspot/make/linux/makefiles/gcc.make
其中的Linux是對應的自己的操作系統,在207行,注釋掉:
WARNINGS_ARE_ERRORS = -Werror

http://www.07net01.com/2015/08/913552.html

Unkown Problem

Compiling 521 properties into resource bundles
Copying and cleaning 53 properties
Creating sun/util/LocaleDataMetaInfo.java from 421 found resources.
Generating sun/misc/Version.java
Generating sun/misc/Version.java compact1
Generating sun/misc/Version.java compact2
Generating sun/misc/Version.java compact3
Aliases: Table size 1024 (10 bits), shift 0, max chain depth 3
Classes: Table size 32 (5 bits), shift 1, max chain depth 3
Cache: Table size 32 (5 bits), shift 1, max chain depth 3
Generating X11 wrapper (32-bit version)
Generating beaninfo
Generating Nimbus source files
[Error] encoded value was less than 0: encode(-8.326673E-17, 5.0, 11.0, 16.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] encoded value was greater than 3: encode(15.029411, 1.0, 14.0, 15.0)
[Error] encoded value was less than 0: encode(-0.05882353, 1.0, 24.0, 25.0)
[Error] Encountered Infinity: encode(-0.00877193, 0.0, 7.0, 7.0)

好吧這又是個Bug   https://bugs.openjdk.java.net/browse/JDK-8016451

4,結果

——- Build times ———-
Start 2016-01-14 21:43:38
End 2016-01-14 22:04:28
00:00:30 corba
00:00:23 demos
00:02:17 docs
00:11:58 hotspot
00:00:36 images
00:00:18 jaxp
00:00:26 jaxws
00:03:42 jdk
00:00:24 langtools
00:00:16 nashorn
00:20:50 TOTAL
-————————————
Finished building OpenJDK for target ‘all’

查看編譯成果

shaw@K-Lenovo:~/downloads/openjdk/build/linux-x86-normal-server-release/jdk/bin$ ./java -version
openjdk version “1.8.0-internal”
OpenJDK Runtime Environment (build 1.8.0-internal-sha_2016_01_14_21_32-b00)
OpenJDK Server VM (build 25.0-b70, mixed mode)

5,感受

說實話,我是看了《深入理解Java虛擬機:JVM高級特性與最佳實踐》之后,想滿足下好奇心。我直接選取了打包好的源碼,而不是用 Mercurial 獲取源碼項目,鑒於工具鏈的豐富性,Linux下編譯的復雜度要遠低於Windows下。同時編譯 OpenJDK 8 相比 OpenJDK 7 也簡便了好多。

6,注解

終於找到編譯 hotspot 時第一個 cc1plus 錯誤的原因了,先找到的這個 RFE,討論 JDK 7 是否在 linux-x86 (32-bit) 平台上考慮從 STABS 轉換到 DWARF :(都是十多年前的老東西了,現在才。。。, 還只是CLOSED, 真是有點懶了 :(

In practice all GNU/Linux distros use DWARF and newer tools (systemtap,
perf, etc) don’t handle STABS. GCC has defaulted to DWARF for ELF
platforms since GCC 3.1 (released in 2002). You can still make GCC
output STABS, but at the recent GNU Tools Cauldron it was actually
suggested to just always output DWARF (and have separate tools for
transforming that into other debugging formats if people still
used those). GDB still supports STABS, but I don’t know how well it
works or is supported.

https://bugs.openjdk.java.net/browse/JDK-7188173

下面是GCC 3.1 的 Release Note:

Caveats

  • The -traditional C compiler option has been deprecated and will be removed in GCC 3.3. (It remains possible to preprocess non-C code with the traditional preprocessor.)
    The default debugging format for most ELF platforms (including GNU/Linux and FreeBSD; notable exception is Solaris) has changed from stabs to DWARF2. This requires GDB 5.1.1 or later.
  • The default debugging format for most ELF platforms (including GNU/Linux and FreeBSD; notable exception is Solaris) has changed from stabs to DWARF2. This requires GDB 5.1.1 or later.

https://gcc.gnu.org/gcc-3.1/changes.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM