8141590: Cannot build Zero with devkit
authorerikj
Wed, 07 Dec 2016 16:08:23 +0100
changeset 42425 57cde06ae8d6
parent 42424 2ac2a6ef14a6
child 42426 c993418e6f1a
child 42529 d01162cb85f4
8141590: Cannot build Zero with devkit Reviewed-by: ihse
common/autoconf/generated-configure.sh
common/autoconf/lib-ffi.m4
common/autoconf/spec.gmk.in
common/conf/jib-profiles.js
make/common/MakeBase.gmk
make/devkit/Tools.gmk
make/jprt.properties
--- a/common/autoconf/generated-configure.sh	Wed Dec 07 09:47:57 2016 +0100
+++ b/common/autoconf/generated-configure.sh	Wed Dec 07 16:08:23 2016 +0100
@@ -671,6 +671,8 @@
 LLVM_LDFLAGS
 LLVM_CFLAGS
 LLVM_CONFIG
+LIBFFI_LIB_FILE
+ENABLE_LIBFFI_BUNDLING
 LIBFFI_LIBS
 LIBFFI_CFLAGS
 ALSA_LIBS
@@ -1208,6 +1210,7 @@
 with_libffi
 with_libffi_include
 with_libffi_lib
+enable_libffi_bundling
 with_libjpeg
 with_giflib
 with_libpng
@@ -1990,6 +1993,9 @@
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
                           --with-freetype, disabled otherwise]
+  --enable-libffi-bundling
+                          enable bundling of libffi.so to make the built JDK
+                          runnable on more systems
   --enable-jtreg-failure-handler
                           forces build of the jtreg failure handler to be
                           enabled, missing dependencies become fatal errors.
@@ -5082,7 +5088,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1481100369
+DATE_WHEN_GENERATED=1481104795
 
 ###############################################################################
 #
@@ -62633,6 +62639,11 @@
   withval=$with_libffi_lib;
 fi
 
+  # Check whether --enable-libffi-bundling was given.
+if test "${enable_libffi_bundling+set}" = set; then :
+  enableval=$enable_libffi_bundling;
+fi
+
 
   if test "x$NEEDS_LIB_FFI" = xfalse; then
     if (test "x${with_libffi}" != x && test "x${with_libffi}" != xno) || \
@@ -62651,6 +62662,7 @@
     fi
 
     if test "x${with_libffi}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi}/lib"
       LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
       LIBFFI_CFLAGS="-I${with_libffi}/include"
       LIBFFI_FOUND=yes
@@ -62660,6 +62672,7 @@
       LIBFFI_FOUND=yes
     fi
     if test "x${with_libffi_lib}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi_lib}"
       LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
       LIBFFI_FOUND=yes
     fi
@@ -62869,7 +62882,70 @@
 
       as_fn_error $? "Found libffi but could not link and compile with it. $HELP_MSG" "$LINENO" 5
     fi
-  fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libffi should be bundled" >&5
+$as_echo_n "checking if libffi should be bundled... " >&6; }
+    if test "x$enable_libffi_bundling" = "x"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xno"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xyes"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+      ENABLE_LIBFFI_BUNDLING=true
+    else
+      as_fn_error $? "Invalid value for --enable-libffi-bundling" "$LINENO" 5
+    fi
+
+    # Find the libffi.so.X to bundle
+    if test "x${ENABLE_LIBFFI_BUNDLING}" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libffi lib file location" >&5
+$as_echo_n "checking for libffi lib file location... " >&6; }
+      if test "x${LIBFFI_LIB_PATH}" != x; then
+        if test -e ${LIBFFI_LIB_PATH}/libffi.so.?; then
+          LIBFFI_LIB_FILE="${LIBFFI_LIB_PATH}/libffi.so.?"
+        else
+          as_fn_error $? "Could not locate libffi.so.? for bundling in ${LIBFFI_LIB_PATH}" "$LINENO" 5
+        fi
+      else
+        # If we don't have an explicit path, look in a few obvious places
+        if test "x${OPENJDK_TARGET_CPU}" = "xx86"; then
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        elif test "x${OPENJDK_TARGET_CPU}" = "xx86_64"; then
+          if test -e ${SYSROOT}/usr/lib64/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib64/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        else
+          # Fallback on the default /usr/lib dir
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        fi
+      fi
+      # Make sure the wildcard is evaluated
+      LIBFFI_LIB_FILE="$(ls ${LIBFFI_LIB_FILE})"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBFFI_LIB_FILE}" >&5
+$as_echo "${LIBFFI_LIB_FILE}" >&6; }
+    fi
+  fi
+
+
 
 
 
