common/autoconf/build-performance.m4

Thu, 05 Apr 2018 07:59:52 -0700

author
kevinw
date
Thu, 05 Apr 2018 07:59:52 -0700
changeset 2206
7ba4e17574e0
parent 2204
0e87966d7ff1
child 2215
7a73b8b4ac8a
permissions
-rw-r--r--

8034788: Rewrite toolchain.m4 to support multiple toolchains per platform.
Reviewed-by: ihse, henryjen, erikj

erikj@459 1 #
kevinw@2206 2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
erikj@459 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@459 4 #
erikj@459 5 # This code is free software; you can redistribute it and/or modify it
erikj@459 6 # under the terms of the GNU General Public License version 2 only, as
erikj@459 7 # published by the Free Software Foundation. Oracle designates this
erikj@459 8 # particular file as subject to the "Classpath" exception as provided
erikj@459 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@459 10 #
erikj@459 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@459 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@459 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@459 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@459 15 # accompanied this code).
erikj@459 16 #
erikj@459 17 # You should have received a copy of the GNU General Public License version
erikj@459 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@459 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@459 20 #
erikj@459 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@459 22 # or visit www.oracle.com if you need additional information or have any
erikj@459 23 # questions.
erikj@459 24 #
erikj@459 25
erikj@459 26 AC_DEFUN([BPERF_CHECK_CORES],
erikj@459 27 [
ihse@839 28 AC_MSG_CHECKING([for number of cores])
ihse@839 29 NUM_CORES=1
ihse@839 30 FOUND_CORES=no
erikj@459 31
ihse@839 32 if test -f /proc/cpuinfo; then
ihse@839 33 # Looks like a Linux (or cygwin) system
ihse@839 34 NUM_CORES=`cat /proc/cpuinfo | grep -c processor`
ihse@839 35 FOUND_CORES=yes
ihse@839 36 elif test -x /usr/sbin/psrinfo; then
ihse@839 37 # Looks like a Solaris system
ihse@839 38 NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
ihse@839 39 FOUND_CORES=yes
ihse@839 40 elif test -x /usr/sbin/system_profiler; then
ihse@839 41 # Looks like a MacOSX system
ihse@839 42 NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'`
ihse@839 43 FOUND_CORES=yes
kvn@972 44 elif test "x$OPENJDK_BUILD_OS" = xaix ; then
kvn@972 45 NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'`
kvn@972 46 FOUND_CORES=yes
ihse@839 47 elif test -n "$NUMBER_OF_PROCESSORS"; then
ihse@839 48 # On windows, look in the env
ihse@839 49 NUM_CORES=$NUMBER_OF_PROCESSORS
ihse@839 50 FOUND_CORES=yes
ihse@839 51 fi
erikj@459 52
ihse@839 53 if test "x$FOUND_CORES" = xyes; then
ihse@839 54 AC_MSG_RESULT([$NUM_CORES])
ihse@839 55 else
ihse@839 56 AC_MSG_RESULT([could not detect number of cores, defaulting to 1])
ihse@839 57 AC_MSG_WARN([This will disable all parallelism from build!])
ihse@839 58 fi
erikj@459 59 ])
erikj@459 60
erikj@459 61 AC_DEFUN([BPERF_CHECK_MEMORY_SIZE],
erikj@459 62 [
ihse@839 63 AC_MSG_CHECKING([for memory size])
ihse@839 64 # Default to 1024 MB
ihse@839 65 MEMORY_SIZE=1024
ihse@839 66 FOUND_MEM=no
erikj@459 67
ihse@839 68 if test -f /proc/meminfo; then
ihse@839 69 # Looks like a Linux (or cygwin) system
ihse@839 70 MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'`
ihse@839 71 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
ihse@839 72 FOUND_MEM=yes
ihse@839 73 elif test -x /usr/sbin/prtconf; then
kvn@972 74 # Looks like a Solaris or AIX system
kvn@972 75 MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'`
ihse@839 76 FOUND_MEM=yes
ihse@839 77 elif test -x /usr/sbin/system_profiler; then
ihse@839 78 # Looks like a MacOSX system
ihse@839 79 MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'`
ihse@839 80 MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
ihse@839 81 FOUND_MEM=yes
ihse@839 82 elif test "x$OPENJDK_BUILD_OS" = xwindows; then
ihse@839 83 # Windows, but without cygwin
ihse@839 84 MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
ihse@839 85 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
ihse@839 86 FOUND_MEM=yes
ihse@839 87 fi
ihse@839 88
ihse@839 89 if test "x$FOUND_MEM" = xyes; then
ihse@839 90 AC_MSG_RESULT([$MEMORY_SIZE MB])
ihse@839 91 else
ihse@839 92 AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB])
ihse@839 93 AC_MSG_WARN([This might seriously impact build performance!])
ihse@839 94 fi
erikj@459 95 ])
erikj@459 96
erikj@459 97 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES],
erikj@459 98 [
erikj@635 99 # How many cores do we have on this build system?
erikj@635 100 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
ihse@839 101 [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
erikj@635 102 if test "x$with_num_cores" = x; then
erikj@459 103 # The number of cores were not specified, try to probe them.
erikj@459 104 BPERF_CHECK_CORES
erikj@635 105 else
erikj@459 106 NUM_CORES=$with_num_cores
erikj@635 107 fi
erikj@635 108 AC_SUBST(NUM_CORES)
erikj@459 109 ])
erikj@459 110
erikj@459 111 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY],
erikj@459 112 [
erikj@635 113 # How much memory do we have on this build system?
erikj@635 114 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
ihse@839 115 [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
erikj@635 116 if test "x$with_memory_size" = x; then
erikj@459 117 # The memory size was not specified, try to probe it.
erikj@459 118 BPERF_CHECK_MEMORY_SIZE
erikj@635 119 else
erikj@459 120 MEMORY_SIZE=$with_memory_size
erikj@635 121 fi
erikj@635 122 AC_SUBST(MEMORY_SIZE)
erikj@635 123 ])
erikj@635 124
erikj@635 125 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS],
erikj@635 126 [
ihse@839 127 # Provide a decent default number of parallel jobs for make depending on
erikj@635 128 # number of cores, amount of memory and machine architecture.
erikj@635 129 AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs],
ihse@839 130 [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])])
erikj@635 131 if test "x$with_jobs" = x; then
erikj@635 132 # Number of jobs was not specified, calculate.
erikj@635 133 AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
erikj@635 134 # Approximate memory in GB, rounding up a bit.
erikj@635 135 memory_gb=`expr $MEMORY_SIZE / 1100`
erikj@635 136 # Pick the lowest of memory in gb and number of cores.
erikj@635 137 if test "$memory_gb" -lt "$NUM_CORES"; then
erikj@635 138 JOBS="$memory_gb"
erikj@635 139 else
erikj@635 140 JOBS="$NUM_CORES"
erikj@635 141 # On bigger machines, leave some room for other processes to run
erikj@635 142 if test "$JOBS" -gt "4"; then
erikj@635 143 JOBS=`expr $JOBS '*' 90 / 100`
erikj@635 144 fi
erikj@635 145 fi
erikj@635 146 # Cap number of jobs to 16
erikj@635 147 if test "$JOBS" -gt "16"; then
erikj@635 148 JOBS=16
erikj@635 149 fi
erikj@724 150 if test "$JOBS" -eq "0"; then
erikj@724 151 JOBS=1
erikj@724 152 fi
erikj@635 153 AC_MSG_RESULT([$JOBS])
erikj@635 154 else
erikj@635 155 JOBS=$with_jobs
erikj@635 156 fi
erikj@635 157 AC_SUBST(JOBS)
erikj@459 158 ])
erikj@459 159
erikj@459 160 AC_DEFUN([BPERF_SETUP_CCACHE],
erikj@459 161 [
ihse@839 162 AC_ARG_ENABLE([ccache],
kevinw@2203 163 [AS_HELP_STRING([--enable-ccache],
kevinw@2203 164 [enable using ccache to speed up recompilations @<:@disabled@:>@])])
kevinw@2203 165
kevinw@2203 166 CCACHE=
kevinw@2203 167 AC_MSG_CHECKING([is ccache enabled])
kevinw@2203 168 ENABLE_CCACHE=$enable_ccache
kevinw@2203 169 if test "x$enable_ccache" = xyes; then
kevinw@2203 170 AC_MSG_RESULT([yes])
ihse@839 171 OLD_PATH="$PATH"
ihse@839 172 if test "x$TOOLS_DIR" != x; then
ihse@839 173 PATH=$TOOLS_DIR:$PATH
ihse@839 174 fi
kevinw@2204 175 BASIC_REQUIRE_PROGS(CCACHE, ccache)
kevinw@2203 176 CCACHE_STATUS="enabled"
ihse@839 177 PATH="$OLD_PATH"
kevinw@2203 178 elif test "x$enable_ccache" = xno; then
kevinw@2203 179 AC_MSG_RESULT([no, explicitly disabled])
kevinw@2203 180 elif test "x$enable_ccache" = x; then
kevinw@2203 181 AC_MSG_RESULT([no])
ihse@839 182 else
kevinw@2203 183 AC_MSG_RESULT([unknown])
kevinw@2203 184 AC_MSG_ERROR([--enable-ccache does not accept any parameters])
ihse@839 185 fi
ihse@839 186 AC_SUBST(CCACHE)
erikj@459 187
ihse@839 188 AC_ARG_WITH([ccache-dir],
ihse@839 189 [AS_HELP_STRING([--with-ccache-dir],
ihse@839 190 [where to store ccache files @<:@~/.ccache@:>@])])
erikj@459 191
ihse@839 192 if test "x$with_ccache_dir" != x; then
ihse@839 193 # When using a non home ccache directory, assume the use is to share ccache files
ihse@839 194 # with other users. Thus change the umask.
ihse@839 195 SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002"
kevinw@2203 196 if test "x$CCACHE" = x; then
kevinw@2203 197 AC_MSG_WARN([--with-ccache-dir has no meaning when ccache is not enabled])
kevinw@2203 198 fi
ihse@839 199 fi
kevinw@2203 200
ihse@839 201 if test "x$CCACHE" != x; then
ihse@839 202 BPERF_SETUP_CCACHE_USAGE
ihse@839 203 fi
erikj@459 204 ])
erikj@459 205
erikj@459 206 AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
erikj@459 207 [
ihse@839 208 if test "x$CCACHE" != x; then
ihse@839 209 # Only use ccache if it is 3.1.4 or later, which supports
ihse@839 210 # precompiled headers.
ihse@839 211 AC_MSG_CHECKING([if ccache supports precompiled headers])
ihse@839 212 HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
ihse@839 213 if test "x$HAS_GOOD_CCACHE" = x; then
ihse@839 214 AC_MSG_RESULT([no, disabling ccache])
ihse@839 215 CCACHE=
kevinw@2203 216 CCACHE_STATUS="disabled"
ihse@839 217 else
ihse@839 218 AC_MSG_RESULT([yes])
ihse@839 219 AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
ihse@839 220 PUSHED_FLAGS="$CXXFLAGS"
ihse@839 221 CXXFLAGS="-fpch-preprocess $CXXFLAGS"
ihse@839 222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
ihse@839 223 CXXFLAGS="$PUSHED_FLAGS"
ihse@839 224 if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
ihse@839 225 AC_MSG_RESULT([yes])
ihse@839 226 else
ihse@839 227 AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
ihse@839 228 CCACHE=
kevinw@2203 229 CCACHE_STATUS="disabled"
ihse@839 230 fi
erikj@459 231 fi
ihse@839 232 fi
erikj@459 233
ihse@839 234 if test "x$CCACHE" != x; then
ihse@839 235 CCACHE_SLOPPINESS=time_macros
ihse@839 236 CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
ihse@839 237 CCACHE_FLAGS=-fpch-preprocess
erikj@459 238
ihse@839 239 if test "x$SET_CCACHE_DIR" != x; then
ihse@839 240 mkdir -p $CCACHE_DIR > /dev/null 2>&1
ihse@839 241 chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
erikj@459 242 fi
ihse@839 243 fi
erikj@459 244 ])
erikj@459 245
erikj@459 246 AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS],
erikj@459 247 [
erikj@459 248
ihse@839 249 ###############################################################################
ihse@839 250 #
ihse@839 251 # Can the C/C++ compiler use precompiled headers?
ihse@839 252 #
ihse@839 253 AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers],
ihse@839 254 [disable using precompiled headers when compiling C++ @<:@enabled@:>@])],
ihse@839 255 [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes])
ihse@839 256
ihse@839 257 USE_PRECOMPILED_HEADER=1
ihse@839 258 if test "x$ENABLE_PRECOMPH" = xno; then
erikj@459 259 USE_PRECOMPILED_HEADER=0
ihse@839 260 fi
erikj@459 261
ihse@839 262 if test "x$ENABLE_PRECOMPH" = xyes; then
erikj@459 263 # Check that the compiler actually supports precomp headers.
kevinw@2206 264 if test "x$TOOLCHAIN_TYPE" = xgcc; then
ihse@839 265 AC_MSG_CHECKING([that precompiled headers work])
ihse@839 266 echo "int alfa();" > conftest.h
ihse@839 267 $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
ihse@839 268 if test ! -f conftest.hpp.gch; then
ihse@839 269 USE_PRECOMPILED_HEADER=0
ihse@839 270 AC_MSG_RESULT([no])
ihse@839 271 else
ihse@839 272 AC_MSG_RESULT([yes])
ihse@839 273 fi
ihse@839 274 rm -f conftest.h conftest.hpp.gch
erikj@459 275 fi
ihse@839 276 fi
erikj@459 277
ihse@839 278 AC_SUBST(USE_PRECOMPILED_HEADER)
erikj@459 279 ])
erikj@459 280
erikj@459 281
erikj@459 282 AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
erikj@459 283 [
ihse@839 284 AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java],
ihse@839 285 [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])])
erikj@459 286
ihse@839 287 if test "x$with_sjavac_server_java" != x; then
ohair@478 288 SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
ohair@478 289 FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
erikj@459 290 if test "x$FOUND_VERSION" = x; then
ihse@839 291 AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
erikj@459 292 fi
ihse@839 293 else
ohair@478 294 SJAVAC_SERVER_JAVA=""
erikj@459 295 # Hotspot specific options.
ohair@478 296 ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA])
erikj@459 297 # JRockit specific options.
ohair@478 298 ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA])
ohair@478 299 SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
ihse@839 300 fi
ihse@839 301 AC_SUBST(SJAVAC_SERVER_JAVA)
erikj@459 302
ihse@839 303 if test "$MEMORY_SIZE" -gt "2500"; then
erikj@717 304 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 305 if test "$JVM_ARG_OK" = true; then
ihse@839 306 JVM_64BIT=true
ihse@839 307 JVM_ARG_OK=false
erikj@717 308 fi
ihse@839 309 fi
erikj@459 310
ihse@839 311 if test "$JVM_64BIT" = true; then
erikj@459 312 if test "$MEMORY_SIZE" -gt "17000"; then
ihse@839 313 ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 314 fi
erikj@717 315 if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then
ihse@839 316 ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 317 fi
erikj@717 318 if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then
ihse@839 319 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 320 fi
erikj@717 321 if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then
ihse@839 322 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@459 323 fi
ihse@839 324 fi
ihse@839 325 if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then
erikj@717 326 ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
ihse@839 327 fi
ihse@839 328 if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then
erikj@717 329 ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
ihse@839 330 fi
ihse@839 331 if test "$JVM_ARG_OK" = false; then
erikj@717 332 ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
ihse@839 333 fi
erikj@459 334
ihse@839 335 AC_MSG_CHECKING([whether to use sjavac])
ihse@839 336 AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
ihse@839 337 [use sjavac to do fast incremental compiles @<:@disabled@:>@])],
ihse@839 338 [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no'])
ihse@839 339 AC_MSG_RESULT([$ENABLE_SJAVAC])
ihse@839 340 AC_SUBST(ENABLE_SJAVAC)
erikj@459 341
ihse@839 342 if test "x$ENABLE_SJAVAC" = xyes; then
ohair@478 343 SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
ihse@839 344 else
ohair@478 345 SJAVAC_SERVER_DIR=
ihse@839 346 fi
ihse@839 347 AC_SUBST(SJAVAC_SERVER_DIR)
erikj@459 348 ])

mercurial