build-performance.m4 revision 1929:a2a3930ed7c3
1184610Salfred#
2184610Salfred# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3184610Salfred# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4184610Salfred#
5213435Shselasky# This code is free software; you can redistribute it and/or modify it
6184610Salfred# under the terms of the GNU General Public License version 2 only, as
7184610Salfred# published by the Free Software Foundation.  Oracle designates this
8184610Salfred# particular file as subject to the "Classpath" exception as provided
9184610Salfred# by Oracle in the LICENSE file that accompanied this code.
10184610Salfred#
11184610Salfred# This code is distributed in the hope that it will be useful, but WITHOUT
12184610Salfred# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13184610Salfred# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14184610Salfred# version 2 for more details (a copy is included in the LICENSE file that
15184610Salfred# accompanied this code).
16184610Salfred#
17184610Salfred# You should have received a copy of the GNU General Public License version
18184610Salfred# 2 along with this work; if not, write to the Free Software Foundation,
19184610Salfred# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20184610Salfred#
21184610Salfred# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22184610Salfred# or visit www.oracle.com if you need additional information or have any
23184610Salfred# questions.
24184610Salfred#
25184610Salfred
26184610SalfredAC_DEFUN([BPERF_CHECK_CORES],
27184610Salfred[
28184610Salfred  AC_MSG_CHECKING([for number of cores])
29184610Salfred  NUM_CORES=1
30190754Sthompsa  FOUND_CORES=no
31184610Salfred
32184610Salfred  if test -f /proc/cpuinfo; then
33246122Shselasky    # Looks like a Linux (or cygwin) system
34246122Shselasky    NUM_CORES=`cat /proc/cpuinfo  | grep -c processor`
35246122Shselasky    FOUND_CORES=yes
36194677Sthompsa  elif test -x /usr/sbin/psrinfo; then
37194677Sthompsa    # Looks like a Solaris system
38194677Sthompsa    NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
39194677Sthompsa    FOUND_CORES=yes
40194677Sthompsa  elif test -x /usr/sbin/sysctl; then
41194677Sthompsa    # Looks like a MacOSX system
42194677Sthompsa    NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
43194677Sthompsa    FOUND_CORES=yes
44194677Sthompsa  elif test "x$OPENJDK_BUILD_OS" = xaix ; then
45194677Sthompsa    NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'`
46194677Sthompsa    FOUND_CORES=yes
47194677Sthompsa  elif test -n "$NUMBER_OF_PROCESSORS"; then
48194677Sthompsa    # On windows, look in the env
49194677Sthompsa    NUM_CORES=$NUMBER_OF_PROCESSORS
50194677Sthompsa    FOUND_CORES=yes
51194677Sthompsa  fi
52194677Sthompsa
53194677Sthompsa  if test "x$FOUND_CORES" = xyes; then
54194677Sthompsa    AC_MSG_RESULT([$NUM_CORES])
55188942Sthompsa  else
56194677Sthompsa    AC_MSG_RESULT([could not detect number of cores, defaulting to 1])
57212136Sthompsa    AC_MSG_WARN([This will disable all parallelism from build!])
58184610Salfred  fi
59184610Salfred])
60184610Salfred
61188942SthompsaAC_DEFUN([BPERF_CHECK_MEMORY_SIZE],
62188942Sthompsa[
63188942Sthompsa  AC_MSG_CHECKING([for memory size])
64188942Sthompsa  # Default to 1024 MB
65188942Sthompsa  MEMORY_SIZE=1024
66188942Sthompsa  FOUND_MEM=no
67188942Sthompsa
68188942Sthompsa  if test -f /proc/meminfo; then
69188942Sthompsa    # Looks like a Linux (or cygwin) system
70188942Sthompsa    MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'`
71184610Salfred    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
72188942Sthompsa    FOUND_MEM=yes
73188942Sthompsa  elif test -x /usr/sbin/prtconf; then
74246122Shselasky    # Looks like a Solaris or AIX system
75184610Salfred    MEMORY_SIZE=`/usr/sbin/prtconf 2> /dev/null | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'`
76184610Salfred    FOUND_MEM=yes
77261105Shselasky  elif test -x /usr/sbin/sysctl; then
78261105Shselasky    # Looks like a MacOSX system
79261105Shselasky    MEMORY_SIZE=`/usr/sbin/sysctl -n hw.memsize`
80261105Shselasky    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
81261105Shselasky    FOUND_MEM=yes
82261105Shselasky  elif test "x$OPENJDK_BUILD_OS" = xwindows; then
83261105Shselasky    # Windows, but without cygwin
84184610Salfred    MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
85194677Sthompsa    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
86184610Salfred    FOUND_MEM=yes
87184610Salfred  fi
88227309Sed
89242126Shselasky  if test "x$FOUND_MEM" = xyes; then
90184610Salfred    AC_MSG_RESULT([$MEMORY_SIZE MB])
91199675Sthompsa  else
92184610Salfred    AC_MSG_RESULT([could not detect memory size, defaulting to $MEMORY_SIZE MB])
93184610Salfred    AC_MSG_WARN([This might seriously impact build performance!])
94190735Sthompsa  fi
95194228Sthompsa])
96186730Salfred
97192502SthompsaAC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES],
98194228Sthompsa[
99190735Sthompsa  # How many cores do we have on this build system?
100186730Salfred  AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
101184610Salfred      [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
102184610Salfred  if test "x$with_num_cores" = x; then
103184610Salfred    # The number of cores were not specified, try to probe them.
104184610Salfred    BPERF_CHECK_CORES
105184610Salfred  else
106184610Salfred    NUM_CORES=$with_num_cores
107184610Salfred  fi
108250207Shselasky  AC_SUBST(NUM_CORES)
109250207Shselasky])
110250207Shselasky
111184610SalfredAC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY],
112196498Salfred[
113192984Sthompsa  # How much memory do we have on this build system?
114192984Sthompsa  AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
115184610Salfred      [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
116185087Salfred  if test "x$with_memory_size" = x; then
117184610Salfred    # The memory size was not specified, try to probe it.
118184610Salfred    BPERF_CHECK_MEMORY_SIZE
119184610Salfred  else
120184610Salfred    MEMORY_SIZE=$with_memory_size
121184610Salfred  fi
122234803Shselasky  AC_SUBST(MEMORY_SIZE)
123213435Shselasky])
124184610Salfred
125184610SalfredAC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS],
126184610Salfred[
127184610Salfred  # Provide a decent default number of parallel jobs for make depending on
128184610Salfred  # number of cores, amount of memory and machine architecture.
129184610Salfred  AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs],
130186730Salfred      [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])])
131186730Salfred  if test "x$with_jobs" = x; then
132184610Salfred    # Number of jobs was not specified, calculate.
133184610Salfred    AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
134184610Salfred    # Approximate memory in GB.
135184610Salfred    memory_gb=`expr $MEMORY_SIZE / 1024`
136184610Salfred    # Pick the lowest of memory in gb and number of cores.
137193045Sthompsa    if test "$memory_gb" -lt "$NUM_CORES"; then
138261105Shselasky      JOBS="$memory_gb"
139261105Shselasky    else
140261105Shselasky      JOBS="$NUM_CORES"
141184610Salfred    fi
142194228Sthompsa    if test "$JOBS" -eq "0"; then
143194228Sthompsa      JOBS=1
144208008Sthompsa    fi
145186730Salfred    AC_MSG_RESULT([$JOBS])
146192984Sthompsa  else
147184610Salfred    JOBS=$with_jobs
148261105Shselasky  fi
149184610Salfred  AC_SUBST(JOBS)
150184610Salfred])
151184610Salfred
152190734SthompsaAC_DEFUN_ONCE([BPERF_SETUP_TEST_JOBS],
153190734Sthompsa[
154190734Sthompsa  # The number of test jobs will be chosen automatically if TEST_JOBS is 0
155190734Sthompsa  AC_ARG_WITH(test-jobs, [AS_HELP_STRING([--with-test-jobs],
156190734Sthompsa      [number of parallel tests jobs to run @<:@based on build jobs@:>@])])
157184610Salfred  if test "x$with_test_jobs" = x; then
158261105Shselasky      TEST_JOBS=0
159261105Shselasky  else
160261105Shselasky      TEST_JOBS=$with_test_jobs
161261105Shselasky  fi
162261105Shselasky  AC_SUBST(TEST_JOBS)
163261105Shselasky])
164261105Shselasky
165261105ShselaskyAC_DEFUN([BPERF_SETUP_CCACHE],
166261105Shselasky[
167261105Shselasky  AC_ARG_ENABLE([ccache],
168261105Shselasky      [AS_HELP_STRING([--enable-ccache],
169184610Salfred      [enable using ccache to speed up recompilations @<:@disabled@:>@])])
170184610Salfred
171184610Salfred  CCACHE=
172184610Salfred  CCACHE_STATUS=
173184610Salfred  AC_MSG_CHECKING([is ccache enabled])
174184610Salfred  if test "x$enable_ccache" = xyes; then
175184610Salfred    if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then
176184610Salfred      AC_MSG_RESULT([yes])
177190735Sthompsa      OLD_PATH="$PATH"
178190735Sthompsa      if test "x$TOOLCHAIN_PATH" != x; then
179190735Sthompsa        PATH=$TOOLCHAIN_PATH:$PATH
180190735Sthompsa      fi
181184610Salfred      BASIC_REQUIRE_PROGS(CCACHE, ccache)
182190735Sthompsa      PATH="$OLD_PATH"
183190735Sthompsa      CCACHE_VERSION=[`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`]
184184610Salfred      CCACHE_STATUS="Active ($CCACHE_VERSION)"
185190735Sthompsa    else
186190735Sthompsa      AC_MSG_RESULT([no])
187190735Sthompsa      AC_MSG_WARN([ccache is not supported with toolchain type $TOOLCHAIN_TYPE])
188241128Shselasky    fi
189190735Sthompsa  elif test "x$enable_ccache" = xno; then
190190735Sthompsa    AC_MSG_RESULT([no, explicitly disabled])
191190735Sthompsa    CCACHE_STATUS="Disabled"
192190735Sthompsa  elif test "x$enable_ccache" = x; then
193190735Sthompsa    AC_MSG_RESULT([no])
194184610Salfred  else
195184610Salfred    AC_MSG_RESULT([unknown])
196184610Salfred    AC_MSG_ERROR([--enable-ccache does not accept any parameters])
197189275Sthompsa  fi
198189275Sthompsa  AC_SUBST(CCACHE)
199212122Sthompsa
200184610Salfred  AC_ARG_WITH([ccache-dir],
201184610Salfred      [AS_HELP_STRING([--with-ccache-dir],
202194677Sthompsa      [where to store ccache files @<:@~/.ccache@:>@])])
203184610Salfred
204194677Sthompsa  if test "x$with_ccache_dir" != x; then
205184610Salfred    # When using a non home ccache directory, assume the use is to share ccache files
206184610Salfred    # with other users. Thus change the umask.
207184610Salfred    SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002"
208184610Salfred    if test "x$CCACHE" = x; then
209184610Salfred      AC_MSG_WARN([--with-ccache-dir has no meaning when ccache is not enabled])
210184610Salfred    fi
211184610Salfred  fi
212184610Salfred
213184610Salfred  if test "x$CCACHE" != x; then
214184610Salfred    BPERF_SETUP_CCACHE_USAGE
215194228Sthompsa  fi
216184610Salfred])
217184610Salfred
218194677SthompsaAC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
219194228Sthompsa[
220187178Sthompsa  if test "x$CCACHE" != x; then
221184610Salfred    if test "x$USE_PRECOMPILED_HEADER" = "x1"; then
222184610Salfred      HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \
223184610Salfred          $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]$'`]
224187178Sthompsa      if test "x$HAS_BAD_CCACHE" != "x"; then
225187178Sthompsa        AC_MSG_ERROR([Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION])
226187178Sthompsa      fi
227187178Sthompsa      AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
228187178Sthompsa      CCACHE_PRECOMP_FLAG="-fpch-preprocess"
229194677Sthompsa      PUSHED_FLAGS="$CXXFLAGS"
230194677Sthompsa      CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS"
231194228Sthompsa      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
232184610Salfred      CXXFLAGS="$PUSHED_FLAGS"
233187178Sthompsa      if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
234184610Salfred        AC_MSG_RESULT([yes])
235184610Salfred        CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG"
236184610Salfred        AC_SUBST(CFLAGS_CCACHE)
237184610Salfred        CCACHE_SLOPPINESS=pch_defines,time_macros
238261105Shselasky      else
239261105Shselasky        AC_MSG_RESULT([no])
240261105Shselasky        AC_MSG_ERROR([Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG])
241261105Shselasky      fi
242261105Shselasky    fi
243261105Shselasky
244261105Shselasky    CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \
245261105Shselasky        CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE"
246261105Shselasky
247261105Shselasky    if test "x$SET_CCACHE_DIR" != x; then
248261105Shselasky      mkdir -p $CCACHE_DIR > /dev/null 2>&1
249261105Shselasky      chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
250261105Shselasky    fi
251261105Shselasky  fi
252261105Shselasky])
253261105Shselasky
254261105Shselasky################################################################################
255261105Shselasky#
256261105Shselasky# Runs icecc-create-env once and prints the error if it fails
257261105Shselasky#
258261105Shselasky# $1: arguments to icecc-create-env
259261105Shselasky# $2: log file
260261105Shselasky#
261261105ShselaskyAC_DEFUN([BPERF_RUN_ICECC_CREATE_ENV],
262261105Shselasky[
263261105Shselasky  ( cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
264261105Shselasky      && ${ICECC_CREATE_ENV} $1 > $2 2>&1 )
265261105Shselasky  if test "$?" != "0"; then
266261105Shselasky    AC_MSG_NOTICE([icecc-create-env output:])
267261105Shselasky    cat $2
268261105Shselasky    AC_MSG_ERROR([Failed to create icecc compiler environment])
269261105Shselasky  fi
270261105Shselasky])
271261105Shselasky
272261105Shselasky################################################################################
273261105Shselasky#
274261105Shselasky# Optionally enable distributed compilation of native code using icecc/icecream
275261105Shselasky#
276261105ShselaskyAC_DEFUN([BPERF_SETUP_ICECC],
277261105Shselasky[
278261105Shselasky  AC_ARG_ENABLE([icecc], [AS_HELP_STRING([--enable-icecc],
279261105Shselasky      [enable distribted compilation of native code using icecc/icecream @<:@disabled@:>@])])
280261105Shselasky
281261105Shselasky  if test "x${enable_icecc}" = "xyes"; then
282261105Shselasky    BASIC_REQUIRE_PROGS(ICECC_CMD, icecc)
283261105Shselasky    old_path="$PATH"
284261105Shselasky
285261105Shselasky    # Look for icecc-create-env in some known places
286261105Shselasky    PATH="$PATH:/usr/lib/icecc:/usr/lib64/icecc"
287261105Shselasky    BASIC_REQUIRE_PROGS(ICECC_CREATE_ENV, icecc-create-env)
288261105Shselasky    # Use icecc-create-env to create a minimal compilation environment that can
289261105Shselasky    # be sent to the other hosts in the icecream cluster.
290261105Shselasky    icecc_create_env_log="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env.log"
291261105Shselasky    ${MKDIR} -p ${CONFIGURESUPPORT_OUTPUTDIR}/icecc
292261105Shselasky    # Older versions of icecc does not have the --gcc parameter
293261105Shselasky    if ${ICECC_CREATE_ENV} | $GREP -q -e --gcc; then
294261105Shselasky      icecc_gcc_arg="--gcc"
295261105Shselasky    fi
296261105Shselasky    if test "x${TOOLCHAIN_TYPE}" = "xgcc"; then
297261105Shselasky      BPERF_RUN_ICECC_CREATE_ENV([${icecc_gcc_arg} ${CC} ${CXX}], \
298261105Shselasky          ${icecc_create_env_log})
299261105Shselasky    elif test "x$TOOLCHAIN_TYPE" = "xclang"; then
300261105Shselasky      # For clang, the icecc compilerwrapper is needed. It usually resides next
301261105Shselasky      # to icecc-create-env.
302261105Shselasky      BASIC_REQUIRE_PROGS(ICECC_WRAPPER, compilerwrapper)
303261105Shselasky      BPERF_RUN_ICECC_CREATE_ENV([--clang ${CC} ${ICECC_WRAPPER}], ${icecc_create_env_log})
304261105Shselasky    else
305261105Shselasky      AC_MSG_ERROR([Can only create icecc compiler packages for toolchain types gcc and clang])
306261105Shselasky    fi
307261105Shselasky    PATH="$old_path"
308261105Shselasky    # The bundle with the compiler gets a name based on checksums. Parse log file
309261105Shselasky    # to find it.
310261105Shselasky    ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log}`"
311261105Shselasky    ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
312261105Shselasky    if test ! -f ${ICECC_ENV_BUNDLE}; then
313261105Shselasky      AC_MSG_ERROR([icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}])
314261105Shselasky    fi
315261105Shselasky    AC_MSG_CHECKING([for icecc build environment for target compiler])
316261105Shselasky    AC_MSG_RESULT([${ICECC_ENV_BUNDLE}])
317261105Shselasky    ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${CC} ICECC_CXX=${CXX} ${ICECC_CMD}"
318261105Shselasky
319261105Shselasky    if test "x${COMPILE_TYPE}" = "xcross"; then
320261105Shselasky      # If cross compiling, create a separate env package for the build compiler
321261105Shselasky      # Assume "gcc" or "cc" is gcc and "clang" is clang. Otherwise bail.
322261105Shselasky      icecc_create_env_log_build="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env_build.log"
323261105Shselasky      if test "x${BUILD_CC##*/}" = "xgcc" ||  test "x${BUILD_CC##*/}" = "xcc"; then
324261105Shselasky        BPERF_RUN_ICECC_CREATE_ENV([${icecc_gcc_arg} ${BUILD_CC} ${BUILD_CXX}], \
325261105Shselasky            ${icecc_create_env_log_build})
326261105Shselasky      elif test "x${BUILD_CC##*/}" = "xclang"; then
327261105Shselasky        BPERF_RUN_ICECC_CREATE_ENV([--clang ${BUILD_CC} ${ICECC_WRAPPER}], ${icecc_create_env_log_build})
328261105Shselasky      else
329261105Shselasky        AC_MSG_ERROR([Cannot create icecc compiler package for ${BUILD_CC}])
330261105Shselasky      fi
331261105Shselasky      ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log_build}`"
332261105Shselasky      ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
333261105Shselasky      if test ! -f ${ICECC_ENV_BUNDLE}; then
334261105Shselasky        AC_MSG_ERROR([icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}])
335261105Shselasky      fi
336261105Shselasky      AC_MSG_CHECKING([for icecc build environment for build compiler])
337261105Shselasky      AC_MSG_RESULT([${ICECC_ENV_BUNDLE}])
338261105Shselasky      BUILD_ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${BUILD_CC} \
339261105Shselasky          ICECC_CXX=${BUILD_CXX} ${ICECC_CMD}"
340261105Shselasky    else
341261105Shselasky      BUILD_ICECC="${ICECC}"
342261105Shselasky    fi
343261105Shselasky    AC_SUBST(ICECC)
344261105Shselasky    AC_SUBST(BUILD_ICECC)
345261105Shselasky  fi
346261105Shselasky])
347261105Shselasky
348261105ShselaskyAC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS],
349261105Shselasky[
350261105Shselasky
351261105Shselasky  ###############################################################################
352261105Shselasky  #
353261105Shselasky  # Can the C/C++ compiler use precompiled headers?
354261105Shselasky  #
355261105Shselasky  AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers],
356261105Shselasky      [disable using precompiled headers when compiling C++ @<:@enabled@:>@])],
357261105Shselasky      [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes])
358261105Shselasky
359261105Shselasky  USE_PRECOMPILED_HEADER=1
360261105Shselasky  AC_MSG_CHECKING([If precompiled header is enabled])
361261105Shselasky  if test "x$ENABLE_PRECOMPH" = xno; then
362261105Shselasky    AC_MSG_RESULT([no, forced])
363261105Shselasky    USE_PRECOMPILED_HEADER=0
364261105Shselasky  elif test "x$ICECC" != "x"; then
365261105Shselasky    AC_MSG_RESULT([no, does not work effectively with icecc])
366261105Shselasky    USE_PRECOMPILED_HEADER=0
367261105Shselasky  else
368261105Shselasky    AC_MSG_RESULT([yes])
369261105Shselasky  fi
370261105Shselasky
371261105Shselasky  if test "x$ENABLE_PRECOMPH" = xyes; then
372261105Shselasky    # Check that the compiler actually supports precomp headers.
373261105Shselasky    if test "x$TOOLCHAIN_TYPE" = xgcc; then
374261105Shselasky      AC_MSG_CHECKING([that precompiled headers work])
375261105Shselasky      echo "int alfa();" > conftest.h
376261105Shselasky      $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
377261105Shselasky      if test ! -f conftest.hpp.gch; then
378261105Shselasky        USE_PRECOMPILED_HEADER=0
379261105Shselasky        AC_MSG_RESULT([no])
380261105Shselasky      else
381261105Shselasky        AC_MSG_RESULT([yes])
382261105Shselasky      fi
383261105Shselasky      rm -f conftest.h conftest.hpp.gch
384261105Shselasky    fi
385261105Shselasky  fi
386261105Shselasky
387261105Shselasky  AC_SUBST(USE_PRECOMPILED_HEADER)
388261105Shselasky])
389261105Shselasky
390261105Shselasky
391261105ShselaskyAC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
392261105Shselasky[
393261105Shselasky  AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java],
394261105Shselasky      [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])])
395261105Shselasky
396261105Shselasky  if test "x$with_sjavac_server_java" != x; then
397261105Shselasky    SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
398261105Shselasky    FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
399261105Shselasky    if test "x$FOUND_VERSION" = x; then
400261105Shselasky      AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
401261105Shselasky    fi
402261105Shselasky  else
403261105Shselasky    SJAVAC_SERVER_JAVA="$JAVA"
404261105Shselasky  fi
405261105Shselasky  AC_SUBST(SJAVAC_SERVER_JAVA)
406261105Shselasky
407261105Shselasky  if test "$MEMORY_SIZE" -gt "3000"; then
408261105Shselasky    ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA_FLAGS,[$SJAVAC_SERVER_JAVA])
409261105Shselasky    if test "$JVM_ARG_OK" = true; then
410261105Shselasky      JVM_64BIT=true
411261105Shselasky      JVM_ARG_OK=false
412261105Shselasky    fi
413261105Shselasky  fi
414261105Shselasky
415261105Shselasky  MX_VALUE=`expr $MEMORY_SIZE / 2`
416261105Shselasky  if test "$JVM_64BIT" = true; then
417261105Shselasky    # Set ms lower than mx since more than one instance of the server might
418261105Shselasky    # get launched at the same time before they figure out which instance won.
419261105Shselasky    MS_VALUE=512
420261105Shselasky    if test "$MX_VALUE" -gt "2048"; then
421261105Shselasky      MX_VALUE=2048
422261105Shselasky    fi
423261105Shselasky  else
424261105Shselasky    MS_VALUE=256
425261105Shselasky    if test "$MX_VALUE" -gt "1500"; then
426261105Shselasky      MX_VALUE=1500
427261105Shselasky    fi
428261105Shselasky  fi
429261105Shselasky  if test "$MX_VALUE" -lt "512"; then
430267347Shselasky    MX_VALUE=512
431267347Shselasky  fi
432267347Shselasky  ADD_JVM_ARG_IF_OK([-Xms${MS_VALUE}M -Xmx${MX_VALUE}M],SJAVAC_SERVER_JAVA_FLAGS,[$SJAVAC_SERVER_JAVA])
433267347Shselasky  AC_SUBST(SJAVAC_SERVER_JAVA_FLAGS)
434267347Shselasky
435267347Shselasky  AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
436267347Shselasky      [use sjavac to do fast incremental compiles @<:@disabled@:>@])],
437267347Shselasky      [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC="no"])
438267347Shselasky  if test "x$JVM_ARG_OK" = "xfalse"; then
439267347Shselasky    AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac])
440267347Shselasky    ENABLE_SJAVAC="no"
441267347Shselasky  fi
442267347Shselasky  AC_MSG_CHECKING([whether to use sjavac])
443267347Shselasky  AC_MSG_RESULT([$ENABLE_SJAVAC])
444267347Shselasky  AC_SUBST(ENABLE_SJAVAC)
445267347Shselasky
446267347Shselasky  AC_ARG_ENABLE([javac-server], [AS_HELP_STRING([--disable-javac-server],
447267347Shselasky      [disable javac server @<:@enabled@:>@])],
448267347Shselasky      [ENABLE_JAVAC_SERVER="${enableval}"], [ENABLE_JAVAC_SERVER="yes"])
449267347Shselasky  if test "x$JVM_ARG_OK" = "xfalse"; then
450267347Shselasky    AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling javac server])
451267347Shselasky    ENABLE_JAVAC_SERVER="no"
452267347Shselasky  fi
453267347Shselasky  AC_MSG_CHECKING([whether to use javac server])
454267347Shselasky  AC_MSG_RESULT([$ENABLE_JAVAC_SERVER])
455267347Shselasky  AC_SUBST(ENABLE_JAVAC_SERVER)
456267347Shselasky
457267347Shselasky  if test "x$ENABLE_JAVAC_SERVER" = "xyes" || "x$ENABLE_SJAVAC" = "xyes"; then
458267347Shselasky    # When using a server javac, the small client instances do not need much
459267347Shselasky    # resources.
460267347Shselasky    JAVA_FLAGS_JAVAC="$JAVA_FLAGS_SMALL"
461267347Shselasky  fi
462267347Shselasky])
463267347Shselasky