[PATCH] allow the proper C++ linking with -p/-pg
David O'Brien
obrien@FreeBSD.org
Sun Feb 24 03:49:00 GMT 2002
On FreeBSD (and I believe other BSD's); we build profiled versions of
libgcc, libstdc++, and libm. I am able to specify the proper libgcc
using LIBGCC_SPEC ("%{!pg: -lgcc} %{pg: -lgcc_p}"), however there is no
spec that covers libstdc++ nor libm. I don't see any real spec handling
in g++spec.c; so I had to brute force this.
2002-2-23 David O'Brien <obrien@FreeBSD.org>
* g++spec.c (MATH_LIBRARY_PROFILE, LIBSTDCXX_PROFILE): Add.
Use MATH_LIBRARY_PROFILE and LIBSTDCXX_PROFILE if profile flag given.
Index: g++spec.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/g++spec.c,v
retrieving revision 1.25
diff -u -r1.25 g++spec.c
--- g++spec.c 2001/08/08 20:57:38 1.25
+++ g++spec.c 2002/02/24 06:34:18
@@ -32,10 +32,16 @@
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "-lm"
#endif
+#ifndef MATH_LIBRARY_PROFILE
+#define MATH_LIBRARY_PROFILE "-lm"
+#endif
#ifndef LIBSTDCXX
#define LIBSTDCXX "-lstdc++"
#endif
+#ifndef LIBSTDCXX_PROFILE
+#define LIBSTDCXX_PROFILE "-lstdc++"
+#endif
void
lang_specific_driver (in_argc, in_argv, in_added_libraries)
@@ -45,6 +51,9 @@
{
int i, j;
+ /* If non-zero, the user gave us the `-p' or `-pg' flag. */
+ int saw_profile_flag = 0;
+
/* If non-zero, the user gave us the `-v' flag. */
int saw_verbose_flag = 0;
@@ -137,6 +146,8 @@
}
else if (strcmp (argv[i], "-lc") == 0)
args[i] |= WITHLIBC;
+ else if (strcmp (argv[i], "-pg") == 0 || strcmp (argv[i], "-p"))
+ saw_profile_flag++;
else if (strcmp (argv[i], "-v") == 0)
{
saw_verbose_flag = 1;
@@ -259,14 +270,14 @@
/* Add `-lstdc++' if we haven't already done so. */
if (library)
{
- arglist[j++] = LIBSTDCXX;
+ arglist[j++] = saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX;
added_libraries++;
}
if (saw_math)
arglist[j++] = saw_math;
else if (library && need_math)
{
- arglist[j++] = MATH_LIBRARY;
+ arglist[j++] = saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY;
added_libraries++;
}
if (saw_libc)
More information about the Gcc-patches
mailing list