This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH, v3] Potential solution to librt issue.
Paolo, can you help us (Chris) with the "automagic" thing?
I did something in the attached patch (not even compiled) but I'm not
sure it's the right approach at all. The idea is to allow inserting
language-specific stuff in the config/*.h files.
Note that it's the first time I touch specs, and I'm not sure if this
actually could work for the -static case.
Paolo
Index: gcc.c
===================================================================
--- gcc.c (revision 134435)
+++ gcc.c (working copy)
@@ -361,6 +361,7 @@ static const char *convert_filename (con
static const char *getenv_spec_function (int, const char **);
static const char *if_exists_spec_function (int, const char **);
static const char *if_exists_else_spec_function (int, const char **);
+static const char *if_language_spec_function (int, const char **);
static const char *replace_outfile_spec_function (int, const char **);
static const char *version_compare_spec_function (int, const char **);
static const char *include_spec_function (int, const char **);
@@ -1634,6 +1635,7 @@ static const struct spec_function static
{ "getenv", getenv_spec_function },
{ "if-exists", if_exists_spec_function },
{ "if-exists-else", if_exists_else_spec_function },
+ { "if-language", if_language_spec_function },
{ "replace-outfile", replace_outfile_spec_function },
{ "version-compare", version_compare_spec_function },
{ "include", include_spec_function },
@@ -7800,6 +7802,24 @@ if_exists_else_spec_function (int argc,
return argv[1];
}
+/* if-language built-in spec function.
+
+ Expands to the second argument if the current driver is the
+ string in the first argument. */
+
+static const char *
+if_language_spec_function (int argc, const char **argv)
+{
+ /* Must have exactly two arguments. */
+ if (argc != 2)
+ return NULL;
+
+ if (!strcmp (lang_driver_name, argv[0]))
+ return argv[1];
+
+ return NULL;
+}
+
/* replace-outfile built-in spec function.
This looks for the first argument in the outfiles array's name and
Index: gcc.h
===================================================================
--- gcc.h (revision 134435)
+++ gcc.h (working copy)
@@ -74,6 +74,9 @@ extern int n_infiles;
/* Number of extra output files that lang_specific_pre_link may generate. */
extern int lang_specific_extra_outfiles;
+/* Driver name for the if-language function. */
+extern const char *lang_driver_name;
+
/* A vector of corresponding output files is made up later. */
extern const char **outfiles;
Index: cppspec.c
===================================================================
--- cppspec.c (revision 134435)
+++ cppspec.c (working copy)
@@ -208,3 +208,6 @@ int lang_specific_pre_link (void)
/* Number of extra output files that lang_specific_pre_link may generate. */
int lang_specific_extra_outfiles = 0; /* Not used for cpp. */
+
+/* Driver name. */
+const char *lang_driver_name = "cpp";
Index: gccspec.c
===================================================================
--- gccspec.c (revision 134435)
+++ gccspec.c (working copy)
@@ -104,3 +104,6 @@ lang_specific_pre_link (void)
/* Number of extra output files that lang_specific_pre_link may generate. */
int lang_specific_extra_outfiles = 0; /* Not used for C. */
+
+/* Driver name. */
+const char *lang_driver_name = "gcc";
Index: cp/g++spec.c
===================================================================
--- cp/g++spec.c (revision 134435)
+++ cp/g++spec.c (working copy)
@@ -349,3 +349,6 @@ int lang_specific_pre_link (void) /* No
/* Number of extra output files that lang_specific_pre_link may generate. */
int lang_specific_extra_outfiles = 0; /* Not used for C++. */
+
+/* Driver name. */
+const char *lang_driver_name = "g++";
Index: fortran/gfortranspec.c
===================================================================
--- fortran/gfortranspec.c (revision 134435)
+++ fortran/gfortranspec.c (working copy)
@@ -584,3 +584,6 @@ lang_specific_pre_link (void) /* Not use
/* Number of extra output files that lang_specific_pre_link may generate. */
int lang_specific_extra_outfiles = 0; /* Not used for F77. */
+
+/* Driver name. */
+const char *lang_driver_name = "gfortran";
Index: java/jvspec.c
===================================================================
--- java/jvspec.c (revision 134435)
+++ java/jvspec.c (working copy)
@@ -685,3 +685,6 @@ lang_specific_pre_link (void)
}
return err;
}
+
+/* Driver name. */
+const char *lang_driver_name = "gcj";
Index: config/linux.h
===================================================================
--- config/linux.h (revision 134435)
+++ config/linux.h (working copy)
@@ -67,12 +67,25 @@ along with GCC; see the file COPYING3.
#undef CPLUSPLUS_CPP_SPEC
#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
-#undef LIB_SPEC
-#define LIB_SPEC \
+#undef BASE_LIB_SPEC
+#define BASE_LIB_SPEC \
"%{pthread:-lpthread} \
%{shared:-lc} \
%{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
+#ifndef HAVE_LD_AS_NEEDED
+#define BASE_LIB_SPEC LIB_SPEC
+#define BASE_LIB_SPEC LIB_SPEC " \
+ %{!nostdlib:%{!nodefaultlibs:%:if-language(g++, -lrt )}}"
+
+#else
+#define BASE_LIB_SPEC LIB_SPEC " \
+ %{!nostdlib:%{!nodefaultlibs:%:if-language(g++, --as-needed -lrt --no-as-needed )}}"
+
+/* Use --as-needed -lgcc_s for eh support. */
+#define USE_LD_AS_NEEDED 1
+#else
+
#define LINUX_TARGET_OS_CPP_BUILTINS() \
do { \
builtin_define ("__gnu_linux__"); \
@@ -94,11 +107,6 @@ along with GCC; see the file COPYING3.
#define LINK_GCC_C_SEQUENCE_SPEC \
"%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
-/* Use --as-needed -lgcc_s for eh support. */
-#ifdef HAVE_LD_AS_NEEDED
-#define USE_LD_AS_NEEDED 1
-#endif
-
/* Determine which dynamic linker to use depending on whether GLIBC or
uClibc is the default C library and whether -muclibc or -mglibc has
been passed to change the default. */
- References:
- [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.
- Re: [PATCH, v3] Potential solution to librt issue.