]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Build libprofiler only when it will be operational
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Dec 2010 14:29:27 +0000 (03:29 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Dec 2010 14:29:27 +0000 (03:29 +1300)
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.

acinclude/os-deps.m4
configure.ac
lib/profiler/get_tick.h
test-suite/buildtests/layer-02-maximus.opts

index a71c8ecb43ce8ab71b30f149bad0d6856bb60bbe..dfe1433462dc3837f2568c75ceec99738521a987 100644 (file)
@@ -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])
+  )
+])
index 5323e3d227b90a52f19bee6677ef81c3bc72d1b2..8e903f0385c242760b939b29a3fdd39b685662aa 100644 (file)
@@ -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,
index 70f101380adefebbc0c4aa1d468f37ef5adc52bc..eea491c99040cd1699c95cec9a8ed3358b0c05d0 100644 (file)
@@ -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 */
index 675b53a4539c5250c3f445d950914ab85c19c0da..bc9a7e726d53a51e9001f6515341f5864e7cecd9 100644 (file)
@@ -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 \