--- old/common/autoconf/configure.ac 2016-10-31 17:34:49.000000000 -0700 +++ new/common/autoconf/configure.ac 2016-10-31 17:34:49.000000000 -0700 @@ -206,7 +206,7 @@ # Need toolchain to setup dtrace HOTSPOT_SETUP_DTRACE -HOTSPOT_SETUP_JVM_FEATURES +HOTSPOT_ENABLE_DISABLE_AOT HOTSPOT_ENABLE_DISABLE_GTEST ############################################################################### @@ -221,6 +221,10 @@ LIB_DETERMINE_DEPENDENCIES LIB_SETUP_LIBRARIES +# Hotspot setup depends on lib checks (AOT needs libelf). + +HOTSPOT_SETUP_JVM_FEATURES + ############################################################################### # # We need to do some final tweaking, when everything else is done. --- old/common/autoconf/generated-configure.sh 2016-10-31 17:34:49.000000000 -0700 +++ new/common/autoconf/generated-configure.sh 2016-10-31 17:34:49.000000000 -0700 @@ -654,6 +654,16 @@ ENABLE_GENERATE_CLASSLIST BUILD_FAILURE_HANDLER ENABLE_INTREE_EC +VALID_JVM_FEATURES +JVM_FEATURES_custom +JVM_FEATURES_zeroshark +JVM_FEATURES_zero +JVM_FEATURES_minimal +JVM_FEATURES_core +JVM_FEATURES_client +JVM_FEATURES_server +ELF_LIBS +ELF_CFLAGS STLPORT_LIB LIBZIP_CAN_USE_MMAP LIBDL @@ -690,14 +700,7 @@ FIXPATH_DETACH_FLAG FIXPATH BUILD_GTEST -VALID_JVM_FEATURES -JVM_FEATURES_custom -JVM_FEATURES_zeroshark -JVM_FEATURES_zero -JVM_FEATURES_minimal -JVM_FEATURES_core -JVM_FEATURES_client -JVM_FEATURES_server +ENABLE_AOT INCLUDE_DTRACE GCOV_ENABLED STRIP_POLICY @@ -1195,8 +1198,7 @@ enable_zip_debug_info enable_native_coverage enable_dtrace -with_jvm_features -with_jvm_interpreter +enable_aot enable_hotspot_gtest with_stdc__lib with_msvcr_dll @@ -1223,6 +1225,11 @@ with_dxsdk with_dxsdk_lib with_dxsdk_include +with_libelf +with_libelf_include +with_libelf_lib +with_jvm_features +with_jvm_interpreter enable_jtreg_failure_handler enable_generate_classlist with_num_cores @@ -1347,6 +1354,8 @@ PNG_LIBS LCMS_CFLAGS LCMS_LIBS +ELF_CFLAGS +ELF_LIBS ICECC_CMD ICECC_CREATE_ENV ICECC_WRAPPER @@ -1992,6 +2001,10 @@ --enable-dtrace[=yes/no/auto] enable dtrace. Default is auto, where dtrace is enabled if all dependencies are present. + --enable-aot[=yes/no/auto] + enable ahead of time compilation feature. Default is + auto, where aot is enabled if all dependencies are + present. --disable-hotspot-gtest Disables building of the Hotspot unit tests --disable-freetype-bundling disable bundling of the freetype library with the @@ -2117,10 +2130,6 @@ --with-native-debug-symbols set the native debug symbol configuration (none, internal, external, zipped) [varying] - --with-jvm-features additional JVM features to enable (separated by - comma), use '--help' to show possible values [none] - --with-jvm-interpreter Deprecated. Option is kept for backwards - compatibility and is ignored --with-stdc++lib=,, force linking of the C++ runtime on Linux to either static or dynamic, default is static with dynamic as @@ -2167,6 +2176,15 @@ compatibility and is ignored --with-dxsdk-include Deprecated. Option is kept for backwards compatibility and is ignored + --with-libelf specify prefix directory for the libelf package + (expecting the libraries under PATH/lib and the + headers under PATH/include) + --with-libelf-include specify directory for the libelf include files + --with-libelf-lib specify directory for the libelf library + --with-jvm-features additional JVM features to enable (separated by + comma), use '--help' to show possible values [none] + --with-jvm-interpreter Deprecated. Option is kept for backwards + compatibility and is ignored --with-num-cores number of cores in the build system, e.g. --with-num-cores=8 [probed] --with-memory-size memory (in MB) available in the build system, e.g. @@ -2296,6 +2314,8 @@ PNG_LIBS linker flags for PNG, overriding pkg-config LCMS_CFLAGS C compiler flags for LCMS, overriding pkg-config LCMS_LIBS linker flags for LCMS, overriding pkg-config + ELF_CFLAGS C compiler flags for ELF, overriding pkg-config + ELF_LIBS linker flags for ELF, overriding pkg-config ICECC_CMD Override default value for ICECC_CMD ICECC_CREATE_ENV Override default value for ICECC_CREATE_ENV @@ -4183,6 +4203,8 @@ PKGHANDLER_COMMAND="sudo apt-get install ccache" ;; dtrace) PKGHANDLER_COMMAND="sudo apt-get install systemtap-sdt-dev" ;; + elf) + PKGHANDLER_COMMAND="sudo apt-get install libelf-dev" ;; esac } @@ -4202,6 +4224,8 @@ PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel" ;; ccache) PKGHANDLER_COMMAND="sudo yum install ccache" ;; + elf) + PKGHANDLER_COMMAND="sudo yum install elfutils-libelf-devel" ;; esac } @@ -4254,7 +4278,7 @@ # All valid JVM features, regardless of platform VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \ - fprof vm-structs jni-check services management all-gcs nmt cds static-build" + fprof vm-structs jni-check services management all-gcs nmt cds static-build aot" # All valid JVM variants VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" @@ -4298,6 +4322,11 @@ # +################################################################################ +# Check if AOT should be enabled +# + + ############################################################################### # Set up all JVM features for each JVM variant. # @@ -4721,6 +4750,36 @@ ################################################################################ +# +# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Setup libelf (ELF library) +################################################################################ + + ################################################################################ # Determine which libraries are needed for this configuration @@ -5093,7 +5152,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1476374246 +DATE_WHEN_GENERATED=1477705915 ############################################################################### # @@ -52810,113 +52869,52 @@ - # The user can in some cases supply additional jvm features. For the custom - # variant, this defines the entire variant. - -# Check whether --with-jvm-features was given. -if test "${with_jvm_features+set}" = set; then : - withval=$with_jvm_features; + # Check whether --enable-aot was given. +if test "${enable_aot+set}" = set; then : + enableval=$enable_aot; fi - if test "x$with_jvm_features" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking additional JVM features" >&5 -$as_echo_n "checking additional JVM features... " >&6; } - JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JVM_FEATURES" >&5 -$as_echo "$JVM_FEATURES" >&6; } - fi - - # Verify that dependencies are met for explicitly set features. - if [[ " $JVM_FEATURES " =~ " jvmti " ]] && ! [[ " $JVM_FEATURES " =~ " services " ]] ; then - as_fn_error $? "Specified JVM feature 'jvmti' requires feature 'services'" "$LINENO" 5 - fi - if [[ " $JVM_FEATURES " =~ " management " ]] && ! [[ " $JVM_FEATURES " =~ " nmt " ]] ; then - as_fn_error $? "Specified JVM feature 'management' requires feature 'nmt'" "$LINENO" 5 - fi - - if [[ " $JVM_FEATURES " =~ " jvmci " ]] && ! ( [[ " $JVM_FEATURES " =~ " compiler1 " ]] || [[ " $JVM_FEATURES " =~ " compiler2 " ]] ); then - as_fn_error $? "Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1'" "$LINENO" 5 - fi - - if [[ " $JVM_FEATURES " =~ " compiler2 " ]] && ! [[ " $JVM_FEATURES " =~ " all-gcs " ]] ; then - as_fn_error $? "Specified JVM feature 'compiler2' requires feature 'all-gcs'" "$LINENO" 5 - fi - - if [[ " $JVM_FEATURES " =~ " vm-structs " ]] && ! [[ " $JVM_FEATURES " =~ " all-gcs " ]] ; then - as_fn_error $? "Specified JVM feature 'vm-structs' requires feature 'all-gcs'" "$LINENO" 5 - fi - - # Turn on additional features based on other parts of configure - if test "x$INCLUDE_DTRACE" = "xtrue"; then - JVM_FEATURES="$JVM_FEATURES dtrace" - else - if [[ " $JVM_FEATURES " =~ " dtrace " ]] ; then - as_fn_error $? "To enable dtrace, you must use --enable-dtrace" "$LINENO" 5 - fi - fi - - if test "x$STATIC_BUILD" = "xtrue"; then - JVM_FEATURES="$JVM_FEATURES static-build" + if test "x$enable_aot" = "x" || test "x$enable_aot" = "xauto"; then + ENABLE_AOT="true" + elif test "x$enable_aot" = "xyes"; then + ENABLE_AOT="true" + elif test "x$enable_aot" = "xno"; then + ENABLE_AOT="false" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if aot should be enabled" >&5 +$as_echo_n "checking if aot should be enabled... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5 +$as_echo "no, forced" >&6; } else - if [[ " $JVM_FEATURES " =~ " static-build " ]] ; then - as_fn_error $? "To enable static-build, you must use --enable-static-build" "$LINENO" 5 - fi - fi - - if ! [[ " $JVM_VARIANTS " =~ " zero " ]] && ! [[ " $JVM_VARIANTS " =~ " zeroshark " ]] ; then - if [[ " $JVM_FEATURES " =~ " zero " ]] ; then - as_fn_error $? "To enable zero/zeroshark, you must use --with-jvm-variants=zero/zeroshark" "$LINENO" 5 - fi + as_fn_error $? "Invalid value for --enable-aot: $enable_aot" "$LINENO" 5 fi - if ! [[ " $JVM_VARIANTS " =~ " zeroshark " ]] ; then - if [[ " $JVM_FEATURES " =~ " shark " ]] ; then - as_fn_error $? "To enable shark, you must use --with-jvm-variants=zeroshark" "$LINENO" 5 + if test "x$ENABLE_AOT" = "xtrue"; then + # Only enable AOT on linux-X64. + if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then + if test -e "$HOTSPOT_TOPDIR/src/jdk.aot"; then + if test -e "$HOTSPOT_TOPDIR/src/jdk.vm.compiler"; then + ENABLE_AOT="true" + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + as_fn_error $? "Cannot build AOT without hotspot/src/jdk.vm.compiler sources. Remove --enable-aot." "$LINENO" 5 + fi + fi + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + as_fn_error $? "Cannot build AOT without hotspot/src/jdk.aot sources. Remove --enable-aot." "$LINENO" 5 + fi + fi + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + as_fn_error $? "AOT is currently only supported on Linux-x86_64. Remove --enable-aot." "$LINENO" 5 + fi fi fi - # Only enable jvmci on x86_64, sparcv9 and aarch64. - if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \ - test "x$OPENJDK_TARGET_CPU" = "xsparcv9" || \ - test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then - JVM_FEATURES_jvmci="jvmci" - else - JVM_FEATURES_jvmci="" - fi - - # All variants but minimal (and custom) get these features - NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" - - # Enable features depending on variant. - JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" - JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" - JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES" - JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES" - JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES" - JVM_FEATURES_zeroshark="zero shark $NON_MINIMAL_FEATURES $JVM_FEATURES" - JVM_FEATURES_custom="$JVM_FEATURES" - - - - - - - - - - # Used for verification of Makefiles by check-jvm-feature - - - # We don't support --with-jvm-interpreter anymore, use zero instead. - - -# Check whether --with-jvm-interpreter was given. -if test "${with_jvm_interpreter+set}" = set; then : - withval=$with_jvm_interpreter; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-jvm-interpreter is deprecated and will be ignored." >&5 -$as_echo "$as_me: WARNING: Option --with-jvm-interpreter is deprecated and will be ignored." >&2;} -fi - @@ -63814,6 +63812,283 @@ +# Check whether --with-libelf was given. +if test "${with_libelf+set}" = set; then : + withval=$with_libelf; +fi + + +# Check whether --with-libelf-include was given. +if test "${with_libelf_include+set}" = set; then : + withval=$with_libelf_include; +fi + + +# Check whether --with-libelf-lib was given. +if test "${with_libelf_lib+set}" = set; then : + withval=$with_libelf_lib; +fi + + + if test "x$ENABLE_AOT" = xfalse; then + if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \ + (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \ + (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libelf is not used, so --with-libelf[-*] is ignored" >&5 +$as_echo "$as_me: WARNING: libelf is not used, so --with-libelf[-*] is ignored" >&2;} + fi + LIBELF_CFLAGS= + LIBELF_LIBS= + else + LIBELF_FOUND=no + + if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then + ENABLE_AOT="false" + if test "x${enable_aot}" = xyes; then + as_fn_error $? "libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT." "$LINENO" 5 + fi + else + if test "x${with_libelf}" != x; then + ELF_LIBS="-L${with_libelf}/lib -lelf" + ELF_CFLAGS="-I${with_libelf}/include" + LIBELF_FOUND=yes + fi + if test "x${with_libelf_include}" != x; then + ELF_CFLAGS="-I${with_libelf_include}" + LIBELF_FOUND=yes + fi + if test "x${with_libelf_lib}" != x; then + ELF_LIBS="-L${with_libelf_lib} -lelf" + LIBELF_FOUND=yes + fi + # Do not try pkg-config if we have a sysroot set. + if test "x$SYSROOT" = x; then + if test "x$LIBELF_FOUND" = xno; then + # Figure out ELF_CFLAGS and ELF_LIBS + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF" >&5 +$as_echo_n "checking for ELF... " >&6; } + +if test -n "$ELF_CFLAGS"; then + pkg_cv_ELF_CFLAGS="$ELF_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libelf\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libelf") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ELF_CFLAGS=`$PKG_CONFIG --cflags "libelf" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$ELF_LIBS"; then + pkg_cv_ELF_LIBS="$ELF_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libelf\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libelf") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ELF_LIBS=`$PKG_CONFIG --libs "libelf" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + ELF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libelf" 2>&1` + else + ELF_PKG_ERRORS=`$PKG_CONFIG --print-errors "libelf" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$ELF_PKG_ERRORS" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + LIBELF_FOUND=no +elif test $pkg_failed = untried; then + LIBELF_FOUND=no +else + ELF_CFLAGS=$pkg_cv_ELF_CFLAGS + ELF_LIBS=$pkg_cv_ELF_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + LIBELF_FOUND=yes +fi + fi + fi + if test "x$LIBELF_FOUND" = xno; then + for ac_header in libelf.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "libelf.h" "ac_cv_header_libelf_h" "$ac_includes_default" +if test "x$ac_cv_header_libelf_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBELF_H 1 +_ACEOF + + LIBELF_FOUND=yes + ELF_CFLAGS= + ELF_LIBS=-lelf + +else + LIBELF_FOUND=no + +fi + +done + + fi + if test "x$LIBELF_FOUND" = xno; then + ENABLE_AOT="false" + + # Print a helpful message on how to acquire the necessary build dependency. + # elf is the help tag: freetype, cups, alsa etc + MISSING_DEPENDENCY=elf + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + cygwin_help $MISSING_DEPENDENCY + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + msys_help $MISSING_DEPENDENCY + else + PKGHANDLER_COMMAND= + + case $PKGHANDLER in + apt-get) + apt_help $MISSING_DEPENDENCY ;; + yum) + yum_help $MISSING_DEPENDENCY ;; + port) + port_help $MISSING_DEPENDENCY ;; + pkgutil) + pkgutil_help $MISSING_DEPENDENCY ;; + pkgadd) + pkgadd_help $MISSING_DEPENDENCY ;; + esac + + if test "x$PKGHANDLER_COMMAND" != x; then + HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." + fi + fi + + if test "x${enable_aot}" = xyes; then + as_fn_error $? "libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libelf not found, cannot build AOT. $HELP_MSG" >&5 +$as_echo "$as_me: WARNING: libelf not found, cannot build AOT. $HELP_MSG" >&2;} + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libelf works" >&5 +$as_echo_n "checking if libelf works... " >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $ELF_CFLAGS" + OLD_LIBS="$LIBS" + LIBS="$LIBS $ELF_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + elf_version(0); + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + LIBELF_WORKS=yes +else + LIBELF_WORKS=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$OLD_CFLAGS" + LIBS="$OLD_LIBS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBELF_WORKS" >&5 +$as_echo "$LIBELF_WORKS" >&6; } + + if test "x$LIBELF_WORKS" = xno; then + ENABLE_AOT="false" + + # Print a helpful message on how to acquire the necessary build dependency. + # elf is the help tag: freetype, cups, alsa etc + MISSING_DEPENDENCY=elf + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + cygwin_help $MISSING_DEPENDENCY + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + msys_help $MISSING_DEPENDENCY + else + PKGHANDLER_COMMAND= + + case $PKGHANDLER in + apt-get) + apt_help $MISSING_DEPENDENCY ;; + yum) + yum_help $MISSING_DEPENDENCY ;; + port) + port_help $MISSING_DEPENDENCY ;; + pkgutil) + pkgutil_help $MISSING_DEPENDENCY ;; + pkgadd) + pkgadd_help $MISSING_DEPENDENCY ;; + esac + + if test "x$PKGHANDLER_COMMAND" != x; then + HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." + fi + fi + + if test "x$enable_aot" = "xyes"; then + as_fn_error $? "Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Found libelf but could not link and compile with it. $HELP_MSG" >&5 +$as_echo "$as_me: WARNING: Found libelf but could not link and compile with it. $HELP_MSG" >&2;} + fi + fi + fi + fi + fi + + + + + + + + @@ -63825,6 +64100,141 @@ +# Hotspot setup depends on lib checks (AOT needs libelf). + + + # The user can in some cases supply additional jvm features. For the custom + # variant, this defines the entire variant. + +# Check whether --with-jvm-features was given. +if test "${with_jvm_features+set}" = set; then : + withval=$with_jvm_features; +fi + + if test "x$with_jvm_features" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking additional JVM features" >&5 +$as_echo_n "checking additional JVM features... " >&6; } + JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JVM_FEATURES" >&5 +$as_echo "$JVM_FEATURES" >&6; } + fi + + # Verify that dependencies are met for explicitly set features. + if [[ " $JVM_FEATURES " =~ " jvmti " ]] && ! [[ " $JVM_FEATURES " =~ " services " ]] ; then + as_fn_error $? "Specified JVM feature 'jvmti' requires feature 'services'" "$LINENO" 5 + fi + + if [[ " $JVM_FEATURES " =~ " management " ]] && ! [[ " $JVM_FEATURES " =~ " nmt " ]] ; then + as_fn_error $? "Specified JVM feature 'management' requires feature 'nmt'" "$LINENO" 5 + fi + + if [[ " $JVM_FEATURES " =~ " jvmci " ]] && ! ( [[ " $JVM_FEATURES " =~ " compiler1 " ]] || [[ " $JVM_FEATURES " =~ " compiler2 " ]] ); then + as_fn_error $? "Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1'" "$LINENO" 5 + fi + + if [[ " $JVM_FEATURES " =~ " compiler2 " ]] && ! [[ " $JVM_FEATURES " =~ " all-gcs " ]] ; then + as_fn_error $? "Specified JVM feature 'compiler2' requires feature 'all-gcs'" "$LINENO" 5 + fi + + if [[ " $JVM_FEATURES " =~ " vm-structs " ]] && ! [[ " $JVM_FEATURES " =~ " all-gcs " ]] ; then + as_fn_error $? "Specified JVM feature 'vm-structs' requires feature 'all-gcs'" "$LINENO" 5 + fi + + # Turn on additional features based on other parts of configure + if test "x$INCLUDE_DTRACE" = "xtrue"; then + JVM_FEATURES="$JVM_FEATURES dtrace" + else + if [[ " $JVM_FEATURES " =~ " dtrace " ]] ; then + as_fn_error $? "To enable dtrace, you must use --enable-dtrace" "$LINENO" 5 + fi + fi + + if test "x$STATIC_BUILD" = "xtrue"; then + JVM_FEATURES="$JVM_FEATURES static-build" + else + if [[ " $JVM_FEATURES " =~ " static-build " ]] ; then + as_fn_error $? "To enable static-build, you must use --enable-static-build" "$LINENO" 5 + fi + fi + + if ! [[ " $JVM_VARIANTS " =~ " zero " ]] && ! [[ " $JVM_VARIANTS " =~ " zeroshark " ]] ; then + if [[ " $JVM_FEATURES " =~ " zero " ]] ; then + as_fn_error $? "To enable zero/zeroshark, you must use --with-jvm-variants=zero/zeroshark" "$LINENO" 5 + fi + fi + + if ! [[ " $JVM_VARIANTS " =~ " zeroshark " ]] ; then + if [[ " $JVM_FEATURES " =~ " shark " ]] ; then + as_fn_error $? "To enable shark, you must use --with-jvm-variants=zeroshark" "$LINENO" 5 + fi + fi + + # Only enable jvmci on x86_64, sparcv9 and aarch64. + if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \ + test "x$OPENJDK_TARGET_CPU" = "xsparcv9" || \ + test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then + JVM_FEATURES_jvmci="jvmci" + else + JVM_FEATURES_jvmci="" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if aot should be enabled" >&5 +$as_echo_n "checking if aot should be enabled... " >&6; } + if test "x$ENABLE_AOT" = "xtrue"; then + if test "x$enable_aot" = "xyes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5 +$as_echo "yes, forced" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + fi + JVM_FEATURES_aot="aot" + else + if test "x$enable_aot" = "xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5 +$as_echo "no, forced" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + JVM_FEATURES_aot="" + fi + + # All variants but minimal (and custom) get these features + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" + + # Enable features depending on variant. + JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot" + JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" + JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES" + JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES" + JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES" + JVM_FEATURES_zeroshark="zero shark $NON_MINIMAL_FEATURES $JVM_FEATURES" + JVM_FEATURES_custom="$JVM_FEATURES" + + + + + + + + + + # Used for verification of Makefiles by check-jvm-feature + + + # We don't support --with-jvm-interpreter anymore, use zero instead. + + +# Check whether --with-jvm-interpreter was given. +if test "${with_jvm_interpreter+set}" = set; then : + withval=$with_jvm_interpreter; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --with-jvm-interpreter is deprecated and will be ignored." >&5 +$as_echo "$as_me: WARNING: Option --with-jvm-interpreter is deprecated and will be ignored." >&2;} +fi + + + + ############################################################################### # # We need to do some final tweaking, when everything else is done. --- old/common/autoconf/help.m4 2016-10-31 17:34:51.000000000 -0700 +++ new/common/autoconf/help.m4 2016-10-31 17:34:51.000000000 -0700 @@ -121,6 +121,8 @@ PKGHANDLER_COMMAND="sudo apt-get install ccache" ;; dtrace) PKGHANDLER_COMMAND="sudo apt-get install systemtap-sdt-dev" ;; + elf) + PKGHANDLER_COMMAND="sudo apt-get install libelf-dev" ;; esac } @@ -140,6 +142,8 @@ PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel" ;; ccache) PKGHANDLER_COMMAND="sudo yum install ccache" ;; + elf) + PKGHANDLER_COMMAND="sudo yum install elfutils-libelf-devel" ;; esac } --- old/common/autoconf/hotspot.m4 2016-10-31 17:34:52.000000000 -0700 +++ new/common/autoconf/hotspot.m4 2016-10-31 17:34:51.000000000 -0700 @@ -25,7 +25,7 @@ # All valid JVM features, regardless of platform VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \ - fprof vm-structs jni-check services management all-gcs nmt cds static-build" + fprof vm-structs jni-check services management all-gcs nmt cds static-build aot" # All valid JVM variants VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" @@ -174,6 +174,55 @@ AC_SUBST(INCLUDE_DTRACE) ]) +################################################################################ +# Check if AOT should be enabled +# +AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_AOT], +[ + AC_ARG_ENABLE([aot], [AS_HELP_STRING([--enable-aot@<:@=yes/no/auto@:>@], + [enable ahead of time compilation feature. Default is auto, where aot is enabled if all dependencies are present.])]) + + if test "x$enable_aot" = "x" || test "x$enable_aot" = "xauto"; then + ENABLE_AOT="true" + elif test "x$enable_aot" = "xyes"; then + ENABLE_AOT="true" + elif test "x$enable_aot" = "xno"; then + ENABLE_AOT="false" + AC_MSG_CHECKING([if aot should be enabled]) + AC_MSG_RESULT([no, forced]) + else + AC_MSG_ERROR([Invalid value for --enable-aot: $enable_aot]) + fi + + if test "x$ENABLE_AOT" = "xtrue"; then + # Only enable AOT on linux-X64. + if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then + if test -e "$HOTSPOT_TOPDIR/src/jdk.aot"; then + if test -e "$HOTSPOT_TOPDIR/src/jdk.vm.compiler"; then + ENABLE_AOT="true" + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + AC_MSG_ERROR([Cannot build AOT without hotspot/src/jdk.vm.compiler sources. Remove --enable-aot.]) + fi + fi + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + AC_MSG_ERROR([Cannot build AOT without hotspot/src/jdk.aot sources. Remove --enable-aot.]) + fi + fi + else + ENABLE_AOT="false" + if test "x$enable_aot" = "xyes"; then + AC_MSG_ERROR([AOT is currently only supported on Linux-x86_64. Remove --enable-aot.]) + fi + fi + fi + + AC_SUBST(ENABLE_AOT) +]) + ############################################################################### # Set up all JVM features for each JVM variant. # @@ -248,11 +297,28 @@ JVM_FEATURES_jvmci="" fi + AC_MSG_CHECKING([if aot should be enabled]) + if test "x$ENABLE_AOT" = "xtrue"; then + if test "x$enable_aot" = "xyes"; then + AC_MSG_RESULT([yes, forced]) + else + AC_MSG_RESULT([yes]) + fi + JVM_FEATURES_aot="aot" + else + if test "x$enable_aot" = "xno"; then + AC_MSG_RESULT([no, forced]) + else + AC_MSG_RESULT([no]) + fi + JVM_FEATURES_aot="" + fi + # All variants but minimal (and custom) get these features NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" # Enable features depending on variant. - JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" + JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot" JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES" JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES" --- old/common/autoconf/libraries.m4 2016-10-31 17:34:52.000000000 -0700 +++ new/common/autoconf/libraries.m4 2016-10-31 17:34:52.000000000 -0700 @@ -31,6 +31,7 @@ m4_include([lib-freetype.m4]) m4_include([lib-std.m4]) m4_include([lib-x11.m4]) +m4_include([lib-elf.m4]) ################################################################################ # Determine which libraries are needed for this configuration @@ -90,6 +91,7 @@ LIB_SETUP_BUNDLED_LIBS LIB_SETUP_MISC_LIBS LIB_SETUP_SOLARIS_STLPORT + LIB_SETUP_LIBELF ]) ################################################################################ --- old/common/autoconf/spec.gmk.in 2016-10-31 17:34:53.000000000 -0700 +++ new/common/autoconf/spec.gmk.in 2016-10-31 17:34:52.000000000 -0700 @@ -681,6 +681,7 @@ TAR_SUPPORTS_TRANSFORM:=@TAR_SUPPORTS_TRANSFORM@ # Build setup +ENABLE_AOT:=@ENABLE_AOT@ ENABLE_JFR=@ENABLE_JFR@ ENABLE_INTREE_EC=@ENABLE_INTREE_EC@ USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@ @@ -755,6 +756,8 @@ PNG_LIBS:=@PNG_LIBS@ PNG_CFLAGS:=@PNG_CFLAGS@ +ELF_CFLAGS:=@ELF_CFLAGS@ +ELF_LIBS:=@ELF_LIBS@ #################################################### # --- old/make/CompileJavaModules.gmk 2016-10-31 17:34:53.000000000 -0700 +++ new/make/CompileJavaModules.gmk 2016-10-31 17:34:53.000000000 -0700 @@ -452,7 +452,48 @@ ################################################################################ -jdk.vm.ci_ADD_JAVAC_FLAGS := -Xlint:-exports +# -parameters provides method's parameters information in class file, +# JVMCI compilers make use of that information for various sanity checks. + +jdk.vm.ci_ADD_JAVAC_FLAGS := -parameters -Xlint:-exports + +################################################################################ + +jdk.aot_ADD_JAVAC_FLAGS := -parameters + +################################################################################ + +jdk.vm.compiler_ADD_JAVAC_FLAGS := -parameters + +jdk.vm.compiler_EXCLUDES += \ + com.oracle.graal.compiler.match.processor \ + com.oracle.graal.nodeinfo.processor \ + com.oracle.graal.options.processor \ + com.oracle.graal.serviceprovider.processor \ + com.oracle.graal.replacements.verifier \ + com.oracle.graal.api.directives.test \ + com.oracle.graal.api.test \ + com.oracle.graal.asm.aarch64.test \ + com.oracle.graal.asm.amd64.test \ + com.oracle.graal.asm.sparc.test \ + com.oracle.graal.asm.test \ + com.oracle.graal.compiler.amd64.test \ + com.oracle.graal.compiler.sparc.test \ + com.oracle.graal.compiler.test \ + com.oracle.graal.debug.test \ + com.oracle.graal.graph.test \ + com.oracle.graal.hotspot.amd64.test \ + com.oracle.graal.hotspot.lir.test \ + com.oracle.graal.hotspot.test \ + com.oracle.graal.jtt \ + com.oracle.graal.lir.jtt \ + com.oracle.graal.lir.test \ + com.oracle.graal.nodes.test \ + com.oracle.graal.options.test \ + com.oracle.graal.phases.common.test \ + com.oracle.graal.replacements.test \ + com.oracle.graal.test \ + # ################################################################################ @@ -508,6 +549,22 @@ MODULESOURCEPATH := $(call PathList, $(JVMCI_MODULESOURCEPATH)) endif +ifeq ($(MODULE), jdk.vm.compiler) + ## WORKAROUND jdk.vm.compiler source structure issue + VM_COMPILER_MODULESOURCEPATH := $(MODULESOURCEPATH) \ + $(subst /$(MODULE)/,/*/, $(filter-out %processor/src %test/src %jtt/src, \ + $(wildcard $(HOTSPOT_TOPDIR)/src/$(MODULE)/share/classes/*/src))) + MODULESOURCEPATH := $(call PathList, $(VM_COMPILER_MODULESOURCEPATH)) +endif + +ifeq ($(MODULE), jdk.aot) + ## WORKAROUND jdk.aot source structure issue + AOT_MODULESOURCEPATH := $(MODULESOURCEPATH) \ + $(subst /$(MODULE)/,/*/, $(filter-out %processor/src, \ + $(wildcard $(HOTSPOT_TOPDIR)/src/$(MODULE)/share/classes/*/src))) + MODULESOURCEPATH := $(call PathList, $(AOT_MODULESOURCEPATH)) +endif + $(eval $(call SetupJavaCompilation, $(MODULE), \ SETUP := $(if $($(MODULE)_SETUP), $($(MODULE)_SETUP), GENERATE_JDKBYTECODE), \ MODULE := $(MODULE), \ --- old/make/GensrcModuleInfo.gmk 2016-10-31 17:34:54.000000000 -0700 +++ new/make/GensrcModuleInfo.gmk 2016-10-31 17:34:54.000000000 -0700 @@ -92,10 +92,12 @@ # Returns non empty if the package exists in the current module # Param 1 - Name of package with dots PackageExists = \ - $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \ - $(MODULE_CLASSES_DIRS) \ - $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \ - $(JDK_OUTPUTDIR)/modules/$(MODULE) \ + $(strip $(wildcard $(foreach s, $(subst .,/,/$(strip $1)) $(subst .,/,/*/src/$(strip $1)), \ + $(addsuffix $s, \ + $(MODULE_CLASSES_DIRS) \ + $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \ + $(JDK_OUTPUTDIR)/modules/$(MODULE) \ + ) \ ))) # Convert the modification lines into arguments for the modification tool. @@ -119,7 +121,12 @@ $(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \ $(eval ARGS += -$(command) $(provider)/$(class)) \ , \ - $(error A module-info.extra in $(MODULE) contains invalid command $(command)) \ + $(if $(filter $(command), uses), \ + $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \ + $(eval ARGS += -$(command) $(provider)) \ + , \ + $(error A module-info.java.extra in $(MODULE) contains invalid command $(command)) \ + ) \ ) \ ) \ ) --- old/make/Main.gmk 2016-10-31 17:34:54.000000000 -0700 +++ new/make/Main.gmk 2016-10-31 17:34:54.000000000 -0700 @@ -85,10 +85,14 @@ buildtools-modules: +($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileModuleTools.gmk) + + buildtools-hotspot: + +($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk) endif ALL_TARGETS += buildtools-langtools interim-langtools \ - interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules + interim-rmic interim-cldrconverter buildtools-jdk buildtools-modules \ + buildtools-hotspot ################################################################################ # Special targets for certain modules @@ -515,11 +519,13 @@ buildtools-jdk: interim-langtools interim-cldrconverter + buildtools-hotspot: interim-langtools + buildtools-modules: exploded-image-base $(CORBA_GENSRC_TARGETS): interim-langtools - $(HOTSPOT_GENSRC_TARGETS): interim-langtools + $(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk @@ -589,6 +595,14 @@ # current JDK. jdk.vm.ci-gensrc-hotspot: java.base-java + # The annotation processing for jdk.vm.compiler needs classes from the current JDK. + jdk.vm.compiler-gensrc-hotspot: java.base-java java.management-java \ + jdk.management-java jdk.vm.ci-java jdk.unsupported-java + + # For jdk.vm.compiler, the gensrc step is generating a module-info.java.extra + # file to be processed by the gensrc-moduleinfo target. + jdk.vm.compiler-gensrc-moduleinfo: jdk.vm.compiler-gensrc-hotspot + # Explicitly add dependencies for special targets java.base-java: unpack-sec @@ -738,7 +752,7 @@ # Virtual targets without recipes buildtools: buildtools-langtools interim-langtools interim-rmic \ - buildtools-jdk + buildtools-jdk buildtools-hotspot gensrc: $(GENSRC_TARGETS) --- old/make/common/Modules.gmk 2016-10-31 17:34:55.000000000 -0700 +++ new/make/common/Modules.gmk 2016-10-31 17:34:54.000000000 -0700 @@ -144,6 +144,13 @@ endif ################################################################################ +# Filter out aot specific modules if aot is disabled + +ifeq ($(ENABLE_AOT), false) + MODULES_FILTER += jdk.aot jdk.vm.compiler +endif + +################################################################################ # Module list macros # Use append so that the custom extension may add to these variables --- /dev/null 2016-10-31 17:34:55.000000000 -0700 +++ new/common/autoconf/lib-elf.m4 2016-10-31 17:34:55.000000000 -0700 @@ -0,0 +1,129 @@ +# +# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Setup libelf (ELF library) +################################################################################ +AC_DEFUN_ONCE([LIB_SETUP_LIBELF], +[ + AC_ARG_WITH(libelf, [AS_HELP_STRING([--with-libelf], + [specify prefix directory for the libelf package + (expecting the libraries under PATH/lib and the headers under PATH/include)])]) + AC_ARG_WITH(libelf-include, [AS_HELP_STRING([--with-libelf-include], + [specify directory for the libelf include files])]) + AC_ARG_WITH(libelf-lib, [AS_HELP_STRING([--with-libelf-lib], + [specify directory for the libelf library])]) + + if test "x$ENABLE_AOT" = xfalse; then + if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \ + (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \ + (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then + AC_MSG_WARN([[libelf is not used, so --with-libelf[-*] is ignored]]) + fi + LIBELF_CFLAGS= + LIBELF_LIBS= + else + LIBELF_FOUND=no + + if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then + ENABLE_AOT="false" + if test "x${enable_aot}" = xyes; then + AC_MSG_ERROR([libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT.]) + fi + else + if test "x${with_libelf}" != x; then + ELF_LIBS="-L${with_libelf}/lib -lelf" + ELF_CFLAGS="-I${with_libelf}/include" + LIBELF_FOUND=yes + fi + if test "x${with_libelf_include}" != x; then + ELF_CFLAGS="-I${with_libelf_include}" + LIBELF_FOUND=yes + fi + if test "x${with_libelf_lib}" != x; then + ELF_LIBS="-L${with_libelf_lib} -lelf" + LIBELF_FOUND=yes + fi + # Do not try pkg-config if we have a sysroot set. + if test "x$SYSROOT" = x; then + if test "x$LIBELF_FOUND" = xno; then + # Figure out ELF_CFLAGS and ELF_LIBS + PKG_CHECK_MODULES([ELF], [libelf], [LIBELF_FOUND=yes], [LIBELF_FOUND=no]) + fi + fi + if test "x$LIBELF_FOUND" = xno; then + AC_CHECK_HEADERS([libelf.h], + [ + LIBELF_FOUND=yes + ELF_CFLAGS= + ELF_LIBS=-lelf + ], + [LIBELF_FOUND=no] + ) + fi + if test "x$LIBELF_FOUND" = xno; then + ENABLE_AOT="false" + HELP_MSG_MISSING_DEPENDENCY([elf]) + if test "x${enable_aot}" = xyes; then + AC_MSG_ERROR([libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG]) + else + AC_MSG_WARN([libelf not found, cannot build AOT. $HELP_MSG]) + fi + else + AC_MSG_CHECKING([if libelf works]) + AC_LANG_PUSH(C) + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $ELF_CFLAGS" + OLD_LIBS="$LIBS" + LIBS="$LIBS $ELF_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [ + elf_version(0); + return 0; + ])], + [LIBELF_WORKS=yes], + [LIBELF_WORKS=no] + ) + CFLAGS="$OLD_CFLAGS" + LIBS="$OLD_LIBS" + AC_LANG_POP(C) + AC_MSG_RESULT([$LIBELF_WORKS]) + + if test "x$LIBELF_WORKS" = xno; then + ENABLE_AOT="false" + HELP_MSG_MISSING_DEPENDENCY([elf]) + if test "x$enable_aot" = "xyes"; then + AC_MSG_ERROR([Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG]) + else + AC_MSG_WARN([Found libelf but could not link and compile with it. $HELP_MSG]) + fi + fi + fi + fi + fi + + AC_SUBST(ELF_CFLAGS) + AC_SUBST(ELF_LIBS) +])