/* Specific flags and argument handling of the C++ front-end.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GCC.
#define MATH_LIBRARY "-lm"
#endif
#ifndef MATH_LIBRARY_PROFILE
-#define MATH_LIBRARY_PROFILE "-lm"
+#define MATH_LIBRARY_PROFILE MATH_LIBRARY
#endif
#ifndef LIBSTDCXX
#define LIBSTDCXX "-lstdc++"
#endif
#ifndef LIBSTDCXX_PROFILE
-#define LIBSTDCXX_PROFILE "-lstdc++"
+#define LIBSTDCXX_PROFILE LIBSTDCXX
#endif
void
argv = *in_argv;
added_libraries = *in_added_libraries;
- args = (int *) xcalloc (argc, sizeof (int));
+ args = xcalloc (argc, sizeof (int));
for (i = 1; i < argc; i++)
{
{
library = -1;
}
- else if (strcmp (argv[i], "-lm") == 0
- || strcmp (argv[i], "-lmath") == 0
- || strcmp (argv[i], MATH_LIBRARY) == 0
- )
+ else if (strcmp (argv[i], MATH_LIBRARY) == 0)
{
args[i] |= MATHLIB;
need_math = 0;
}
saw_speclang = 1;
}
+ /* Arguments that go directly to the linker might be .o files,
+ or something, and so might cause libstdc++ to be needed. */
+ else if (strcmp (argv[i], "-Xlinker") == 0)
+ {
+ quote = argv[i];
+ if (library == 0)
+ library = 1;
+ }
+ else if (strncmp (argv[i], "-Wl,", 4) == 0)
+ library = (library == 0) ? 1 : library;
+ /* Unrecognized libraries (e.g. -lfoo) may require libstdc++. */
+ else if (strncmp (argv[i], "-l", 2) == 0)
+ library = (library == 0) ? 1 : library;
else if (((argv[i][2] == '\0'
- && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
- || strcmp (argv[i], "-Xlinker") == 0
+ && strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
|| strcmp (argv[i], "-Tdata") == 0))
quote = argv[i];
else if ((argv[i][2] == '\0'
- && (char *) strchr ("cSEM", argv[i][1]) != NULL)
+ && strchr ("cSEM", argv[i][1]) != NULL)
|| strcmp (argv[i], "-MM") == 0
|| strcmp (argv[i], "-fsyntax-only") == 0)
{
}
if (quote)
- fatal ("argument to `%s' missing\n", quote);
+ fatal ("argument to '%s' missing\n", quote);
/* If we know we don't have to do anything, bail now. */
if (! added && library <= 0)
/* Make sure to have room for the trailing NULL argument. */
num_args = argc + added + need_math + shared_libgcc + (library > 0) + 1;
- arglist = (const char **) xmalloc (num_args * sizeof (char *));
+ arglist = xmalloc (num_args * sizeof (char *));
i = 0;
j = 0;
arglist[j++] = "-xc++-header";
break;
default:
- abort ();
+ gcc_unreachable ();
}
arglist[j++] = argv[i];
arglist[j] = "-xnone";
/* Add `-lstdc++' if we haven't already done so. */
if (library > 0)
{
- arglist[j++] = saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX;
- added_libraries++;
-#ifdef USE_LIBUNWIND_EXCEPTIONS
-# ifndef LIBUNWIND
-# define LIBUNWIND "-lunwind"
-# endif
- arglist[j++] = LIBUNWIND;
- added_libraries++;
-#endif
+ arglist[j] = saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX;
+ if (arglist[j][0] != '-' || arglist[j][1] == 'l')
+ added_libraries++;
+ j++;
}
if (saw_math)
arglist[j++] = saw_math;
else if (library > 0 && need_math)
{
- arglist[j++] = saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY;
- added_libraries++;
+ arglist[j] = saw_profile_flag ? MATH_LIBRARY_PROFILE : MATH_LIBRARY;
+ if (arglist[j][0] != '-' || arglist[j][1] == 'l')
+ added_libraries++;
+ j++;
}
if (saw_libc)
arglist[j++] = saw_libc;
}
/* Called before linking. Returns 0 on success and -1 on failure. */
-int lang_specific_pre_link () /* Not used for C++. */
+int lang_specific_pre_link (void) /* Not used for C++. */
{
return 0;
}