--- a/common/autoconf/lib-ffi.m4	Wed Dec 07 09:47:57 2016 +0100
+++ b/common/autoconf/lib-ffi.m4	Wed Dec 07 16:08:23 2016 +0100
@@ -35,6 +35,8 @@
       [specify directory for the libffi include files])])
   AC_ARG_WITH(libffi-lib, [AS_HELP_STRING([--with-libffi-lib],
       [specify directory for the libffi library])])
+  AC_ARG_ENABLE(libffi-bundling, [AS_HELP_STRING([--enable-libffi-bundling],
+      [enable bundling of libffi.so to make the built JDK runnable on more systems])])
 
   if test "x$NEEDS_LIB_FFI" = xfalse; then
     if (test "x${with_libffi}" != x && test "x${with_libffi}" != xno) || \
@@ -52,6 +54,7 @@
     fi
 
     if test "x${with_libffi}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi}/lib"
       LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
       LIBFFI_CFLAGS="-I${with_libffi}/include"
       LIBFFI_FOUND=yes
@@ -61,6 +64,7 @@
       LIBFFI_FOUND=yes
     fi
     if test "x${with_libffi_lib}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi_lib}"
       LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
       LIBFFI_FOUND=yes
     fi
@@ -109,8 +113,65 @@
       HELP_MSG_MISSING_DEPENDENCY([ffi])
       AC_MSG_ERROR([Found libffi but could not link and compile with it. $HELP_MSG])
     fi
+
+    AC_MSG_CHECKING([if libffi should be bundled])
+    if test "x$enable_libffi_bundling" = "x"; then
+      AC_MSG_RESULT([no])
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xno"; then
+      AC_MSG_RESULT([no, forced])
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xyes"; then
+      AC_MSG_RESULT([yes, forced])
+      ENABLE_LIBFFI_BUNDLING=true
+    else
+      AC_MSG_ERROR([Invalid value for --enable-libffi-bundling])
+    fi
+
+    # Find the libffi.so.X to bundle
+    if test "x${ENABLE_LIBFFI_BUNDLING}" = "xtrue"; then
+      AC_MSG_CHECKING([for libffi lib file location])
+      if test "x${LIBFFI_LIB_PATH}" != x; then
+        if test -e ${LIBFFI_LIB_PATH}/libffi.so.?; then
+          LIBFFI_LIB_FILE="${LIBFFI_LIB_PATH}/libffi.so.?"
+        else
+          AC_MSG_ERROR([Could not locate libffi.so.? for bundling in ${LIBFFI_LIB_PATH}])
+        fi
+      else
+        # If we don't have an explicit path, look in a few obvious places
+        if test "x${OPENJDK_TARGET_CPU}" = "xx86"; then
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        elif test "x${OPENJDK_TARGET_CPU}" = "xx86_64"; then
+          if test -e ${SYSROOT}/usr/lib64/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib64/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        else
+          # Fallback on the default /usr/lib dir
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        fi
+      fi
+      # Make sure the wildcard is evaluated
+      LIBFFI_LIB_FILE="$(ls ${LIBFFI_LIB_FILE})"
+      AC_MSG_RESULT([${LIBFFI_LIB_FILE}])
+    fi
   fi
 
   AC_SUBST(LIBFFI_CFLAGS)
   AC_SUBST(LIBFFI_LIBS)
