在 Linux (aarch64) 编译 OpenJDK 8

环境信息

编译 OpenJDK 需要有一个 JDK。

解压后当前目录结构如下:

/opt/
├── jdk1.8.0_421
│   ├── COPYRIGHT
│   ├── LICENSE
│   ├── README.html
│   ├── THIRDPARTYLICENSEREADME.txt
│   ├── bin
│   ├── include
│   ├── jre
│   ├── legal
│   ├── lib
│   ├── man
│   ├── release
│   └── src.zip
└── jdk8u422-b05
    ├── ASSEMBLY_EXCEPTION
    ├── LICENSE
    ├── Makefile
    ├── README.md
    ├── THIRD_PARTY_README
    ├── common
    ├── configure
    ├── corba
    ├── doc
    ├── hotspot
    ├── jaxp
    ├── jaxws
    ├── jdk
    ├── langtools
    ├── make
    ├── nashorn
    └── test

进入 jdk8u422-b05 目录。

构建

一、运行 configure,配置编译环境

bash configure --with-boot-jdk=../jdk1.8.0_421

由于本机是 minimal 安装的,需要安装以下依赖:

yum install -y zip unzip make gcc libXtst-devel libXt-devel libXrender-devel cups-devel freetype-devel alsa-lib-devel fontconfig-devel g++

如果缺少依赖项而失败,按照提示安装后再次运行。

配置完成后,会输出以下信息:

A new configuration has been successfully created in
/opt/jdk8u422-b05/build/linux-aarch64-normal-server-release
using configure arguments '--with-boot-jdk=../jdk1.8.0_421

Configuration summary:
* Debug level:    release
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: aarch64, address length: 64

Tools summary:
* Boot JDK:       java version "1.8.0_421" Java(TM) SE Runtime Environment (build 1.8.0_421-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.421-b09, mixed mode)  (at /opt/jdk1.8.0_421)
* Toolchain:      gcc (GNU Compiler Collection)
* C Compiler:     Version 11.4.1 (at /usr/bin/gcc)
* C++ Compiler:   Version 11.4.1 (at /usr/bin/g++)
  
Build performance summary:
* Cores to use:   1
* Memory limit:   1639 MB

二、编译 OpenJDK

make images

OpenJDK 8 不支持 --disable-warnings-as-errors,会将所有 warning 视为 error 从而停止编译。需要将 ./hotspot/make/linux/makefiles/gcc.makeWARNINGS_ARE_ERRORS = -Werror 注释掉。

编译完成后,输出以下信息:

----- Build times -------
Start 2024-09-21 22:56:18
End   2024-09-21 23:08:59
00:00:18 corba
00:00:24 demos
00:07:32 hotspot
00:00:24 images
00:00:10 jaxp
00:00:16 jaxws
00:03:12 jdk
00:00:18 langtools
00:00:07 nashorn
00:12:41 TOTAL
-------------------------
Finished building OpenJDK for target 'images'

编译成功后的 JDK 和 JRE 会在 ./build/linux-aarch64-normal-server-release 目录下的 j2re-imagej2sdk-image

三、验证结果

./build/linux-aarch64-normal-server-release/images/j2sdk-image/bin/java -version

编译成功,输出以下信息:

openjdk version "1.8.0_422-internal"
OpenJDK Runtime Environment (build 1.8.0_422-internal-root_2024_09_21_22_56-b00)
OpenJDK 64-Bit Server VM (build 25.422-b00, mixed mode)

参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值