diff --git a/ghc/lib/std/cbits/getCPUTime.lc b/ghc/lib/std/cbits/getCPUTime.lc
index d3d7b2a4895eb0ddab58aeaca665b5d812db99fb..15488e9bf412bdff2e5256ae16ca9ede4b78bae8 100644
--- a/ghc/lib/std/cbits/getCPUTime.lc
+++ b/ghc/lib/std/cbits/getCPUTime.lc
@@ -71,7 +71,14 @@ getCPUTime(StgByteArray cpuStruct)
 {
     StgInt *cpu=(StgInt *)cpuStruct;
 
-#if defined(HAVE_GETRUSAGE) && ! irix_TARGET_OS
+/* getrusage() is right royal pain to deal with when targetting multiple
+   versions of Solaris, since some versions supply it in libc (2.3 and 2.5),
+   while 2.4 has got it in libucb (I wouldn't be too surprised if it was back
+   again in libucb in 2.6..)
+
+   Avoid the problem by resorting to times() instead.
+*/
+#if defined(HAVE_GETRUSAGE) && ! irix_TARGET_OS && ! solaris2_TARGET_OS
     struct rusage t;
 
     getrusage(RUSAGE_SELF, &t);