summaryrefslogtreecommitdiffstats
path: root/contrib/gcc
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-06-09 00:03:56 +0000
committerobrien <obrien@FreeBSD.org>2002-06-09 00:03:56 +0000
commit016feefa33ac6baeb05fc237d397ead5ccf65d4a (patch)
tree45bf03ffa70750e38f87f9b248fdd4c6d461223e /contrib/gcc
parentc2750abc35ce901efc9e0b3acd9aa1bc6c0309b0 (diff)
downloadFreeBSD-src-016feefa33ac6baeb05fc237d397ead5ccf65d4a.zip
FreeBSD-src-016feefa33ac6baeb05fc237d397ead5ccf65d4a.tar.gz
Allow one to profile FORTRAN77 programs.
Diffstat (limited to 'contrib/gcc')
-rw-r--r--contrib/gcc/f/g77spec.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/contrib/gcc/f/g77spec.c b/contrib/gcc/f/g77spec.c
index 2e094d9..81725e3 100644
--- a/contrib/gcc/f/g77spec.c
+++ b/contrib/gcc/f/g77spec.c
@@ -18,6 +18,8 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* $FreeBSD$ */
+
/* This file contains a filter for the main `gcc' driver, which is
replicated for the `g77' driver by adding this filter. The purpose
of this filter is to be basically identical to gcc (in that
@@ -52,14 +54,23 @@ Boston, MA 02111-1307, USA. */
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "-lm"
#endif
+#ifndef MATH_LIBRARY_PROFILE
+#define MATH_LIBRARY_PROFILE "-lm"
+#endif
#ifndef FORTRAN_INIT
#define FORTRAN_INIT "-lfrtbegin"
#endif
+#ifndef FORTRAN_INIT_PROFILE
+#define FORTRAN_INIT_PROFILE "-lfrtbegin"
+#endif
#ifndef FORTRAN_LIBRARY
#define FORTRAN_LIBRARY "-lg2c"
#endif
+#ifndef FORTRAN_LIBRARY_PROFILE
+#define FORTRAN_LIBRARY_PROFILE "-lg2c"
+#endif
/* Options this driver needs to recognize, not just know how to
skip over. */
@@ -79,6 +90,7 @@ typedef enum
OPTION_nostdlib, /* Aka --no-standard-libraries, or
-nodefaultlibs. */
OPTION_o, /* Aka --output. */
+ OPTION_p, /* Aka --profile. */
OPTION_S, /* Aka --assemble. */
OPTION_syntax_only, /* -fsyntax-only. */
OPTION_v, /* Aka --verbose. */
@@ -167,6 +179,9 @@ lookup_option (xopt, xskip, xarg, text)
opt = OPTION_L, arg = text + 2;
else if (text[1] == 'o')
opt = OPTION_o;
+ else if ((text[1] == 'p') && (text[2] == '\0')
+ || (text[1] == 'p') && (text[2] == 'g') && (text[3] == '\0'))
+ opt = OPTION_p;
else if ((text[1] == 'S') && (text[2] == '\0'))
opt = OPTION_S, skip = 0;
else if (text[1] == 'V')
@@ -291,6 +306,9 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
/* By default, we throw on the math library if we have one. */
int need_math = (MATH_LIBRARY[0] != '\0');
+ /* If non-zero, the user gave us the `-p' or `-pg' flag. */
+ int saw_profile_flag = 0;
+
/* The number of input and output files in the incoming arg list. */
int n_infiles = 0;
int n_outfiles = 0;
@@ -359,6 +377,11 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries)
++n_outfiles;
break;
+ case OPTION_p:
+ saw_profile_flag = 1;
+ library = FORTRAN_LIBRARY_PROFILE;
+ break;
+
case OPTION_v:
verbose = 1;
break;
@@ -432,7 +455,7 @@ or type the command `info -f g77 Copying'.\n\
/* Not a filename or library. */
if (saw_library == 1 && need_math) /* -l<library>. */
- append_arg (MATH_LIBRARY);
+ append_arg (saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY);
saw_library = 0;
@@ -483,10 +506,12 @@ or type the command `info -f g77 Copying'.\n\
{
if (0 == use_init)
{
- append_arg (FORTRAN_INIT);
+ append_arg (saw_profile_flag ? FORTRAN_INIT_PROFILE
+ : FORTRAN_INIT);
use_init = 1;
}
- append_arg (FORTRAN_LIBRARY);
+ append_arg (saw_profile_flag ? FORTRAN_LIBRARY_PROFILE
+ : FORTRAN_LIBRARY);
}
}
else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
@@ -494,7 +519,8 @@ or type the command `info -f g77 Copying'.\n\
else
{ /* Other library, or filename. */
if (saw_library == 1 && need_math)
- append_arg (MATH_LIBRARY);
+ append_arg (saw_profile_flag ? MATH_LIBRARY_PROFILE
+ : MATH_LIBRARY);
saw_library = 0;
}
}
@@ -513,13 +539,14 @@ or type the command `info -f g77 Copying'.\n\
case 0:
if (0 == use_init)
{
- append_arg (FORTRAN_INIT);
+ append_arg (saw_profile_flag ? FORTRAN_INIT_PROFILE
+ : FORTRAN_INIT);
use_init = 1;
}
append_arg (library);
case 1:
if (need_math)
- append_arg (MATH_LIBRARY);
+ append_arg (saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY);
default:
break;
}
OpenPOWER on IntegriCloud