# 2013-07-17 Stefan Teleman <stefan.teleman@oracle.com>
# 1. GCC did not pass the correct values-xpg?.c/values-X?.c when
# linking - based on language standard binding (-std=<xxx>.
#
# 2. C99 is not legal in C++98/C++03, but it is legal in C++11.
# We expose some of the C99 interfaces via different macros, such as
# _XPG5/_XOPEN_SOURCE=500 for C++98/C++03
#
# 3. Do not pass /usr/ccs/lib at link time (this directory is empty
# in S11 and S12
--- gcc-4.8.2/gcc/config/sol2.h	2013-01-10 12:38:27.000000000 -0800
+++ gcc-4.8.2/gcc/config/sol2.h	2013-10-17 11:15:49.102855258 -0700
@@ -89,8 +89,16 @@
 	   library.  */					\
 	if (c_dialect_cxx ())				\
 	  {						\
+	    if ((cxx_dialect == cxx98) || (cxx_dialect == cxx03)) \
+            {                                           \
+	      builtin_define ("__STDC_VERSION__=199409L"); \
+	      builtin_define ("_XOPEN_SOURCE=500");	\
+            }                                           \
+            else                                        \
+            {                                           \
 	    builtin_define ("__STDC_VERSION__=199901L");\
 	    builtin_define ("_XOPEN_SOURCE=600");	\
+            }                                           \
 	    builtin_define ("_LARGEFILE_SOURCE=1");	\
 	    builtin_define ("_LARGEFILE64_SOURCE=1");	\
 	    builtin_define ("__EXTENSIONS__");		\
@@ -127,8 +135,58 @@
 #endif
 
 #undef STARTFILE_ARCH32_SPEC
-#define STARTFILE_ARCH32_SPEC "%{ansi:values-Xc.o%s} \
-			    %{!ansi:values-Xa.o%s}"
+#define STARTFILE_ARCH32_SPEC "%{std=c++0x:values-Xc.o%s} \
+                               %{std=c++0x:values-xpg6.o%s} \
+                               %{std=c++11:values-Xc.o%s} \
+                               %{std=c++11:values-xpg6.o%s} \
+                               %{std=c11:values-Xc.o%s} \
+                               %{std=c11:values-xpg6.o%s} \
+                               %{std=c1x:values-Xc.o%s} \
+                               %{std=c1x:values-xpg6.o%s} \
+                               %{std=c99:values-Xc.o%s} \
+                               %{std=c99:values-xpg6.o%s} \
+                               %{std=c9x:values-Xc.o%s} \
+                               %{std=c9x:values-xpg6.o%s} \
+                               %{std=gnu++0x:values-Xc.o%s} \
+                               %{std=gnu++0x:values-xpg6.o%s} \
+                               %{std=gnu++11:values-Xc.o%s} \
+                               %{std=gnu++11:values-xpg6.o%s} \
+                               %{std=gnu11:values-Xc.o%s} \
+                               %{std=gnu11:values-xpg6.o%s} \
+                               %{std=gnu1x:values-Xc.o%s} \
+                               %{std=gnu1x:values-xpg6.o%s} \
+                               %{std=gnu99:values-Xc.o%s} \
+                               %{std=gnu99:values-xpg6.o%s} \
+                               %{std=gnu9x:values-Xc.o%s} \
+                               %{std=gnu9x:values-xpg6.o%s} \
+                               %{std=f2003:values-Xc.o%s} \
+                               %{std=f2003:values-xpg6.o%s} \
+                               %{std=f2008:values-Xc.o%s} \
+                               %{std=f2008:values-xpg6.o%s} \
+                               %{std=f2008ts:values-Xc.o%s} \
+                               %{std=f2008ts:values-xpg6.o%s} \
+                               %{std=f95:values-Xa.o%s} \
+                               %{std=f95:values-xpg4.o%s} \
+                               %{std=gnu:values-Xa.o%s} \
+                               %{std=gnu:values-xpg4.o%s} \
+                               %{std=legacy:values-Xa.o%s} \
+                               %{std=legacy:values-xpg4.o%s} \
+                               %{std=c++03:values-Xa.o%s} \
+                               %{std=c++03:values-xpg4.o%s} \
+                               %{std=c++98:values-Xa.o%s} \
+                               %{std=c++98:values-xpg4.o%s} \
+                               %{std=c89:values-Xa.o%s} \
+                               %{std=c89:values-xpg4.o%s} \
+                               %{std=c90:values-Xa.o%s} \
+                               %{std=c90:values-xpg4.o%s} \
+                               %{std=gnu++03:values-Xa.o%s} \
+                               %{std=gnu++03:values-xpg4.o%s} \
+                               %{std=gnu++98:values-Xa.o%s} \
+                               %{std=gnu++98:values-xpg4.o%s} \
+                               %{std=gnu89:values-Xa.o%s} \
+                               %{std=gnu89:values-xpg4.o%s} \
+                               %{std=gnu90:values-Xa.o%s} \
+                               %{std=gnu90:values-xpg4.o%s}"
 
 #undef STARTFILE_ARCH_SPEC
 #define STARTFILE_ARCH_SPEC STARTFILE_ARCH32_SPEC
@@ -154,8 +212,8 @@
   "%{G:-G} \
    %{YP,*} \
    %{R*} \
-   %{!YP,*:%{p|pg:-Y P,%R/usr/ccs/lib/libp:%R/usr/lib/libp:%R/usr/ccs/lib:%R/lib:%R/usr/lib} \
-	   %{!p:%{!pg:-Y P,%R/usr/ccs/lib:%R/lib:%R/usr/lib}}}"
+   %{!YP,*:%{p|pg:-Y P,%R/usr/lib/libp:%R/lib:%R/usr/lib} \
+	   %{!p:%{!pg:-Y P,%R/lib:%R/usr/lib}}}"
 
 #undef LINK_ARCH32_SPEC
 #define LINK_ARCH32_SPEC LINK_ARCH32_SPEC_BASE
