erikj@459: # aleonard@2451: # Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. erikj@459: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. erikj@459: # erikj@459: # This code is free software; you can redistribute it and/or modify it erikj@459: # under the terms of the GNU General Public License version 2 only, as erikj@459: # published by the Free Software Foundation. Oracle designates this erikj@459: # particular file as subject to the "Classpath" exception as provided erikj@459: # by Oracle in the LICENSE file that accompanied this code. erikj@459: # erikj@459: # This code is distributed in the hope that it will be useful, but WITHOUT erikj@459: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or erikj@459: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License erikj@459: # version 2 for more details (a copy is included in the LICENSE file that erikj@459: # accompanied this code). erikj@459: # erikj@459: # You should have received a copy of the GNU General Public License version erikj@459: # 2 along with this work; if not, write to the Free Software Foundation, erikj@459: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. erikj@459: # erikj@459: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA erikj@459: # or visit www.oracle.com if you need additional information or have any erikj@459: # questions. erikj@459: # erikj@459: erikj@459: AC_DEFUN([BPERF_CHECK_CORES], erikj@459: [ ihse@839: AC_MSG_CHECKING([for number of cores]) ihse@839: NUM_CORES=1 ihse@839: FOUND_CORES=no erikj@459: ihse@839: if test -f /proc/cpuinfo; then ihse@839: # Looks like a Linux (or cygwin) system ihse@839: NUM_CORES=`cat /proc/cpuinfo | grep -c processor` ihse@839: FOUND_CORES=yes ihse@839: elif test -x /usr/sbin/psrinfo; then ihse@839: # Looks like a Solaris system ihse@839: NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` ihse@839: FOUND_CORES=yes ihse@839: elif test -x /usr/sbin/system_profiler; then ihse@839: # Looks like a MacOSX system ihse@839: NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` ihse@839: FOUND_CORES=yes kvn@972: elif test "x$OPENJDK_BUILD_OS" = xaix ; then aleonard@2451: NUM_LCPU=`lparstat -m 2> /dev/null | $GREP -o "lcpu=[[0-9]]*" | $CUT -d "=" -f 2` aleonard@2451: if test -n "$NUM_LCPU"; then aleonard@2451: NUM_CORES=$NUM_LCPU aleonard@2451: FOUND_CORES=yes aleonard@2451: fi ihse@839: elif test -n "$NUMBER_OF_PROCESSORS"; then ihse@839: # On windows, look in the env ihse@839: NUM_CORES=$NUMBER_OF_PROCESSORS ihse@839: FOUND_CORES=yes ihse@839: fi erikj@459: ihse@839: if test "x$FOUND_CORES" = xyes; then ihse@839: AC_MSG_RESULT([$NUM_CORES]) ihse@839: else ihse@839: AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) ihse@839: AC_MSG_WARN([This will disable all parallelism from build!]) ihse@839: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_CHECK_MEMORY_SIZE], erikj@459: [ ihse@839: AC_MSG_CHECKING([for memory size]) ihse@839: # Default to 1024 MB ihse@839: MEMORY_SIZE=1024 ihse@839: FOUND_MEM=no erikj@459: ihse@839: if test -f /proc/meminfo; then ihse@839: # Looks like a Linux (or cygwin) system ihse@839: MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` ihse@839: MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` ihse@839: FOUND_MEM=yes ihse@839: elif test -x /usr/sbin/prtconf; then kvn@972: # Looks like a Solaris or AIX system kvn@972: MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'` ihse@839: FOUND_MEM=yes ihse@839: elif test -x /usr/sbin/system_profiler; then ihse@839: # Looks like a MacOSX system ihse@839: MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` ihse@839: MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` ihse@839: FOUND_MEM=yes ihse@839: elif test "x$OPENJDK_BUILD_OS" = xwindows; then ihse@839: # Windows, but without cygwin ihse@839: MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-` ihse@839: MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024` ihse@839: FOUND_MEM=yes ihse@839: fi ihse@839: ihse@839: if test "x$FOUND_MEM" = xyes; then ihse@839: AC_MSG_RESULT([$MEMORY_SIZE MB]) ihse@839: else ihse@839: AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB]) ihse@839: AC_MSG_WARN([This might seriously impact build performance!]) ihse@839: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], erikj@459: [ erikj@635: # How many cores do we have on this build system? erikj@635: AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], ihse@839: [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) erikj@635: if test "x$with_num_cores" = x; then erikj@459: # The number of cores were not specified, try to probe them. erikj@459: BPERF_CHECK_CORES erikj@635: else erikj@459: NUM_CORES=$with_num_cores erikj@635: fi erikj@635: AC_SUBST(NUM_CORES) erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], erikj@459: [ erikj@635: # How much memory do we have on this build system? erikj@635: AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], ihse@839: [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) erikj@635: if test "x$with_memory_size" = x; then erikj@459: # The memory size was not specified, try to probe it. erikj@459: BPERF_CHECK_MEMORY_SIZE erikj@635: else erikj@459: MEMORY_SIZE=$with_memory_size erikj@635: fi erikj@635: AC_SUBST(MEMORY_SIZE) erikj@635: ]) erikj@635: erikj@635: AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], erikj@635: [ ihse@839: # Provide a decent default number of parallel jobs for make depending on erikj@635: # number of cores, amount of memory and machine architecture. erikj@635: AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs], ihse@839: [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])]) erikj@635: if test "x$with_jobs" = x; then erikj@635: # Number of jobs was not specified, calculate. erikj@635: AC_MSG_CHECKING([for appropriate number of jobs to run in parallel]) erikj@635: # Approximate memory in GB, rounding up a bit. erikj@635: memory_gb=`expr $MEMORY_SIZE / 1100` erikj@635: # Pick the lowest of memory in gb and number of cores. erikj@635: if test "$memory_gb" -lt "$NUM_CORES"; then erikj@635: JOBS="$memory_gb" erikj@635: else erikj@635: JOBS="$NUM_CORES" erikj@635: # On bigger machines, leave some room for other processes to run erikj@635: if test "$JOBS" -gt "4"; then erikj@635: JOBS=`expr $JOBS '*' 90 / 100` erikj@635: fi erikj@635: fi erikj@635: # Cap number of jobs to 16 erikj@635: if test "$JOBS" -gt "16"; then erikj@635: JOBS=16 erikj@635: fi erikj@724: if test "$JOBS" -eq "0"; then erikj@724: JOBS=1 erikj@724: fi erikj@635: AC_MSG_RESULT([$JOBS]) erikj@635: else erikj@635: JOBS=$with_jobs erikj@635: fi erikj@635: AC_SUBST(JOBS) erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_SETUP_CCACHE], erikj@459: [ ihse@839: AC_ARG_ENABLE([ccache], kevinw@2203: [AS_HELP_STRING([--enable-ccache], kevinw@2203: [enable using ccache to speed up recompilations @<:@disabled@:>@])]) kevinw@2203: kevinw@2203: CCACHE= kevinw@2203: AC_MSG_CHECKING([is ccache enabled]) kevinw@2203: ENABLE_CCACHE=$enable_ccache kevinw@2203: if test "x$enable_ccache" = xyes; then kevinw@2203: AC_MSG_RESULT([yes]) ihse@839: OLD_PATH="$PATH" kevinw@2215: if test "x$TOOLCHAIN_PATH" != x; then kevinw@2215: PATH=$TOOLCHAIN_PATH:$PATH ihse@839: fi kevinw@2204: BASIC_REQUIRE_PROGS(CCACHE, ccache) kevinw@2203: CCACHE_STATUS="enabled" ihse@839: PATH="$OLD_PATH" kevinw@2203: elif test "x$enable_ccache" = xno; then kevinw@2203: AC_MSG_RESULT([no, explicitly disabled]) kevinw@2203: elif test "x$enable_ccache" = x; then kevinw@2203: AC_MSG_RESULT([no]) ihse@839: else kevinw@2203: AC_MSG_RESULT([unknown]) kevinw@2203: AC_MSG_ERROR([--enable-ccache does not accept any parameters]) ihse@839: fi ihse@839: AC_SUBST(CCACHE) erikj@459: ihse@839: AC_ARG_WITH([ccache-dir], ihse@839: [AS_HELP_STRING([--with-ccache-dir], ihse@839: [where to store ccache files @<:@~/.ccache@:>@])]) erikj@459: ihse@839: if test "x$with_ccache_dir" != x; then ihse@839: # When using a non home ccache directory, assume the use is to share ccache files ihse@839: # with other users. Thus change the umask. ihse@839: SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" kevinw@2203: if test "x$CCACHE" = x; then kevinw@2203: AC_MSG_WARN([--with-ccache-dir has no meaning when ccache is not enabled]) kevinw@2203: fi ihse@839: fi kevinw@2203: ihse@839: if test "x$CCACHE" != x; then ihse@839: BPERF_SETUP_CCACHE_USAGE ihse@839: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], erikj@459: [ ihse@839: if test "x$CCACHE" != x; then ihse@839: # Only use ccache if it is 3.1.4 or later, which supports ihse@839: # precompiled headers. ihse@839: AC_MSG_CHECKING([if ccache supports precompiled headers]) ihse@839: HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` ihse@839: if test "x$HAS_GOOD_CCACHE" = x; then ihse@839: AC_MSG_RESULT([no, disabling ccache]) ihse@839: CCACHE= kevinw@2203: CCACHE_STATUS="disabled" ihse@839: else ihse@839: AC_MSG_RESULT([yes]) ihse@839: AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) ihse@839: PUSHED_FLAGS="$CXXFLAGS" ihse@839: CXXFLAGS="-fpch-preprocess $CXXFLAGS" ihse@839: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) ihse@839: CXXFLAGS="$PUSHED_FLAGS" ihse@839: if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then ihse@839: AC_MSG_RESULT([yes]) ihse@839: else ihse@839: AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) ihse@839: CCACHE= kevinw@2203: CCACHE_STATUS="disabled" ihse@839: fi erikj@459: fi ihse@839: fi erikj@459: ihse@839: if test "x$CCACHE" != x; then ihse@839: CCACHE_SLOPPINESS=time_macros ihse@839: CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" ihse@839: CCACHE_FLAGS=-fpch-preprocess erikj@459: ihse@839: if test "x$SET_CCACHE_DIR" != x; then ihse@839: mkdir -p $CCACHE_DIR > /dev/null 2>&1 ihse@839: chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 erikj@459: fi ihse@839: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], erikj@459: [ erikj@459: ihse@839: ############################################################################### ihse@839: # ihse@839: # Can the C/C++ compiler use precompiled headers? ihse@839: # ihse@839: AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], ihse@839: [disable using precompiled headers when compiling C++ @<:@enabled@:>@])], ihse@839: [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes]) ihse@839: ihse@839: USE_PRECOMPILED_HEADER=1 ihse@839: if test "x$ENABLE_PRECOMPH" = xno; then erikj@459: USE_PRECOMPILED_HEADER=0 ihse@839: fi erikj@459: ihse@839: if test "x$ENABLE_PRECOMPH" = xyes; then erikj@459: # Check that the compiler actually supports precomp headers. kevinw@2206: if test "x$TOOLCHAIN_TYPE" = xgcc; then ihse@839: AC_MSG_CHECKING([that precompiled headers work]) ihse@839: echo "int alfa();" > conftest.h ihse@839: $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD ihse@839: if test ! -f conftest.hpp.gch; then ihse@839: USE_PRECOMPILED_HEADER=0 ihse@839: AC_MSG_RESULT([no]) ihse@839: else ihse@839: AC_MSG_RESULT([yes]) ihse@839: fi ihse@839: rm -f conftest.h conftest.hpp.gch erikj@459: fi ihse@839: fi erikj@459: ihse@839: AC_SUBST(USE_PRECOMPILED_HEADER) erikj@459: ]) erikj@459: erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], erikj@459: [ ihse@839: AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], ihse@839: [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])]) erikj@459: ihse@839: if test "x$with_sjavac_server_java" != x; then ohair@478: SJAVAC_SERVER_JAVA="$with_sjavac_server_java" ohair@478: FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` erikj@459: if test "x$FOUND_VERSION" = x; then ihse@839: AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) erikj@459: fi ihse@839: else ohair@478: SJAVAC_SERVER_JAVA="" erikj@459: # Hotspot specific options. ohair@478: ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) erikj@459: # JRockit specific options. ohair@478: ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) ohair@478: SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" ihse@839: fi ihse@839: AC_SUBST(SJAVAC_SERVER_JAVA) erikj@459: ihse@839: if test "$MEMORY_SIZE" -gt "2500"; then erikj@717: ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@717: if test "$JVM_ARG_OK" = true; then ihse@839: JVM_64BIT=true ihse@839: JVM_ARG_OK=false erikj@717: fi ihse@839: fi erikj@459: ihse@839: if test "$JVM_64BIT" = true; then erikj@459: if test "$MEMORY_SIZE" -gt "17000"; then ihse@839: ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@717: fi erikj@717: if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then ihse@839: ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@717: fi erikj@717: if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then ihse@839: ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@717: fi erikj@717: if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then ihse@839: ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: fi ihse@839: fi ihse@839: if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then erikj@717: ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ihse@839: fi ihse@839: if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then erikj@717: ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ihse@839: fi ihse@839: if test "$JVM_ARG_OK" = false; then erikj@717: ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ihse@839: fi erikj@459: ihse@839: AC_MSG_CHECKING([whether to use sjavac]) ihse@839: AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], ihse@839: [use sjavac to do fast incremental compiles @<:@disabled@:>@])], ihse@839: [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) ihse@839: AC_MSG_RESULT([$ENABLE_SJAVAC]) ihse@839: AC_SUBST(ENABLE_SJAVAC) erikj@459: ihse@839: if test "x$ENABLE_SJAVAC" = xyes; then ohair@478: SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" ihse@839: else ohair@478: SJAVAC_SERVER_DIR= ihse@839: fi ihse@839: AC_SUBST(SJAVAC_SERVER_DIR) erikj@459: ])