erikj@459: # erikj@459: # Copyright (c) 2011, 2012, 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: [ erikj@459: AC_MSG_CHECKING([for number of cores]) erikj@459: NUM_CORES=1 erikj@459: FOUND_CORES=no erikj@459: erikj@459: if test -f /proc/cpuinfo; then ohair@478: # Looks like a Linux (or cygwin) system erikj@459: NUM_CORES=`cat /proc/cpuinfo | grep -c processor` erikj@459: FOUND_CORES=yes ohair@478: elif test -x /usr/sbin/psrinfo; then erikj@459: # Looks like a Solaris system erikj@459: NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` erikj@459: FOUND_CORES=yes ohair@478: elif test -x /usr/sbin/system_profiler; then erikj@459: # Looks like a MacOSX system erikj@459: NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` erikj@459: FOUND_CORES=yes erikj@459: fi erikj@459: erikj@459: # For c/c++ code we run twice as many concurrent build erikj@459: # jobs than we have cores, otherwise we will stall on io. erikj@459: CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` erikj@459: erikj@459: if test "x$FOUND_CORES" = xyes; then erikj@459: AC_MSG_RESULT([$NUM_CORES]) erikj@459: else erikj@459: AC_MSG_RESULT([could not detect number of cores, defaulting to 1!]) erikj@459: fi erikj@459: erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_CHECK_MEMORY_SIZE], erikj@459: [ erikj@459: AC_MSG_CHECKING([for memory size]) ohair@478: # Default to 1024 MB erikj@459: MEMORY_SIZE=1024 erikj@459: FOUND_MEM=no erikj@459: ohair@478: if test -f /proc/meminfo; then ohair@478: # Looks like a Linux (or cygwin) system erikj@459: MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` erikj@459: MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` erikj@459: FOUND_MEM=yes ohair@478: elif test -x /usr/sbin/prtconf; then erikj@459: # Looks like a Solaris system erikj@459: MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'` erikj@459: FOUND_MEM=yes ohair@478: elif test -x /usr/sbin/system_profiler; then erikj@459: # Looks like a MacOSX system erikj@459: MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` erikj@459: MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` erikj@459: FOUND_MEM=yes ohair@478: elif test "x$build_os" = xwindows; then ohair@478: # Windows, but without cygwin erikj@459: MEMORY_SIZE=`systeminfo | grep 'Total Physical Memory:' | awk '{ print [$]4 }' | sed 's/,//'` erikj@459: FOUND_MEM=yes erikj@459: fi erikj@459: erikj@459: if test "x$FOUND_MEM" = xyes; then erikj@459: AC_MSG_RESULT([$MEMORY_SIZE MB]) erikj@459: else ohair@478: AC_MSG_RESULT([could not detect memory size defaulting to 1024 MB!]) erikj@459: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], erikj@459: [ erikj@459: # How many cores do we have on this build system? erikj@459: AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], erikj@459: [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) erikj@459: 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@459: else erikj@459: NUM_CORES=$with_num_cores erikj@459: CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` erikj@459: fi erikj@459: AC_SUBST(NUM_CORES) erikj@459: AC_SUBST(CONCURRENT_BUILD_JOBS) erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], erikj@459: [ erikj@459: # How much memory do we have on this build system? erikj@459: AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], erikj@459: [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) erikj@459: 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@459: else erikj@459: MEMORY_SIZE=$with_memory_size erikj@459: fi erikj@459: AC_SUBST(MEMORY_SIZE) erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_SETUP_CCACHE], erikj@459: [ erikj@459: AC_ARG_ENABLE([ccache], erikj@459: [AS_HELP_STRING([--disable-ccache], erikj@459: [use ccache to speed up recompilations @<:@enabled@:>@])], erikj@459: [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) erikj@459: if test "x$ENABLE_CCACHE" = xyes; then erikj@459: AC_PATH_PROG(CCACHE, ccache) erikj@459: else erikj@459: AC_MSG_CHECKING([for ccache]) erikj@459: AC_MSG_RESULT([explicitly disabled]) erikj@459: CCACHE= erikj@459: fi erikj@459: AC_SUBST(CCACHE) erikj@459: erikj@459: AC_ARG_WITH([ccache-dir], erikj@459: [AS_HELP_STRING([--with-ccache-dir], erikj@459: [where to store ccache files @<:@~/.ccache@:>@])]) erikj@459: erikj@459: if test "x$with_ccache_dir" != x; then erikj@459: # When using a non home ccache directory, assume the use is to share ccache files erikj@459: # with other users. Thus change the umask. erikj@459: SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" erikj@459: fi erikj@459: CCACHE_FOUND="" erikj@459: if test "x$CCACHE" != x; then erikj@459: BPERF_SETUP_CCACHE_USAGE erikj@459: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], erikj@459: [ erikj@459: if test "x$CCACHE" != x; then erikj@459: CCACHE_FOUND="true" erikj@459: # Only use ccache if it is 3.1.4 or later, which supports erikj@459: # precompiled headers. erikj@459: AC_MSG_CHECKING([if ccache supports precompiled headers]) erikj@459: HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` erikj@459: if test "x$HAS_GOOD_CCACHE" = x; then erikj@459: AC_MSG_RESULT([no, disabling ccache]) erikj@459: CCACHE= erikj@459: else erikj@459: AC_MSG_RESULT([yes]) erikj@459: AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) erikj@459: PUSHED_FLAGS="$CXXFLAGS" erikj@459: CXXFLAGS="-fpch-preprocess $CXXFLAGS" erikj@459: AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) erikj@459: CXXFLAGS="$PUSHED_FLAGS" erikj@459: if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then erikj@459: AC_MSG_RESULT([yes]) erikj@459: else erikj@459: AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) erikj@459: CCACHE= erikj@459: fi erikj@459: fi erikj@459: fi erikj@459: erikj@459: if test "x$CCACHE" != x; then erikj@459: CCACHE_SLOPPINESS=time_macros erikj@459: CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" erikj@459: CCACHE_FLAGS=-fpch-preprocess erikj@459: erikj@459: if test "x$SET_CCACHE_DIR" != x; then erikj@459: mkdir -p $CCACHE_DIR > /dev/null 2>&1 erikj@459: chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 erikj@459: fi erikj@459: fi erikj@459: ]) erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], erikj@459: [ erikj@459: erikj@459: ############################################################################### erikj@459: # erikj@459: # Can the C/C++ compiler use precompiled headers? erikj@459: # erikj@459: AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], erikj@459: [use precompiled headers when compiling C++ @<:@enabled@:>@])], erikj@459: [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes]) erikj@459: erikj@459: USE_PRECOMPILED_HEADER=1 erikj@459: if test "x$ENABLE_PRECOMPH" = xno; then erikj@459: USE_PRECOMPILED_HEADER=0 erikj@459: fi erikj@459: erikj@459: if test "x$ENABLE_PRECOMPH" = xyes; then erikj@459: # Check that the compiler actually supports precomp headers. erikj@459: if test "x$GCC" = xyes; then erikj@459: AC_MSG_CHECKING([that precompiled headers work]) erikj@459: echo "int alfa();" > conftest.h erikj@459: $CXX -x c++-header conftest.h -o conftest.hpp.gch erikj@459: if test ! -f conftest.hpp.gch; then erikj@459: echo Precompiled header is not working! erikj@459: USE_PRECOMPILED_HEADER=0 erikj@459: AC_MSG_RESULT([no]) erikj@459: else erikj@459: AC_MSG_RESULT([yes]) erikj@459: fi erikj@459: rm -f conftest.h erikj@459: fi erikj@459: fi erikj@459: erikj@459: AC_SUBST(USE_PRECOMPILED_HEADER) erikj@459: ]) erikj@459: erikj@459: erikj@459: AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], erikj@459: [ ohair@478: AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], ohair@478: [use this java binary for running the sjavac background server and other long running java tasks in the build process, ohair@478: e.g. ---with-sjavac-server-java="/opt/jrockit/bin/java -server"])]) erikj@459: ohair@478: 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 ohair@478: AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) erikj@459: fi erikj@459: 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" erikj@459: fi ohair@478: AC_SUBST(SJAVAC_SERVER_JAVA) erikj@459: ohair@478: AC_ARG_WITH(sjavac-server-cores, [AS_HELP_STRING([--with-sjavac-server-cores], ohair@478: [use at most this number of concurrent threads on the sjavac server @<:@probed@:>@])]) ohair@478: if test "x$with_sjavac_server_cores" != x; then ohair@478: SJAVAC_SERVER_CORES="$with_sjavac_server_cores" erikj@459: else erikj@459: if test "$NUM_CORES" -gt 16; then erikj@459: # We set this arbitrary limit because we want to limit the heap erikj@459: # size of the javac server. erikj@459: # In the future we will make the javac compilers in the server erikj@459: # share more and more state, thus enabling us to use more and erikj@459: # more concurrent threads in the server. ohair@478: SJAVAC_SERVER_CORES="16" erikj@459: else ohair@478: SJAVAC_SERVER_CORES="$NUM_CORES" erikj@459: fi erikj@459: erikj@459: if test "$MEMORY_SIZE" -gt "17000"; then erikj@459: MAX_HEAP_MEM=10000 ohair@478: ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: elif test "$MEMORY_SIZE" -gt "10000"; then erikj@459: MAX_HEAP_MEM=6000 ohair@478: ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: elif test "$MEMORY_SIZE" -gt "5000"; then erikj@459: MAX_HEAP_MEM=3000 ohair@478: ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: elif test "$MEMORY_SIZE" -gt "3800"; then erikj@459: MAX_HEAP_MEM=2500 ohair@478: ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: elif test "$MEMORY_SIZE" -gt "1900"; then erikj@459: MAX_HEAP_MEM=1200 ohair@478: ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1400M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: elif test "$MEMORY_SIZE" -gt "1000"; then erikj@459: MAX_HEAP_MEM=900 ohair@478: ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: else erikj@459: MAX_HEAP_MEM=512 ohair@478: ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) erikj@459: fi erikj@459: ohair@478: ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) ohair@478: erikj@459: MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501` ohair@478: if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then erikj@459: AC_MSG_CHECKING([if number of server cores must be reduced]) ohair@478: SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP" ohair@478: AC_MSG_RESULT([yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB]) erikj@459: fi erikj@459: fi ohair@478: AC_SUBST(SJAVAC_SERVER_CORES) erikj@459: erikj@459: AC_MSG_CHECKING([whether to use sjavac]) erikj@459: AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], erikj@459: [use sjavac to do fast incremental compiles @<:@disabled@:>@])], erikj@459: [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) erikj@459: AC_MSG_RESULT([$ENABLE_SJAVAC]) erikj@459: AC_SUBST(ENABLE_SJAVAC) erikj@459: ohair@478: if test "x$ENABLE_SJAVAC" = xyes; then ohair@478: SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" ohair@478: else ohair@478: SJAVAC_SERVER_DIR= ohair@478: fi ohair@478: AC_SUBST(SJAVAC_SERVER_DIR) ohair@478: erikj@459: ])