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

转载于:https://www.cnblogs.com/shaw-me/p/5133273.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值