+  AC_SUBST(ENABLE_LIBFFI_BUNDLING)
+  AC_SUBST(LIBFFI_LIB_FILE)
 ])
--- a/common/autoconf/spec.gmk.in	Wed Dec 07 09:47:57 2016 +0100
+++ b/common/autoconf/spec.gmk.in	Wed Dec 07 16:08:23 2016 +0100
@@ -319,6 +319,8 @@
 ALSA_CFLAGS:=@ALSA_CFLAGS@
 LIBFFI_LIBS:=@LIBFFI_LIBS@
 LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@
+ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@
+LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@
 
 PACKAGE_PATH=@PACKAGE_PATH@
 
--- a/common/conf/jib-profiles.js	Wed Dec 07 09:47:57 2016 +0100
+++ b/common/conf/jib-profiles.js	Wed Dec 07 16:08:23 2016 +0100
@@ -346,6 +346,35 @@
     // Generate debug profiles for the open jprt profiles
     profiles = concatObjects(profiles, generateDebugProfiles(common, openOnlyProfiles));
 
+    // Profiles for building the zero jvm variant. These are used for verification
+    // in JPRT.
+    var zeroProfiles = {
+        "linux-x64-zero": {
+            target_os: "linux",
+            target_cpu: "x64",
+            dependencies: concat(common.dependencies, "devkit"),
+            configure_args: concat(common.configure_args,
+                "--with-zlib=system",
+                "--with-jvm-variants=zero",
+                "--enable-libffi-bundling"),
+            default_make_targets: common.default_make_targets
+        },
+
+        "linux-x86-zero": {
+            target_os: "linux",
+            target_cpu: "x86",
+            build_cpu: "x64",
+            dependencies: concat(common.dependencies, "devkit"),
+            configure_args: concat(common.configure_args, common.configure_args_32bit,
+                "--with-zlib=system",
+                "--with-jvm-variants=zero",
+                "--enable-libffi-bundling"),
+            default_make_targets: common.default_make_targets
+        },
+    }
+    profiles = concatObjects(profiles, zeroProfiles);
+    profiles = concatObjects(profiles, generateDebugProfiles(common, zeroProfiles));
+
     // Profiles used to run tests. Used in JPRT.
     var testOnlyProfiles = {
 
@@ -380,7 +409,7 @@
         + (input.build_cpu == "x86" ? "i586" : input.build_cpu);
 
     var devkit_platform_revisions = {
-        linux_x64: "gcc4.9.2-OEL6.4+1.0",
+        linux_x64: "gcc4.9.2-OEL6.4+1.1",
         macosx_x64: "Xcode6.3-MacOSX10.9+1.0",
         solaris_x64: "SS12u4-Solaris11u1+1.0",
         solaris_sparcv9: "SS12u4-Solaris11u1+1.0",
--- a/make/common/MakeBase.gmk	Wed Dec 07 09:47:57 2016 +0100
+++ b/make/common/MakeBase.gmk	Wed Dec 07 16:08:23 2016 +0100
@@ -507,14 +507,18 @@
 	if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
   endef
 else
-  # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
-  # significantly.
   define install-file
 	$(call MakeDir, $(@D))
 	$(CP) -fP '$<' '$@'
   endef
 endif
 
+# Variant of install file that does not preserve symlinks
+define install-file-nolink
+	$(call MakeDir, $(@D))
+	$(CP) -f '$<' '$@'
+endef
+
 ################################################################################
 # Take two paths and return the path of the last common directory.
 # Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
--- a/make/devkit/Tools.gmk	Wed Dec 07 09:47:57 2016 +0100
+++ b/make/devkit/Tools.gmk	Wed Dec 07 16:08:23 2016 +0100
@@ -85,8 +85,8 @@
     libgcc \
     elfutils elfutils-libs elfutils-devel \
     elfutils-libelf elfutils-libelf-devel \
-    zlib zlib-devel
-
+    zlib zlib-devel \
+    libffi libffi-devel
 
 ifeq ($(ARCH),x86_64)
   RPM_DIR ?= $(RPM_DIR_x86_64)
@@ -209,6 +209,18 @@
 	@touch $@
 
 ##########################################################################################
+# Create links for ffi header files so that they become visible by default when using the
+# devkit.
+
+$(SYSROOT)/usr/include/ffi.h: $(rpms)
+	cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) .
+
+$(SYSROOT)/usr/include/ffitarget.h: $(rpms)
+	cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) .
+
+SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h
+
+##########################################################################################
 
 # Define marker files for each source package to be compiled
 $(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done))
