This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix C++ -mmacosx-version-min inconsistency, objective-C++
- From: gkeating at apple dot com (Geoffrey Keating)
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Mar 2007 11:54:09 -0800 (PST)
- Subject: fix C++ -mmacosx-version-min inconsistency, objective-C++
This patch does two things:
- It makes the 'c++' driver add -lstdc++, etc., when compiling
objective-C++ as well as regular C++.
- There was an early exit if 'nothing was to be done', but it wasn't
taking into account the possibility of needing to add
-shared-libgcc. If you do take that into account it becomes an
early exit that's almost never taken, so I removed it.
The testcase does test the specific bug, but it'd be nice if there was
a way to more generally test option combinations involving -x.
Unfortunately dg-options adds the options after the source file, not
before it...
Bootstrapped & tested on powerpc-darwin9.
--
- Geoffrey Keating <geoffk@apple.com>
===File ~/patches/gcc-cp-5027856.patch======================
Index: gcc/cp/ChangeLog
2007-03-02 Geoffrey Keating <geoffk@apple.com>
* g++spec.c (lang_specific_driver): Add -lstdc++ when compiling
Objective-C++. Don't exit early if -shared-libgcc needs to be
added.
Index: gcc/testsuite/ChangeLog
2007-03-02 Geoffrey Keating <geoffk@apple.com>
* g++.dg/other/darwin-minversion-1.C: New.
Index: gcc/testsuite/g++.dg/other/darwin-minversion-1.C
===================================================================
--- gcc/testsuite/g++.dg/other/darwin-minversion-1.C (revision 0)
+++ gcc/testsuite/g++.dg/other/darwin-minversion-1.C (revision 0)
@@ -0,0 +1,10 @@
+/* Test for -mmacosx-version-min default on powerpc-darwin. */
+/* { dg-do compile { target powerpc-*-darwin* } } */
+
+int main(void)
+{
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1030
+ fail me;
+#endif
+ return 0;
+}
Index: gcc/cp/g++spec.c
===================================================================
--- gcc/cp/g++spec.c (revision 122345)
+++ gcc/cp/g++spec.c (working copy)
@@ -159,11 +159,19 @@
arg = "";
if (library == 0
&& (strcmp (arg, "c++") == 0
- || strcmp (arg, "c++-cpp-output") == 0))
+ || strcmp (arg, "c++-cpp-output") == 0
+ || strcmp (arg, "objective-c++") == 0
+ || strcmp (arg, "objective-c++-cpp-output") == 0))
library = 1;
saw_speclang = 1;
}
+ else if (strcmp (argv[i], "-ObjC++") == 0)
+ {
+ if (library == 0)
+ library = 1;
+ 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)
@@ -237,13 +245,6 @@
if (quote)
fatal ("argument to '%s' missing\n", quote);
- /* If we know we don't have to do anything, bail now. */
- if (! added && library <= 0)
- {
- free (args);
- return;
- }
-
/* There's no point adding -shared-libgcc if we don't have a shared
libgcc. */
#ifndef ENABLE_SHARED_LIBGCC
============================================================