diff options
author | obrien <obrien@FreeBSD.org> | 2002-06-09 00:03:56 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-06-09 00:03:56 +0000 |
commit | 016feefa33ac6baeb05fc237d397ead5ccf65d4a (patch) | |
tree | 45bf03ffa70750e38f87f9b248fdd4c6d461223e | |
parent | c2750abc35ce901efc9e0b3acd9aa1bc6c0309b0 (diff) | |
download | FreeBSD-src-016feefa33ac6baeb05fc237d397ead5ccf65d4a.zip FreeBSD-src-016feefa33ac6baeb05fc237d397ead5ccf65d4a.tar.gz |
Allow one to profile FORTRAN77 programs.
-rw-r--r-- | contrib/gcc/f/g77spec.c | 39 | ||||
-rw-r--r-- | gnu/usr.bin/cc/cc_tools/freebsd-native.h | 1 | ||||
-rw-r--r-- | gnu/usr.bin/cc/f77/Makefile | 2 |
3 files changed, 35 insertions, 7 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; } diff --git a/gnu/usr.bin/cc/cc_tools/freebsd-native.h b/gnu/usr.bin/cc/cc_tools/freebsd-native.h index ce6c982..a102a89 100644 --- a/gnu/usr.bin/cc/cc_tools/freebsd-native.h +++ b/gnu/usr.bin/cc/cc_tools/freebsd-native.h @@ -51,6 +51,7 @@ #define LIBGCC_SPEC "%{!pg: -lgcc} %{pg: -lgcc_p}" #define LIBSTDCXX_PROFILE "-lstdc++_p" #define MATH_LIBRARY_PROFILE "-lm_p" +#define FORTRAN_LIBRARY_PROFILE "-lg2c_p" /* FreeBSD is 4.4BSD derived */ #define bsd4_4 diff --git a/gnu/usr.bin/cc/f77/Makefile b/gnu/usr.bin/cc/f77/Makefile index da5e79a..4902ba5 100644 --- a/gnu/usr.bin/cc/f77/Makefile +++ b/gnu/usr.bin/cc/f77/Makefile @@ -10,7 +10,7 @@ SRCS= gcc.c g77spec.c version.c CFLAGS+= -DDEFAULT_TARGET_VERSION=\"$(version)\" CFLAGS+= -DDEFAULT_TARGET_MACHINE=\"$(target)\" -CFLAGS+= -DFORTRAN_INIT=\"-lg2c\" +CFLAGS+= -DFORTRAN_INIT=\"-lg2c\" -DFORTRAN_INIT_PROFILE=\"-lg2c_p\" DPADD= ${LIBCC_INT} LDADD= ${LIBCC_INT} |