@@ -496,7 +508,7 @@
 libs : $(libs)
 sysroot : rpms libs
 gcc : sysroot $(gcc) $(gccpatch)
-all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links)
+all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS)
 
 # this is only built for host. so separate.
 ccache : $(ccache)
--- a/make/jprt.properties	Wed Dec 07 09:47:57 2016 +0100
+++ b/make/jprt.properties	Wed Dec 07 16:08:23 2016 +0100
@@ -118,6 +118,12 @@
 jprt.windows_i586.fastdebugOpen.build.jib.profile=windows-x86-open-debug
 jprt.windows_x64.fastdebugOpen.build.jib.profile=windows-x64-open-debug
 
+jprt.linux_i586.productZero.build.jib.profile=linux-x86-zero
+jprt.linux_x64.productZero.build.jib.profile=linux-x64-zero
+
+jprt.linux_i586.fastdebugZero.build.jib.profile=linux-x86-zero-debug
+jprt.linux_x64.fastdebugZero.build.jib.profile=linux-x64-zero-debug
+
 jprt.test.jib.profile=run-test
 
 # Set make target to use for different build flavors
@@ -128,6 +134,8 @@
 jprt.build.flavor.optimized.target=jprt_bundle
 jprt.build.flavor.optimizedOpen.target=jprt_bundle
 jprt.build.flavor.slowdebug.target=jprt_bundle
+jprt.build.flavor.productZero.target=jprt_bundle
+jprt.build.flavor.fastdebugZero.target=jprt_bundle
 
 # Use these configure args to define debug level or provide specific
 # configuration details not covered by Jib profiles.
@@ -181,7 +189,7 @@
 jprt.build.configure.args=						\
     --with-output-sync=recurse						\
     --with-jobs=$ALT_PARALLEL_COMPILE_JOBS				\
-    --with-version-opt=$JPRT_JOB_ID				 	\
+    --with-version-opt=$JPRT_JOB_ID					\
     ${my.additional.build.configure.args.${jprt.test.set}}		\
     ${my.custom.build.configure.args}
 
@@ -481,15 +489,15 @@
 ################################################################################
 # Testset buildinfra
 my.build.flavors.buildinfra = \
-    product,fastdebug,slowdebug, \
+    product,fastdebug,slowdebug,productZero,fastdebugZero \
     ${my.additional.build.flavors.buildinfra}
 
 # Platforms built for hotspot push jobs
 my.build.targets.buildinfra = \
     solaris_sparcv9_5.11-{product|fastdebug|slowdebug}, \
     solaris_x64_5.11-{product|fastdebug|slowdebug}, \
-    linux_i586_3.8-{product|fastdebug|slowdebug}, \
-    linux_x64_3.8-{product|fastdebug|slowdebug}, \
+    linux_i586_3.8-{product|fastdebug|slowdebug|productZero|fastdebugZero}, \
+    linux_x64_3.8-{product|fastdebug|slowdebug|productZero|fastdebugZero}, \
     macosx_x64_10.9-{product|fastdebug|slowdebug}, \
     windows_i586_6.3-{product|fastdebug|slowdebug}, \
     windows_x64_6.3-{product|fastdebug|slowdebug}, \