Fail to cross compiling jdk12 for mips64el-linux-gnu target
Leslie Zhai
zhaixiang at loongson.cn
Thu Jan 24 02:28:18 UTC 2019
Hi Erik,
Because the flags' macro of MIPS is different from other targets[1], it
will effect the `UnixConstants` of
src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template, for
example, PREFIX_O_APPEND, so the `Flags` in `FileChannel` is different
from other targets. Then failed[2] to cross compiling jdk12 for
mips64el-linux-gnu target by following the document[3].
Workaround 1:
Only make hotspot, then scp
build/linux-mips64el-normal-server-fastdebug/jdk/lib/server/libjvm.so to
mips64el target machine, java version is able to work[4], but it needs
to make images on mips64el target machine at first.
Workaround 2:
Just change[5] the flags' macro of MIPS to keep same with other
targets. Even if succeed to cross compiling, and java version is able
to work on target machine, but jmod[6], javac, etc. failed to work.
Because buildjdk/jdk/bin/jmod is x86-64, but images/jdk/bin/jmod is
mips64el target, the flags' macro is still different in X86 host and
MIPS target machine.
Please give me some advice about how to fix the root cause, thanks a lot!
Regards,
Leslie Zhai
1.
$ diff -Naur sysdeps/unix/sysv/linux/x86/bits/fcntl.h
sysdeps/unix/sysv/linux/mips/bits/fcntl.h
--- sysdeps/unix/sysv/linux/x86/bits/fcntl.h 2019-01-23
11:46:18.712301739 +0800
+++ sysdeps/unix/sysv/linux/mips/bits/fcntl.h 2019-01-23
11:46:18.540304458 +0800
@@ -1,5 +1,5 @@
-/* O_*, F_*, FD_* bit values for Linux/x86.
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -13,24 +13,56 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
-#ifndef _FCNTL_H
+#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif
-#ifdef __x86_64__
-# define __O_LARGEFILE 0
+#include <sgidefs.h>
+
+#define O_APPEND 0x0008
+#define O_SYNC 0x4010
+#define O_NONBLOCK 0x0080
+#define O_CREAT 0x0100 /* not fcntl */
+#define O_TRUNC 0x0200 /* not fcntl */
+#define O_EXCL 0x0400 /* not fcntl */
+#define O_NOCTTY 0x0800 /* not fcntl */
+#define O_ASYNC 0x1000
+
+#define __O_DIRECT 0x8000 /* Direct disk access hint. */
+#define __O_DSYNC 0x0010 /* Synchronize data. */
+
+#if _MIPS_SIM == _ABI64
+/* Not necessary, files are always with 64bit off_t. */
+# define __O_LARGEFILE 0
+#else
+# define __O_LARGEFILE 0x2000 /* Allow large file opens. */
#endif
-#ifdef __x86_64__
-/* Not necessary, we always have 64-bit offsets. */
-# define F_GETLK64 5 /* Get record locking info. */
-# define F_SETLK64 6 /* Set record locking info (non-blocking). */
-# define F_SETLKW64 7 /* Set record locking info (blocking). */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 14 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
#endif
+#if _MIPS_SIM != _ABI64
+# define F_GETLK64 33 /* Get record locking info. */
+# define F_SETLK64 34 /* Set record locking info (non-blocking). */
+# define F_SETLKW64 35 /* Set record locking info (blocking). */
+#else
+# define F_GETLK64 14 /* Get record locking info. */
+# define F_SETLK64 6 /* Set record locking info (non-blocking).*/
+# define F_SETLKW64 7 /* Set record locking info (blocking). */
+#endif
+
+#define __F_SETOWN 24 /* Get owner (process receiving SIGIO). */
+#define __F_GETOWN 23 /* Set owner (process receiving SIGIO). */
struct flock
{
@@ -39,12 +71,23 @@
#ifndef __USE_FILE_OFFSET64
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until
EOF. */
+#if _MIPS_SIM != _ABI64
+ /* The 64-bit flock structure, used by the n64 ABI, and for 64-bit
+ fcntls in o32 and n32, never has this field. */
+ long int l_sysid;
+#endif
#else
__off64_t l_start; /* Offset where the lock begins. */
__off64_t l_len; /* Size of the locked area; zero means until
EOF. */
#endif
__pid_t l_pid; /* Process holding the lock. */
+#if ! defined __USE_FILE_OFFSET64 && _MIPS_SIM != _ABI64
+ /* The 64-bit flock structure, used by the n64 ABI, and for 64-bit
+ flock in o32 and n32, never has this field. */
+ long int __glibc_reserved0[4];
+#endif
};
+typedef struct flock flock_t;
#ifdef __USE_LARGEFILE64
struct flock64
----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
2.
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/jdk/bin/jmod
-J-XX:+UseSerialGC -J-Xms32M -J-Xmx512M -J-XX:TieredStopAtLevel=1 create
--module-version 12-internal --target-platform 'linux-mips64el'
--module-path
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/support/interim-jmods
--libs
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_libs/java.base
--cmds
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_cmds/java.base
--config
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_conf/java.base
--class-path
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/jdk/modules/java.base
--header-files
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_include/java.base
--legal-notices
"/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_legal/common:/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/modules_legal/java.base"
--exclude
'**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}'
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/support/interim-jmods/temp/java.base.jmod
> >(/usr/bin/tee -a
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/jmods/java.base.jmod.log)
2> >(/usr/bin/tee -a
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/jmods/java.base.jmod.log
>&2) || ( exitcode=$? && /bin/cp
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/jmods/java.base.jmod.log
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/make-support/failure-logs/buildjdk_support_jmods_java.base.jmod.log
&& /bin/cp
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/buildjdk/support/jmods/java.base.jmod.cmdline
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/make-support/failure-logs/buildjdk_support_jmods_java.base.jmod.cmdline
&& exit $exitcode ) )
Error:
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/support/interim-jmods/temp/.java.base.jmod.tmp
java.nio.file.NoSuchFileException:
/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/support/interim-jmods/temp/.java.base.jmod.tmp
at
java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at
java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
at
java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
at
jdk.jlink/jdk.tools.jmod.JmodOutputStream.newOutputStream(JmodOutputStream.java:52)
at jdk.jlink/jdk.tools.jmod.JmodTask.create(JmodTask.java:437)
at jdk.jlink/jdk.tools.jmod.JmodTask.run(JmodTask.java:208)
at jdk.jlink/jdk.tools.jmod.Main.main(Main.java:34)
CreateJmods.gmk:162: recipe for target
'/home/loongson/zhaixiang/jdk12-mips/build/linux-mips64el-normal-server-fastdebug/support/interim-jmods/java.base.jmod'
failed
----- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< ---
3.
https://hg.openjdk.java.net/jdk/jdk/raw-file/tip/doc/building.html#cross-compiling
4.
$ ./build/linux-mips64el-normal-server-fastdebug/images/jdk/bin/java
-version
openjdk version "12-internal" 2019-03-19
OpenJDK Runtime Environment (fastdebug build
12-internal+0-adhoc.loongson.jdk-mips)
OpenJDK 64-Bit Server VM (fastdebug build
12-internal+0-adhoc.loongson.jdk-mips, mixed mode)
5.
diff -r 294c0bb90976
src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
--- a/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
Wed Jan 09 15:39:04 2019 +0800
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
Thu Jan 24 10:19:04 2019 +0800
@@ -28,7 +28,11 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#ifdef MIPS_SYSROOT
+#include <asm-generic/fcntl.h>
+#else
#include <fcntl.h>
+#endif
#include <sys/stat.h>
/* On Solaris, "sun" is defined as a macro. Undefine to make package
6.
$ file build/linux-mips64el-normal-server-fastdebug/buildjdk/jdk/bin/jmod
build/linux-mips64el-normal-server-fastdebug/buildjdk/jdk/bin/jmod: ELF
64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32,
BuildID[sha1]=7095b74502322b08957f0b4aaa3b9c5c8ceba5b6, not stripped
$ file build/linux-mips64el-normal-server-fastdebug/images/jdk/bin/jmod
build/linux-mips64el-normal-server-fastdebug/images/jdk/bin/jmod: ELF
64-bit LSB shared object, MIPS, MIPS64 rel2 version 1 (SYSV),
dynamically linked, interpreter /lib64/ld.so.1,
BuildID[sha1]=4dd81abf1b06d9bc90063b53a50549dd15434232, for GNU/Linux
3.2.0, not stripped
More information about the build-dev
mailing list