我正在尝试用gcc6构建OpenJDK 8:
$ hg clone http://hg.openjdk.java.net/jdk8 jdk8
$ cd jdk8
$ bash get_source.sh
$ bash ./configure
$ make images
正如here或here所述,我必须更新make文件以将以下选项添加到gcc:
-Wno-deprecated-declarations
-Wno-error=deprecated-declarations
-Wno-error=narrowing
-fno-exceptions
-fvisibility=hidden
-fno-delete-null-pointer-checks
-fno-lifetime-dse
现在似乎一切都很好。 但是,当链接失败时,请执行以下命令:
/usr/bin/x86_64-linux-gnu-gcc-6
-Xlinker --hash-style=both
-Xlinker -z
-Xlinker defs -shared
-L/home/johnd/src/build_jdk/jdk8/jdk/lib/amd64
-L/home/johnd/src/build_jdk/jdk8/jdk/lib/amd64/server
-Xlinker -z
-Xlinker origin
-Xlinker -rpath
-Xlinker \$ORIGIN
-Xlinker -version-script=/home/johnd/src/build_jdk/jdk8/jdk/make/mapfiles/libzip/mapfile-vers
-Xlinker -soname=libzip.so
-o /home/johnd/src/build_jdk/jdk8/jdk/lib/amd64/libzip.so
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/Adler32.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/CRC32.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/Deflater.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/Inflater.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/ZipFile.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/compress.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/deflate.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/gzclose.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/gzlib.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/gzread.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/gzwrite.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/infback.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/inffast.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/inflate.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/inftrees.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/trees.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/uncompr.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/zadler32.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/zcrc32.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/zip_util.o
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/zutil.o
-ljvm
-ljava
它出现以下错误:
/home/johnd/src/build_jdk/jdk8/jdk/objs/libzip/ZipFile.o: In function `Java_java_util_zip_ZipFile_open':
/home/johnd/src/build_jdk/jdk8/jdk/src/share/native/java/util/zip/ZipFile.c:109: undefined reference to `throwFileNotFoundException'
collect2: error: ld returned 1 exit status
这是令人惊讶的,因为符号`throwFileNotFoundException'显然是在libjava中定义的,它作为链接器的参数给出。
$ nm ./jdk/lib/amd64/libjava.so | grep throw
000000000001b0cd t throwFileNotFoundException
000000000001721b t throwIOException
知道发生了什么以及如何解决它?
答案 0 :(得分:1)
您似乎克隆了JDK 8 GA来源(即2014年)。它们比gcc6早了大约两年。
相反,请从JDK 8更新项目中克隆最新的源代码,然后重试,即使用hg.openjdk.java.net/jdk8u/jdk8u。
答案 1 :(得分:0)
似乎最新版本的OpenJDK8尚未针对gcc6进行修补。以下是我使用Debian的OpenJDK8软件包修补OpenJDK8 for gcc6的方法:
# apt-get install build-essentials
# apt-get build-dep openjdk-8
$ apt-get source openjdk-8
以下是Debian软件包中的补丁列表:
$ ls -1 openjdk-8-8u144-b01/debian/patches/
8141491.diff
8164293.diff
aarch32.diff
aarch64.diff
accessible-toolkit.patch
adlc-parser.patch
alpha-float-const.diff
applet-hole.patch
atk-wrapper-security.patch
autoconf-select.diff
autoconf-updates.diff
bootstrap-with-gcj.diff
compare-pointer-with-literal.patch
compiler-flags.diff
default-jvm-cfg-aarch64.diff
default-jvm-cfg-default.diff
disable-doclint-by-default.diff
dnd-files.patch
dont-strip-images.diff
enumipv6-fix.patch
fontconfig-japanese.diff
fontconfig-korean-nanum.diff
fontconfig-wqy-microhei.patch
gcc6.diff
[...]
在应用补丁之前,请下载最新的OpenJDK8源:
$ hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
$ cd jdk8u
$ bash get_source.sh
然后应用补丁:
$ patch -p1 < /path/to/openjdk-8-8u144-b01/debian/patches/gcc6.diff
$ patch -p1 < /path/to/openjdk-8-8u144-b01/debian/patches/8141491.diff
$ patch -p1 < /path/to/openjdk-8-8u144-b01/debian/patches/hotspot-warn-no-errformat.diff
$ patch -p1 < /path/to/openjdk-8-8u144-b01/debian/patches/hotspot-set-compiler.diff
$ patch -p1 < /path/to/openjdk-8-8u144-b01/debian/patches/hotspot-disable-werror.diff
然后编译:
$ bash ./configure
$ make