# Return true if profiling is supported on the target.
-proc check_profiling_available { } {
+proc check_profiling_available { test_what } {
global profiling_available_saved
+ verbose "Profiling argument is <$test_what>" 1
+
+ # These conditions depend on the argument so examine them before
+ # looking at the cache variable.
+
+ # Support for -p on solaris2 relies on mcrt1.o which comes with the
+ # vendor compiler. We cannot reliably predict the directory where the
+ # vendor compiler (and thus mcrt1.o) is installed so we can't
+ # necessarily find mcrt1.o even if we have it.
+ if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
+ return 0
+ }
+
+ # Support for -p on irix relies on libprof1.a which doesn't appear to
+ # exist on any irix6 system currently posting testsuite results.
+ # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
+ # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
+ if { [istarget mips*-*-irix*]
+ && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
+ return 0
+ }
+
+ # Now examine the cache variable.
if {![info exists profiling_available_saved]} {
# Some targets don't have any implementation of __bb_init_func or are
# missing other needed machinery.