From: Amos Jeffries Date: Sun, 5 Dec 2010 14:29:27 +0000 (+1300) Subject: Build libprofiler only when it will be operational X-Git-Tag: take1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e44eea8bb03064e166f372e9f67776b60c05e70;p=thirdparty%2Fsquid.git Build libprofiler only when it will be operational The internal CPU profiler requires specific CPU support. It is not useful to build and link the library unless it is going to work. Uses AC_PREPROC_IFELSE to allow building on cross-compilers. --- diff --git a/acinclude/os-deps.m4 b/acinclude/os-deps.m4 index a71c8ecb43..dfe1433462 100644 --- a/acinclude/os-deps.m4 +++ b/acinclude/os-deps.m4 @@ -837,3 +837,27 @@ AC_DEFUN([SQUID_CHECK_SETRESUID_WORKS],[ squid_cv_resuid_works="no" ],[:]) ) ]) + +dnl check that we have functional CPU clock access for the profiler +dnl sets squid_cv_profiler_works to "yes" or "no" + +AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[ + AC_CACHE_CHECK([for operational CPU clock access], + squid_cv_cpu_profiler_works, + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ +#if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) ) +// okay +#elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) ) +// okay +#elif defined(__GNUC__) && defined(__alpha) +// okay +#elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */ +// okay +#else +#error This CPU is unsupported. No profiling available here. +#endif + ]])],[ + squid_cv_cpu_profiler_works=yes],[ + squid_cv_cpu_profiler_works=no]) + ) +]) diff --git a/configure.ac b/configure.ac index 5323e3d227..8e903f0385 100644 --- a/configure.ac +++ b/configure.ac @@ -2105,6 +2105,15 @@ AC_ARG_ENABLE(cpu-profiling, SQUID_YESNO([$enableval], [unrecognized argument to --enable-cpu-profiling: $enableval]) ]) +if test "x$enable_cpu_profiling" != "xno"; then + SQUID_CHECK_FUNCTIONAL_CPU_PROFILER + if test "x$enable_cpu_profiling" = "xyes" -a "x$squid_cv_cpu_profiler_works" = "xno"; then + AC_MSG_ERROR([CPU profiling will not be functional in this build.]) + elif test "x$squid_cv_cpu_profiler_works" = "xno"; then + AC_MSG_NOTICE([CPU profiling will not be functional in this build.]) + fi + enable_cpu_profiling="$squid_cv_cpu_profiler_works" +fi SQUID_DEFINE_BOOL(USE_XPROF_STATS,${enable_cpu_profiling:=no}, [Define to enable CPU profiling within Squid]) AM_CONDITIONAL(ENABLE_XPROF_STATS, diff --git a/lib/profiler/get_tick.h b/lib/profiler/get_tick.h index 70f101380a..eea491c990 100644 --- a/lib/profiler/get_tick.h +++ b/lib/profiler/get_tick.h @@ -3,6 +3,10 @@ #if USE_XPROF_STATS +/* + * Ensure that any changes here are synchronised with SQUID_CHECK_FUNCTIONAL_CPU_PROFILER + */ + #if !_SQUID_SOLARIS_ typedef int64_t hrtime_t; #endif @@ -57,9 +61,8 @@ get_tick(void) #else /* This CPU is unsupported. Short-circuit, no profiling here */ -#define get_tick() 0 -#undef USE_XPROF_STATS -#define USE_XPROF_STATS 0 +// #error for configure tests to prevent library construction +#error This CPU is unsupported. No profiling available here. #endif #endif /* USE_XPROF_STATS */ diff --git a/test-suite/buildtests/layer-02-maximus.opts b/test-suite/buildtests/layer-02-maximus.opts index 675b53a453..bc9a7e726d 100644 --- a/test-suite/buildtests/layer-02-maximus.opts +++ b/test-suite/buildtests/layer-02-maximus.opts @@ -39,6 +39,8 @@ MAKETEST="distcheck" # --enable-win32-service \ # --with-valgrind-debug \ # +# --enable-cpu-profiling \ Requires CPU support. +# # # NP: DISTCHECK_CONFIGURE_FLAGS is a magic automake macro for the # distcheck target recursive tests beteen scripted runs. @@ -89,7 +91,6 @@ DISTCHECK_CONFIGURE_FLAGS=" \ --enable-mempools \ --enable-unlinkd \ --enable-stacktraces \ - --enable-cpu-profiling \ --enable-vary \ --enable-x-accelerator-vary \ --enable-ipv6 \