This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, driver] PR41594 recognize -static-libstdc++ as a valid option.
IainS wrote:
>
> On 5 Oct 2009, at 21:06, Dave Korn wrote:
>
>> IainS wrote:
>>> The driver currently rejects -static-libstdc++ although it is processed
>>> by g++spec.c
>>
>> Do you perhaps mean when invoked as 'gcc' rather than as 'g++'?
>
> yes, which causes a couple of fails if one tries to run the testsuite
> with /-static-libstdc++
If I understand your patch correctly, it will cause gcc to accept but ignore
the option, yes? Out of curiosity, here's part of a patch I submitted earlier
to much the same end. It has the minor additional feature that even when
using g++, you can test for -static-libstdc++ in specs (normally g++spec.c
cuts it out), and apart from that it uses a spec to allow-and-ignore the
option in the same way as -static. Can you see any practical differences
between the two approaches (i.e. ignoring it in a spec, vs. extending the
if-test that sets the validated flag)?
cheers,
DaveK
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c (revision 152230)
+++ gcc/gcc.c (working copy)
@@ -760,7 +760,10 @@ proper position among the other output files. */
/* -u* was put back because both BSD and SysV seem to support it. */
/* %{static:} simply prevents an error message if the target machine
- doesn't handle -static. */
+ doesn't handle -static; %{static-libstdc++} is not handled by any
+ target machine but entirely in cp/g++spec.c, yet we cannot just
+ remove it from the command-line there or it cannot be tested in
+ spec processing, so we simply ignore it here similarly. */
/* We want %{T*} after %{L*} and %D so that it can be used to specify linker
scripts which exist in user specified directories, or in standard
directories. */
@@ -769,7 +772,7 @@ proper position among the other output files. */
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
- %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
+ %{static:} %{static-libstdc++:} %{L*} %(mfwrap) %(link_libgcc) %o\
%{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
%{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
%{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
Index: gcc/cp/g++spec.c
===================================================================
--- gcc/cp/g++spec.c (revision 152230)
+++ gcc/cp/g++spec.c (working copy)
@@ -30,8 +30,6 @@ along with GCC; see the file COPYING3. If not see
#define MATHLIB (1<<2)
/* This bit is set if they did `-lc'. */
#define WITHLIBC (1<<3)
-/* Skip this option. */
-#define SKIPOPT (1<<4)
#ifndef MATH_LIBRARY
#define MATH_LIBRARY "-lm"
@@ -211,10 +209,7 @@ lang_specific_driver (int *in_argc, const char *co
else if (strcmp (argv[i], "-static-libgcc") == 0)
shared_libgcc = 0;
else if (strcmp (argv[i], "-static-libstdc++") == 0)
- {
library = library >= 0 ? 2 : library;
- args[i] |= SKIPOPT;
- }
else if (DEFAULT_WORD_SWITCH_TAKES_ARG (&argv[i][1]))
i++;
else
@@ -324,9 +319,6 @@ lang_specific_driver (int *in_argc, const char *co
arglist[j] = "-xnone";
}
- if ((args[i] & SKIPOPT) != 0)
- --j;
-
i++;
j++;
}