changeset 13726:056b82d21d71

1450 Illumos should be buildable with GCC4 Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com> Reviewed by: Gordon Ross <gwr@nexenta.com> Reviewed by: Albert Lee <trisk@nexenta.com> Approved by: Gordon Ross <gwr@nexenta.com>
author Richard Lowe <richlowe@richlowe.net>
date Sat, 14 Apr 2012 20:29:22 -0400
parents 9a3ca91fb74e
children 826d789b2aae
files exception_lists/check_rtime usr/src/Makefile.master usr/src/Makefile.master.64 usr/src/cmd/krb5/krb5kdc/Makefile usr/src/cmd/lms/Makefile usr/src/cmd/lp/Makefile.lp usr/src/cmd/vi/port/ex_cmdsub.c usr/src/grub/grub-0.97/Makefile.solaris.defs usr/src/head/iso/setjmp_iso.h usr/src/head/setjmp.h usr/src/head/ucontext.h usr/src/head/unistd.h usr/src/lib/libc/Makefile usr/src/lib/libc/inc/base_inlines.h usr/src/lib/libc/inc/thr_inlines.h usr/src/lib/libc/port/unwind/unwind.c usr/src/lib/libc/sparc/Makefile.com usr/src/lib/libc/sparc/crt/_rtboot.s usr/src/lib/libc/sparc/crt/_rtld.c usr/src/lib/libc/sparcv9/Makefile.com usr/src/lib/scsi/libses/Makefile.defs usr/src/lib/scsi/libsmp/Makefile.com usr/src/lib/sun_fc/Makefile.com usr/src/lib/sun_fc/amd64/Makefile usr/src/lib/sun_fc/sparcv9/Makefile usr/src/psm/stand/bootblks/ufs/i386/Makefile usr/src/tools/cw/Makefile usr/src/tools/cw/cw.1 usr/src/tools/cw/cw.c usr/src/ucbhead/setjmp.h usr/src/uts/Makefile.uts usr/src/uts/common/sys/ccompile.h usr/src/uts/common/sys/fork.h usr/src/uts/common/sys/ontrap.h usr/src/uts/common/sys/systm.h usr/src/uts/i86pc/Makefile.rules usr/src/uts/i86xpv/Makefile.rules usr/src/uts/sparc/Makefile.sparc.shared usr/src/uts/sun4u/Makefile.sun4u.shared usr/src/uts/sun4v/Makefile.sun4v.shared
diffstat 40 files changed, 318 insertions(+), 265 deletions(-) [+]
line wrap: on
line diff
--- a/exception_lists/check_rtime	Thu Jun 14 08:00:26 2012 -0700
+++ b/exception_lists/check_rtime	Sat Apr 14 20:29:22 2012 -0400
@@ -163,6 +163,7 @@
 UNREF_OBJ	/lib.*\ of\ .*libxslt\.so\.1
 UNREF_OBJ	/lib.*\ of\ .*libpq\.so\.4
 UNREF_OBJ	/lib.*\ of\ .*libpython2\.4\.so\.1\.0
+UNREF_OBJ	/libgcc_s.*\ of\ .*libstdc\+\+\.so\.6
 
 # Unreferenced object of objects we can't change for other reasons
 UNREF_OBJ	/libmapmalloc\.so\.1;\ unused\ dependency\ of	# interposer
@@ -171,6 +172,10 @@
 UNREF_OBJ	/lib.*\ of\ .*/lib/picl/plugins/		# picl
 UNREF_OBJ	/lib.*\ of\ .*kcfd				# interposer
 UNREF_OBJ	/libpkcs11\.so\.1; .*\ of\ .*libkmf\.so\.1	# interposed
+# Referenced by the Studio build, not the GCC build.  GCC eliminates the unused
+# statics which have the dependence.
+UNREF_OBJ	/libc\.so\.1.*\ of\ .*kldap\.so\.1
+
 
 # Objects that used to contain system functionalty that has since
 # migrated to libc. We preserve these libraries as pure filters for
--- a/usr/src/Makefile.master	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/Makefile.master	Sat Apr 14 20:29:22 2012 -0400
@@ -101,19 +101,36 @@
 $(TONICBUILD)CLOSEDROOT= $(ROOT)-closed
 
 
-# set __GNUC= in the environment to build 32-bit with the gcc compiler.
-# The default is to use the Sun Studio compiler for all processor types.
-__GNUC=		$(POUND_SIGN)
+# The variables below control the compilers used during the build.
+# There are a number of permutations.
+#
+# __GNUC and __SUNC control (and indicate) the primary compiler.  Whichever
+# one is not POUND_SIGN is the primary, with the other as the shadow.  They
+# may also be used to control entirely compiler-specific Makefile assignments.
+# __SUNC and Sun Studio are the default.
+#
+# __GNUC64 indicates that the 64bit build should use the GNU C compiler.
+# There is no Sun C analogue.
+#
+# The following version-specific options are operative regardless of which
+# compiler is primary, and control the versions of the given compilers to be
+# used.  They also allow compiler-version specific Makefile fragments.
+#
+# __SSNEXT when set to the empty string enables options specific to the 'next'
+# version of the Sun Studio compiler.
+#
+# __GNUC3 when the empty string uses and refers to GCC 3.x, it is the default.
+# __GNUC4 when the empty string uses and refers to GCC 4.x.
 
-# set __GNUC64= in the environment to build 64-bit with the gcc compiler.
-# Inherit the __GNUC value by default, and if that is set to $(POUND_SIGN)
-# then this means use the Sun Studio compiler.
-__GNUC64=	$(__GNUC)
+__GNUC=			$(POUND_SIGN)
+$(__GNUC)__SUNC=	$(POUND_SIGN)
+__GNUC64=		$(__GNUC)
 
-# set __SSNEXT= in the enviroment to build with the 'next' release of
-# the Sun Studio compiler. This will cause command line options specific
-# to the 'next' version of the Sun Studio compiler to be used.
-__SSNEXT=	$(POUND_SIGN)
+__SSNEXT=		$(POUND_SIGN)
+
+__GNUC3=
+__GNUC4=		$(POUND_SIGN)
+$(__GNUC4)__GNUC3=	$(POUND_SIGN)
 
 # CLOSED is the root of the tree that contains source which isn't released
 # as open source
@@ -132,6 +149,11 @@
 SFWLIBDIR=	$(SFW_ROOT)/lib
 SFWLIBDIR64=	$(SFW_ROOT)/lib/$(MACH64)
 
+$(__GNUC3)GCC_ROOT=	$(SFW_ROOT)
+$(__GNUC4)GCC_ROOT=	/opt/gcc/4.4.4
+GCCLIBDIR=	$(GCC_ROOT)/lib
+GCCLIBDIR64=	$(GCC_ROOT)/lib/$(MACH64)
+
 RPCGEN=		/usr/bin/rpcgen
 STABS=		$(ONBLD_TOOLS)/bin/$(MACH)/stabs
 ELFEXTRACT=	$(ONBLD_TOOLS)/bin/$(MACH)/elfextract
@@ -314,6 +336,15 @@
 #
 # generate 32-bit addresses in the v9 kernel. Saves memory.
 CCABS32=		-Wc,-xcode=abs32
+#
+# generate v9 code which tolerates callers using the v7 ABI, for the sake of
+# system calls.
+$(__GNUC4)CC32BITCALLERS=		-_gcc=-massume-32bit-callers
+
+# GCC, especially, is increasingly beginning to auto-inline functions and
+# sadly does so separately not under the general -fno-inline-functions
+$(__GNUC4)CCNOAUTOINLINE= -_gcc=-fno-inline-small-functions \
+	-_gcc=-fno-inline-functions-called-once
 
 # One optimization the compiler might perform is to turn this:
 #	#pragma weak foo
@@ -377,6 +408,10 @@
 CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
 CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
 
+# Normally cw(1) would translate -v into a set of options including these
+# but as they're GCC 4.x specific, we can't do that
+$(__GNUC4)CERRWARN +=	-_gcc=-Wno-address -_gcc=-Wno-array-bounds
+
 #
 # turn warnings into errors (C++)
 CCERRWARN=		-xwe
@@ -421,10 +456,6 @@
 # In the same spirit, this will also remove the date from the N_OPT stab.
 CGLOBALSTATIC= -W0,-xglobalstatic
 
-# Normally, gcc uses indirect DWARF strings to save space.  However,
-# this causes relocations that ctfconvert cannot handle.  Disable this.
-CDWARFSTR=	-_gcc=-fno-dwarf2-indirect-strings
-
 # Sometimes we want all symbols and types in debugging information even
 # if they aren't used.
 CALLSYMS=	-W0,-xdbggen=no%usedonly
@@ -490,17 +521,17 @@
 
 CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG) \
-		$(CGLOBALSTATIC)
+		$(CGLOBALSTATIC) $(CCNOAUTOINLINE)
 CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG64) \
-		$(CGLOBALSTATIC)
+		$(CGLOBALSTATIC) $(CCNOAUTOINLINE)
 #
 # Flags that are used to build parts of the code that are subsequently
 # run on the build machine (also known as the NATIVE_BUILD).
 #
 NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $($(NATIVE_MACH)_CCUNBOUND) \
-		$(IROPTFLAG) $(CGLOBALSTATIC)
+		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE)
 
 DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
 DTS_ERRNO=-D_TS_ERRNO
@@ -639,7 +670,9 @@
 # Link time macros
 #
 CCNEEDED		= -lC
-$(__GNUC)CCNEEDED	= -L$(SFWLIBDIR) -R$(SFWLIBDIR) -lstdc++ -lgcc_s
+CCEXTNEEDED		= -lCrun -lCstd
+$(__GNUC)CCNEEDED	= -L$(GCCLIBDIR) -R$(GCCLIBDIR) -lstdc++ -lgcc_s
+$(__GNUC)CCEXTNEEDED	= $(CCNEEDED)
 
 LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
 LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
@@ -729,7 +762,6 @@
 sparcv9_LD=		/usr/ccs/bin/ld
 sparcv9_LINT=		$(SPRO_ROOT)/sunstudio12.1/bin/lint
 
-# We compile 32-bit objects with cc by default
 i386_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
 $(__GNUC)i386_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
 i386_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
@@ -740,7 +772,6 @@
 i386_LD=		/usr/ccs/bin/ld
 i386_LINT=		$(SPRO_ROOT)/sunstudio12.1/bin/lint
 
-# We compile 64-bit objects with gcc
 amd64_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
 $(__GNUC64)amd64_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
 amd64_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
--- a/usr/src/Makefile.master.64	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/Makefile.master.64	Sat Apr 14 20:29:22 2012 -0400
@@ -54,9 +54,10 @@
 LDLIBS.lib =	$(LDLIBS64)
 
 #
-# Override Makefile.master's settings of SFWLIBDIR
+# Override Makefile.master's settings of SFWLIBDIR and GCCLIBDIR
 #
 SFWLIBDIR=	$(SFWLIBDIR64)
+GCCLIBDIR=	$(GCCLIBDIR64)
 
 #
 # Override Makefile.master's settings of CC, CCC, AS and LINT
@@ -80,8 +81,9 @@
 MAPFILECLASS=	-64
 
 CCNEEDED =		-lCrun
-$(__GNUC64)CCNEEDED =	-L$(SFWLIBDIR) -R$(SFWLIBDIR) -lstdc++	\
-			-lgcc_s_$(MACH64)
+$(__GNUC64)CCNEEDED =	-L$(GCCLIBDIR) -R$(GCCLIBDIR) -lstdc++
+$(__GNUC64)$(__GNUC3)CCNEEDED +=	-lgcc_s_$(MACH64)
+$(__GNUC64)$(__GNUC4)CCNEEDED +=	-lgcc_s
 
 BUILDCCC.SO=    $(CCC) $(CCFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
 		$(PICS) $(EXTPICS) $(LDLIBS) $(CCNEEDED)
--- a/usr/src/cmd/krb5/krb5kdc/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/cmd/krb5/krb5kdc/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -2,8 +2,6 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 PROG= krb5kdc
 MANIFEST=	krb5kdc.xml
@@ -42,6 +40,9 @@
 ROOTMANIFESTDIR=	$(ROOTSVCNETWORKSECURITY)
 
 CFLAGS += $(CCOPTS) $(DEFS) $(LOCALINCLUDE)
+# The SET macros in network.c will be mis-optimized if GCC believes it
+# may rely on undefined signed overflow behaviour.
+$(__GNUC4)CFLAGS += -_gcc=-fno-strict-overflow
 
 CPPFLAGS += \
 	-I$(SRC)/lib/gss_mechs/mech_krb5/include \
--- a/usr/src/cmd/lms/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/cmd/lms/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -50,8 +50,7 @@
 CPPFLAGS=	-DBSD_COMP -D_REMOTE_SUPPORT \
 		-I. -I$(SYNCLIB_HDRDIR) -I$(HECI_DIR) -I$(TOOLS_DIR)
 CCFLAGS +=	-compat=5 -features=zla
-CCNEEDED=	-lCrun -lCstd
-$(__GNUC)CCNEEDED = -L$(SFWLIBDIR) -R$(SFWLIBDIR) -lstdc++ -lgcc_s
+$(__SUNC)CCNEEDED=	$(CCEXTNEEDED)
 LDFLAGS += $(ZIGNORE) -norunpath
 LDLIBS += -lsocket -lnsl
 
--- a/usr/src/cmd/lp/Makefile.lp	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/cmd/lp/Makefile.lp	Sat Apr 14 20:29:22 2012 -0400
@@ -84,15 +84,15 @@
 LINTSEC	=	$(LPLIB)/secure/llib-llpsec.ln
 LINTUSR	=	$(LPLIB)/users/llib-llpusr.ln
 
-CFLAGS += -_gcc=-fwritable-strings -_gcc=-Wno-sequence-points
-CFLAGS64 += -_gcc=-fwritable-strings -_gcc=-Wno-sequence-points
+$(__GNUC3)CERRWARN +=	-_gcc=-Wno-sequence-points
+$(__GNUC4)CERRWARN +=	-_gcc=-Wno-sequence-point
 
-all:=           TARGET= all
-install:=       TARGET= install
-clean:=         TARGET= clean
-clobber:=       TARGET= clobber
-lint:=          TARGET= lint
-strip:=          TARGET= strip
+all:=		TARGET= all
+install:=	TARGET= install
+clean:=		TARGET= clean
+clobber:=	TARGET= clobber
+lint:=		TARGET= lint
+strip:=		TARGET= strip
 catalog:=	TARGET= catalog
 _msg:=		TARGET= catalog
 
--- a/usr/src/cmd/vi/port/ex_cmdsub.c	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/cmd/vi/port/ex_cmdsub.c	Sat Apr 14 20:29:22 2012 -0400
@@ -39,6 +39,8 @@
 #undef getchar
 #undef putchar
 #endif
+
+
 /*
  * Command mode subroutines implementing
  *	append, args, copy, delete, join, move, put,
@@ -1725,12 +1727,11 @@
 
 unsigned char *
 vgetpass(prompt)
-unsigned char *prompt;
+char *prompt;
 {
 	unsigned char *p;
 	int c;
 	static unsigned char pbuf[9];
-	char *getpass();
 
 	/* In ex mode, let the system hassle with setting no echo */
 	if (!inopen)
--- a/usr/src/grub/grub-0.97/Makefile.solaris.defs	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/grub/grub-0.97/Makefile.solaris.defs	Sat Apr 14 20:29:22 2012 -0400
@@ -2,8 +2,6 @@
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 include $(SRC)/Makefile.master
 
 .KEEP_STATE:
@@ -44,11 +42,11 @@
 OPTION_FS	= $(POUND_SIGN)
 
 
-BASE_CFLAGS	= -B$(GNU_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS)
-BASE_CCASFLAGS	= -B$(GNU_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS)
+BASE_CFLAGS	= -B$(GCC_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS)
+BASE_CCASFLAGS	= -B$(GCC_ROOT)/bin/ -g $(CPPFLAGS) $(OPTFLAGS)
 BASE_LDFLAGS	=
 
-CC		= $(GNU_ROOT)/bin/gcc
+CC		= $(GCC_ROOT)/bin/gcc
 CFLAGS		= $(BASE_CFLAGS)
 CCDEPMODE	= depmode=none
 
--- a/usr/src/head/iso/setjmp_iso.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/head/iso/setjmp_iso.h	Sat Apr 14 20:29:22 2012 -0400
@@ -43,9 +43,6 @@
 #ifndef _ISO_SETJMP_ISO_H
 #define	_ISO_SETJMP_ISO_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-/* SVr4.0 1.9.2.9 */
-
 #include <sys/feature_tests.h>
 
 #ifdef	__cplusplus
@@ -92,18 +89,18 @@
 
 #if defined(__STDC__)
 
-extern int setjmp(jmp_buf);
+extern int setjmp(jmp_buf) __RETURNS_TWICE;
 #pragma unknown_control_flow(setjmp)
-extern int _setjmp(jmp_buf);
+extern int _setjmp(jmp_buf) __RETURNS_TWICE;
 #pragma unknown_control_flow(_setjmp)
 extern void longjmp(jmp_buf, int) __NORETURN;
 extern void _longjmp(jmp_buf, int) __NORETURN;
 
 #else
 
-extern int setjmp();
+extern int setjmp() __RETURNS_TWICE;
 #pragma unknown_control_flow(setjmp)
-extern int _setjmp();
+extern int _setjmp() __RETURNS_TWICE;
 #pragma unknown_control_flow(_setjmp)
 extern void longjmp();
 extern void _longjmp();
--- a/usr/src/head/setjmp.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/head/setjmp.h	Sat Apr 14 20:29:22 2012 -0400
@@ -31,8 +31,6 @@
 #ifndef _SETJMP_H
 #define	_SETJMP_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.9.2.9 */
-
 #include <iso/setjmp_iso.h>
 
 /*
@@ -60,7 +58,7 @@
 typedef int sigjmp_buf[_SIGJBLEN];
 #endif
 
-extern int sigsetjmp(sigjmp_buf, int);
+extern int sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
 #pragma unknown_control_flow(sigsetjmp)
 extern void siglongjmp(sigjmp_buf, int) __NORETURN;
 #endif
@@ -73,7 +71,7 @@
 typedef int sigjmp_buf[_SIGJBLEN];
 #endif
 
-extern int sigsetjmp();
+extern int sigsetjmp() __RETURNS_TWICE;
 #pragma unknown_control_flow(sigsetjmp)
 extern void siglongjmp();
 
--- a/usr/src/head/ucontext.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/head/ucontext.h	Sat Apr 14 20:29:22 2012 -0400
@@ -30,8 +30,6 @@
 #ifndef _UCONTEXT_H
 #define	_UCONTEXT_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/ucontext.h>
 
 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
@@ -52,7 +50,7 @@
 
 #if defined(__STDC__)
 
-extern int getcontext(ucontext_t *);
+extern int getcontext(ucontext_t *) __RETURNS_TWICE;
 #pragma unknown_control_flow(getcontext)
 extern int setcontext(const ucontext_t *) __NORETURN;
 extern int swapcontext(ucontext_t *_RESTRICT_KYWD,
@@ -75,7 +73,7 @@
 #endif
 #else
 
-extern int getcontext();
+extern int getcontext() __RETURNS_TWICE;
 #pragma unknown_control_flow(getcontext)
 extern int setcontext();
 extern int swapcontext();
--- a/usr/src/head/unistd.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/head/unistd.h	Sat Apr 14 20:29:22 2012 -0400
@@ -536,7 +536,7 @@
 extern int usleep(useconds_t);
 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
-extern pid_t vfork(void);
+extern pid_t vfork(void) __RETURNS_TWICE;
 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
 extern void vhangup(void);
--- a/usr/src/lib/libc/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -127,7 +127,7 @@
 
 .KEEP_STATE:
 
-all:	lib32 $(BUILD64) .WAIT lib64 .WAIT etc THIRDPARTYLICENSE
+all:	all_h lib32 $(BUILD64) .WAIT lib64 .WAIT etc THIRDPARTYLICENSE
 
 THIRDPARTYLICENSE: extract-copyright
 	$(RM) $@
--- a/usr/src/lib/libc/inc/base_inlines.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/inc/base_inlines.h	Sat Apr 14 20:29:22 2012 -0400
@@ -27,8 +27,7 @@
 #ifndef	_BASE_INLINES_H
 #define	_BASE_INLINES_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
+#include <sys/ccompile.h>
 #include <sys/types.h>
 
 #if !defined(__lint) && defined(__GNUC__)
@@ -41,7 +40,7 @@
  */
 
 #if defined(__sparc)
-extern __inline__ double
+extern __GNU_INLINE double
 __mul_set(double x, double y, int *pe)
 {
 	double __result;
@@ -49,19 +48,19 @@
 	uint32_t *__addr = &__fsr;
 
 	__asm__ __volatile__(
-		"fmuld %4, %5, %0\n\t"
-		"st %%fsr, %3\n\t"
-		"ld %3, %2\n\t"
-		"and %2, 1, %2\n\t"
-		"st %2, %1"
-		: "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
-		: "e" (x), "e" (y));
+	    "fmuld %4, %5, %0\n\t"
+	    "st %%fsr, %3\n\t"
+	    "ld %3, %2\n\t"
+	    "and %2, 1, %2\n\t"
+	    "st %2, %1"
+	    : "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
+	    : "e" (x), "e" (y));
 	return (__result);
 }
 #endif	/* __sparc */
 
 #if defined(__sparc)
-extern __inline__ double
+extern __GNU_INLINE double
 __div_set(double x, double y, int *pe)
 {
 	double __result;
@@ -69,37 +68,37 @@
 	uint32_t *__addr = &__fsr;
 
 	__asm__ __volatile__(
-		"fdivd %4, %5, %0\n\t"
-		"st %%fsr, %3\n\t"
-		"ld %3, %2\n\t"
-		"and %2, 1, %2\n\t"
-		"st %2, %1"
-		: "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
-		: "e" (x), "e" (y));
+	    "fdivd %4, %5, %0\n\t"
+	    "st %%fsr, %3\n\t"
+	    "ld %3, %2\n\t"
+	    "and %2, 1, %2\n\t"
+	    "st %2, %1"
+	    : "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
+	    : "e" (x), "e" (y));
 	return (__result);
 }
 #endif	/* __sparc */
 
 #if defined(__sparc)
-extern __inline__ double
+extern __GNU_INLINE double
 __dabs(double *x)
 {
 	double __result;
 
 	__asm__ __volatile__(
 #if defined(__sparcv9)
-		"fabsd %1, %0"
+	    "fabsd %1, %0"
 #else
-		"fabss %1, %0"
+	    "fabss %1, %0"
 #endif
-		: "=e" (__result)
-		: "0" (*x));
+	    : "=e" (__result)
+	    : "0" (*x));
 	return (__result);
 }
 #endif	/* __sparc */
 
 #if defined(__sparc)
-extern __inline__ void
+extern  __GNU_INLINE void
 __get_ieee_flags(__ieee_flags_type *b)
 {
 	uint32_t __fsr;
@@ -109,16 +108,16 @@
 	 * needed; however, it warns as it does so.  Add them here for now.
 	 */
 	__asm__ __volatile__(
-		"st %%fsr, %0\n\t"
-		"st %%g0, %1\n\t"
-		"ld %1, %%fsr\n\t"
-		"nop; nop; nop"
-		: "=m" (*b), "=m" (__fsr));
+	    "st %%fsr, %0\n\t"
+	    "st %%g0, %1\n\t"
+	    "ld %1, %%fsr\n\t"
+	    "nop; nop; nop"
+	    : "=m" (*b), "=m" (__fsr));
 }
 #endif	/* __sparc */
 
 #if defined(__sparc)
-extern __inline__ void
+extern __GNU_INLINE void
 __set_ieee_flags(__ieee_flags_type *b)
 {
 	/*
@@ -126,10 +125,10 @@
 	 * needed; however, it warns as it does so.  Add them here for now.
 	 */
 	__asm__ __volatile__(
-		"ld %0, %%fsr\n\t"
-		"nop; nop; nop"
-		: /* no outputs */
-		: "m" (*b));
+	    "ld %0, %%fsr\n\t"
+	    "nop; nop; nop"
+	    : /* no outputs */
+	    : "m" (*b));
 }
 #endif	/* __sparc */
 
--- a/usr/src/lib/libc/inc/thr_inlines.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/inc/thr_inlines.h	Sat Apr 14 20:29:22 2012 -0400
@@ -27,13 +27,24 @@
 #ifndef _THR_INLINES_H
 #define	_THR_INLINES_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
+#include <sys/ccompile.h>
 
 #if !defined(__lint) && defined(__GNUC__)
 
 /* inlines for gcc */
 
-extern __inline__ ulwp_t *
+/*
+ * ON-usable GCC 4.x emits register pseudo-ops declaring %g7 as ignored, rather
+ * than scratch, GCC 3 does the reverse.  All uses, both ones it generated
+ * (_curthread) and ones it didn't (__curthread) must agree.
+ */
+#if __GNUC__ > 3
+#define	SPARC_REG_SPEC	"#ignore"
+#else
+#define	SPARC_REG_SPEC	"#scratch"
+#endif
+
+extern __GNU_INLINE ulwp_t *
 _curthread(void)
 {
 #if defined(__amd64)
@@ -50,31 +61,29 @@
 	return (__value);
 }
 
-extern __inline__ ulwp_t *
+extern __GNU_INLINE ulwp_t *
 __curthread(void)
 {
 	ulwp_t *__value;
 	__asm__ __volatile__(
 #if defined(__amd64)
-		"movq %%fs:0, %0\n\t"
+	    "movq %%fs:0, %0\n\t"
 #elif defined(__i386)
-		"movl %%gs:0, %0\n\t"
+	    "movl %%gs:0, %0\n\t"
 #elif defined(__sparcv9)
-		".register %%g7, #scratch\n\t"
-		"ldx [%%g7 + 80], %0\n\t"
+	    ".register %%g7, " SPARC_REG_SPEC "\n\t"
+	    "ldx [%%g7 + 80], %0\n\t"
 #elif defined(__sparc)
-		".register %%g7, #scratch\n\t"
-		"ld [%%g7 + 80], %0\n\t"
+	    ".register %%g7, " SPARC_REG_SPEC "\n\t"
+	    "ld [%%g7 + 80], %0\n\t"
 #else
 #error	"port me"
 #endif
-		"1:"
-		: "=r" (__value)
-		: : "cc");
+	    : "=r" (__value));
 	return (__value);
 }
 
-extern __inline__ greg_t
+extern __GNU_INLINE greg_t
 stkptr(void)
 {
 #if defined(__amd64)
@@ -89,207 +98,207 @@
 	return (__value);
 }
 
-extern __inline__ hrtime_t
+extern __GNU_INLINE hrtime_t
 gethrtime(void)		/* note: caller-saved registers are trashed */
 {
 #if defined(__amd64)
 	hrtime_t __value;
 	__asm__ __volatile__(
-		"movl $3, %%eax\n\t"
-		"int $0xd2"
-		: "=a" (__value)
-		: : "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "cc");
+	    "movl $3, %%eax\n\t"
+	    "int $0xd2"
+	    : "=a" (__value)
+	    : : "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "cc");
 #elif defined(__i386)
 	hrtime_t __value;
 	__asm__ __volatile__(
-		"movl $3, %%eax\n\t"
-		"int $0xd2"
-		: "=A" (__value)
-		: : "ecx", "cc");
+	    "movl $3, %%eax\n\t"
+	    "int $0xd2"
+	    : "=A" (__value)
+	    : : "ecx", "cc");
 #elif defined(__sparcv9)
 	register hrtime_t __value __asm__("o0");
 	__asm__ __volatile__(
-		"ta 0x24\n\t"
-		"sllx %%o0, 32, %0\n\t"
-		"or %%o1, %0, %0"
-		: "=r" (__value)
-		: : "o1", "o2", "o3", "o4", "o5", "cc");
+	    "ta 0x24\n\t"
+	    "sllx %%o0, 32, %0\n\t"
+	    "or %%o1, %0, %0"
+	    : "=r" (__value)
+	    : : "o1", "o2", "o3", "o4", "o5", "cc");
 #elif defined(__sparc)
 	register hrtime_t __value __asm__("o0");
 	__asm__ __volatile__(
-		"ta 0x24"
-		: "=r" (__value)
-		: : "o2", "o3", "o4", "o5", "cc");
+	    "ta 0x24"
+	    : "=r" (__value)
+	    : : "o2", "o3", "o4", "o5", "cc");
 #else
 #error	"port me"
 #endif
 	return (__value);
 }
 
-extern __inline__ int
+extern __GNU_INLINE int
 set_lock_byte(volatile uint8_t *__lockp)
 {
 	int __value;
 #if defined(__x86)
 	__asm__ __volatile__(
-		"movl $1, %0\n\t"
-		"xchgb %%dl, %1"
-		: "+d" (__value), "+m" (*__lockp));
+	    "movl $1, %0\n\t"
+	    "xchgb %%dl, %1"
+	    : "+d" (__value), "+m" (*__lockp));
 #elif defined(__sparc)
 	__asm__ __volatile__(
-		"ldstub %1, %0\n\t"
-		"membar #LoadLoad"
-		: "=r" (__value), "+m" (*__lockp));
+	    "ldstub %1, %0\n\t"
+	    "membar #LoadLoad"
+	    : "=r" (__value), "+m" (*__lockp));
 #else
 #error	"port me"
 #endif
 	return (__value);
 }
 
-extern __inline__ uint32_t
+extern __GNU_INLINE uint32_t
 atomic_swap_32(volatile uint32_t *__memory, uint32_t __value)
 {
 #if defined(__x86)
 	__asm__ __volatile__(
-		"xchgl %0, %1"
-		: "+q" (__value), "+m" (*__memory));
+	    "xchgl %0, %1"
+	    : "+q" (__value), "+m" (*__memory));
 	return (__value);
 #elif defined(__sparc)
 	uint32_t __tmp1, __tmp2;
 	__asm__ __volatile__(
-		"ld [%3], %0\n\t"
-		"1:\n\t"
-		"mov %4, %1\n\t"
-		"cas [%3], %0, %1\n\t"
-		"cmp %0, %1\n\t"
-		"bne,a,pn %%icc, 1b\n\t"
-		"  mov %1, %0"
-		: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
-		: "r" (__memory), "r" (__value)
-		: "cc");
+	    "ld [%3], %0\n\t"
+	    "1:\n\t"
+	    "mov %4, %1\n\t"
+	    "cas [%3], %0, %1\n\t"
+	    "cmp %0, %1\n\t"
+	    "bne,a,pn %%icc, 1b\n\t"
+	    "  mov %1, %0"
+	    : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
+	    : "r" (__memory), "r" (__value)
+	    : "cc");
 	return (__tmp2);
 #else
 #error	"port me"
 #endif
 }
 
-extern __inline__ uint32_t
+extern __GNU_INLINE uint32_t
 atomic_cas_32(volatile uint32_t *__memory, uint32_t __cmp, uint32_t __newvalue)
 {
 	uint32_t __oldvalue;
 #if defined(__x86)
 	__asm__ __volatile__(
-		"lock; cmpxchgl %3, %0"
-		: "=m" (*__memory), "=a" (__oldvalue)
-		: "a" (__cmp), "r" (__newvalue));
+	    "lock; cmpxchgl %3, %0"
+	    : "=m" (*__memory), "=a" (__oldvalue)
+	    : "a" (__cmp), "r" (__newvalue));
 #elif defined(__sparc)
 	__asm__ __volatile__(
-		"cas [%2], %3, %1"
-		: "=m" (*__memory), "=&r" (__oldvalue)
-		: "r" (__memory), "r" (__cmp), "1" (__newvalue));
+	    "cas [%2], %3, %1"
+	    : "=m" (*__memory), "=&r" (__oldvalue)
+	    : "r" (__memory), "r" (__cmp), "1" (__newvalue));
 #else
 #error	"port me"
 #endif
 	return (__oldvalue);
 }
 
-extern __inline__ void
+extern __GNU_INLINE void
 atomic_inc_32(volatile uint32_t *__memory)
 {
 #if defined(__x86)
 	__asm__ __volatile__(
-		"lock; incl %0"
-		: "+m" (*__memory));
+	    "lock; incl %0"
+	    : "+m" (*__memory));
 #elif defined(__sparc)
 	uint32_t __tmp1, __tmp2;
 	__asm__ __volatile__(
-		"ld [%3], %0\n\t"
-		"1:\n\t"
-		"add %0, 1, %1\n\t"
-		"cas [%3], %0, %1\n\t"
-		"cmp %0, %1\n\t"
-		"bne,a,pn %%icc, 1b\n\t"
-		"  mov %1, %0"
-		: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
-		: "r" (__memory)
-		: "cc");
+	    "ld [%3], %0\n\t"
+	    "1:\n\t"
+	    "add %0, 1, %1\n\t"
+	    "cas [%3], %0, %1\n\t"
+	    "cmp %0, %1\n\t"
+	    "bne,a,pn %%icc, 1b\n\t"
+	    "  mov %1, %0"
+	    : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
+	    : "r" (__memory)
+	    : "cc");
 #else
 #error	"port me"
 #endif
 }
 
-extern __inline__ void
+extern __GNU_INLINE void
 atomic_dec_32(volatile uint32_t *__memory)
 {
 #if defined(__x86)
 	__asm__ __volatile__(
-		"lock; decl %0"
-		: "+m" (*__memory));
+	    "lock; decl %0"
+	    : "+m" (*__memory));
 #elif defined(__sparc)
 	uint32_t __tmp1, __tmp2;
 	__asm__ __volatile__(
-		"ld [%3], %0\n\t"
-		"1:\n\t"
-		"sub %0, 1, %1\n\t"
-		"cas [%3], %0, %1\n\t"
-		"cmp %0, %1\n\t"
-		"bne,a,pn %%icc, 1b\n\t"
-		"  mov %1, %0"
-		: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
-		: "r" (__memory)
-		: "cc");
+	    "ld [%3], %0\n\t"
+	    "1:\n\t"
+	    "sub %0, 1, %1\n\t"
+	    "cas [%3], %0, %1\n\t"
+	    "cmp %0, %1\n\t"
+	    "bne,a,pn %%icc, 1b\n\t"
+	    "  mov %1, %0"
+	    : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
+	    : "r" (__memory)
+	    : "cc");
 #else
 #error	"port me"
 #endif
 }
 
-extern __inline__ void
+extern __GNU_INLINE void
 atomic_and_32(volatile uint32_t *__memory, uint32_t __bits)
 {
 #if defined(__x86)
 	__asm__ __volatile__(
-		"lock; andl %1, %0"
-		: "+m" (*__memory)
-		: "r" (__bits));
+	    "lock; andl %1, %0"
+	    : "+m" (*__memory)
+	    : "r" (__bits));
 #elif defined(__sparc)
 	uint32_t __tmp1, __tmp2;
 	__asm__ __volatile__(
-		"ld [%3], %0\n\t"
-		"1:\n\t"
-		"and %0, %4, %1\n\t"
-		"cas [%3], %0, %1\n\t"
-		"cmp %0, %1\n\t"
-		"bne,a,pn %%icc, 1b\n\t"
-		"  mov %1, %0"
-		: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
-		: "r" (__memory), "r" (__bits)
-		: "cc");
+	    "ld [%3], %0\n\t"
+	    "1:\n\t"
+	    "and %0, %4, %1\n\t"
+	    "cas [%3], %0, %1\n\t"
+	    "cmp %0, %1\n\t"
+	    "bne,a,pn %%icc, 1b\n\t"
+	    "  mov %1, %0"
+	    : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
+	    : "r" (__memory), "r" (__bits)
+	    : "cc");
 #else
 #error	"port me"
 #endif
 }
 
-extern __inline__ void
+extern __GNU_INLINE void
 atomic_or_32(volatile uint32_t *__memory, uint32_t __bits)
 {
 #if defined(__x86)
 	__asm__ __volatile__(
-		"lock; orl %1, %0"
-		: "+m" (*__memory)
-		: "r" (__bits));
+	    "lock; orl %1, %0"
+	    : "+m" (*__memory)
+	    : "r" (__bits));
 #elif defined(__sparc)
 	uint32_t __tmp1, __tmp2;
 	__asm__ __volatile__(
-		"ld [%3], %0\n\t"
-		"1:\n\t"
-		"or %0, %4, %1\n\t"
-		"cas [%3], %0, %1\n\t"
-		"cmp %0, %1\n\t"
-		"bne,a,pn %%icc, 1b\n\t"
-		"  mov %1, %0"
-		: "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
-		: "r" (__memory), "r" (__bits)
-		: "cc");
+	    "ld [%3], %0\n\t"
+	    "1:\n\t"
+	    "or %0, %4, %1\n\t"
+	    "cas [%3], %0, %1\n\t"
+	    "cmp %0, %1\n\t"
+	    "bne,a,pn %%icc, 1b\n\t"
+	    "  mov %1, %0"
+	    : "=&r" (__tmp1), "=&r" (__tmp2), "=m" (*__memory)
+	    : "r" (__memory), "r" (__bits)
+	    : "cc");
 #else
 #error	"port me"
 #endif
@@ -297,14 +306,14 @@
 
 #if defined(__sparc)	/* only needed on sparc */
 
-extern __inline__ ulong_t
+extern __GNU_INLINE ulong_t
 caller(void)
 {
 	register ulong_t __value __asm__("i7");
 	return (__value);
 }
 
-extern __inline__ ulong_t
+extern __GNU_INLINE ulong_t
 getfp(void)
 {
 	register ulong_t __value __asm__("fp");
@@ -315,7 +324,7 @@
 
 #if defined(__x86)	/* only needed on x86 */
 
-extern __inline__ void
+extern __GNU_INLINE void
 ht_pause(void)
 {
 	__asm__ __volatile__("rep; nop");
--- a/usr/src/lib/libc/port/unwind/unwind.c	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/port/unwind/unwind.c	Sat Apr 14 20:29:22 2012 -0400
@@ -24,8 +24,6 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include "lint.h"
 #include "thr_uberdata.h"
 #include <dlfcn.h>
@@ -40,9 +38,13 @@
  * _ex_unwind() is provided by libC, but if libC is not loaded we
  * need to call a local version of _ex_unwind() which does exactly
  * the same thing except for calling C++ destructors.
+ *
+ * Note that neither of these literally "returns twice" as, for eg, setjmp
+ * does, but they induce unusual control flow which the compiler should treat
+ * in the same manner (make all registers dead, etc.).
  */
-extern	void	_ex_clnup_handler(void *, void (*)(void *));
-extern	void	_ex_unwind_local(void);
+extern	void	_ex_clnup_handler(void *, void (*)(void *)) __RETURNS_TWICE;
+extern	void	_ex_unwind_local(void) __RETURNS_TWICE;
 #pragma unknown_control_flow(_ex_clnup_handler)
 #pragma unknown_control_flow(_ex_unwind_local)
 
--- a/usr/src/lib/libc/sparc/Makefile.com	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/sparc/Makefile.com	Sat Apr 14 20:29:22 2012 -0400
@@ -1204,8 +1204,9 @@
 
 $(TIL:%=pics/%) := CFLAGS += $(LIBCBASE)/threads/sparc.il
 
-# This hack is needed until the sparc gcc is fixed for TLS
-pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
+# This hack is needed because sparc GCC3 generates DWARF data about TLS which
+# The Sun assembler cannot process
+$(__GNUC3)pics/tls_data.o := CTF_FLAGS += -_gcc=-g1
 
 # special kludge for inlines with 'cas':
 pics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \
--- a/usr/src/lib/libc/sparc/crt/_rtboot.s	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/sparc/crt/_rtboot.s	Sat Apr 14 20:29:22 2012 -0400
@@ -74,7 +74,7 @@
 	.section ".text"
 	.volatile
 	.global	__rtboot
-	.local	__rtld
+	.global	__rtld
 	.local	s.LDSO, s.ZERO
 	.local	f.PANIC, f.OPENAT, f.MMAP, f.FSTATAT, f.SYSCONFIG
 	.local	f.CLOSE, f.EXIT, f.MUNMAP
--- a/usr/src/lib/libc/sparc/crt/_rtld.c	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/sparc/crt/_rtld.c	Sat Apr 14 20:29:22 2012 -0400
@@ -70,7 +70,7 @@
  * order to maintain the "no bootstrapping" requirement -- it calls only
  * local functions, uses no intrinsics, etc.
  */
-static void *
+void *
 __rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
 {
 	int i, p;			/* working */
--- a/usr/src/lib/libc/sparcv9/Makefile.com	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/libc/sparcv9/Makefile.com	Sat Apr 14 20:29:22 2012 -0400
@@ -1136,8 +1136,9 @@
 
 $(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/sparcv9.il
 
-# This hack is needed until the sparc gcc is fixed for TLS
-pics/tls_data.o := CC = env 'CW_NO_SHADOW=1' $(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
+# This hack is needed because sparc GCC3 generates DWARF data about TLS which
+# The Sun assembler cannot process
+$(__GNUC3)pics/tls_data.o := CTF_FLAGS += -_gcc=-g1
 
 # Files in fp, port/fp subdirectories that need base.il inline template
 IL=				\
--- a/usr/src/lib/scsi/libses/Makefile.defs	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/scsi/libses/Makefile.defs	Sat Apr 14 20:29:22 2012 -0400
@@ -50,10 +50,10 @@
 	../common/ses_errno.c
 
 #
-# On SPARC, gcc emits DWARF assembler directives for TLS data that are not
+# On SPARC, gcc 3.4 emits DWARF assembler directives for TLS data that are not
 # understood by the Sun assembler.  Until this problem is fixed, we turn down
 # the amount of generated debugging information, which seems to do the trick.
 #
-$(SPARC_BLD)CTF_FLAGS += -_gcc=-g1
+$(__GNUC3)$(SPARC_BLD)CTF_FLAGS += -_gcc=-g1
 
 $(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
--- a/usr/src/lib/scsi/libsmp/Makefile.com	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/scsi/libsmp/Makefile.com	Sat Apr 14 20:29:22 2012 -0400
@@ -51,11 +51,11 @@
 	../common/smp_errno.c
 
 #
-# On SPARC, gcc emits DWARF assembler directives for TLS data that are not
+# On SPARC, gcc 3.4 emits DWARF assembler directives for TLS data that are not
 # understood by the Sun assembler.  Until this problem is fixed, we turn down
 # the amount of generated debugging information, which seems to do the trick.
 #
-$(SPARC_BLD)CTF_FLAGS += -_gcc=-g1
+$(__GNUC3)$(SPARC_BLD)CTF_FLAGS += -_gcc=-g1
 
 $(LINTLIB) :=	SRCS = $(SRCDIR)/$(LINTSRC)
 
--- a/usr/src/lib/sun_fc/Makefile.com	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/sun_fc/Makefile.com	Sat Apr 14 20:29:22 2012 -0400
@@ -137,13 +137,12 @@
 CCFLAGS64 +=	-compat=5
 CPPFLAGS +=	$(INCS) -DBUILD_TIME='"Wed Sep 24 12:00:00 2008"'
 
-LDLIBS		+= -ldevinfo
-LDLIBS		+= -lsysevent
-LDLIBS		+= -lnvpair
-CCRUNLIBS	= -lCstd -lCrun
-$(__GNUC)CCRUNLIBS	= -lstdc++ -lgcc_s
-LDLIBS		+= $(CCRUNLIBS)
-LDLIBS		+= -lc
+LDLIBS			+= -ldevinfo
+LDLIBS			+= -lsysevent
+LDLIBS			+= -lnvpair
+$(__SUNC)CCNEEDED	= $(CCEXTNEEDED)
+LDLIBS			+= $(CCNEEDED)
+LDLIBS			+= -lc
 
 $(LINTLIB) := SRCS=	$(SRCDIR)/$(LINTSRC)
 
--- a/usr/src/lib/sun_fc/amd64/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/sun_fc/amd64/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -27,6 +27,8 @@
 include ../Makefile.com
 include ../../Makefile.lib.64
 
+$(__SUNC)CCNEEDED = $(CCEXTNEEDED)
+
 .KEEP_STATE:
 
 all:  $(LIBS)
--- a/usr/src/lib/sun_fc/sparcv9/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/lib/sun_fc/sparcv9/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -27,6 +27,8 @@
 include ../Makefile.com
 include ../../Makefile.lib.64
 
+$(__SUNC)CCNEEDED = $(CCEXTNEEDED)
+
 .KEEP_STATE:
 
 all:  $(LIBS)
--- a/usr/src/psm/stand/bootblks/ufs/i386/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/psm/stand/bootblks/ufs/i386/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -23,8 +23,6 @@
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 # psm/stand/bootblks/ufs/i386/Makefile
 #
 .KEEP_STATE:
@@ -34,8 +32,8 @@
 include $(BASEDIR)/ufs/Makefile.ufs
 
 
-CC		= $(GNU_ROOT)/bin/gcc
-ASFLAGS		= -B$(GNU_ROOT)/bin/ -fno-builtin -nostdinc
+CC		= $(GCC_ROOT)/bin/gcc
+ASFLAGS		= -B$(GCC_ROOT)/bin/ -fno-builtin -nostdinc
 CPPFLAGS	=
 
 LD		= $(GNU_ROOT)/bin/gld
--- a/usr/src/tools/cw/Makefile	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/tools/cw/Makefile	Sat Apr 14 20:29:22 2012 -0400
@@ -22,8 +22,6 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
 
 PROG	= cw
 
@@ -34,23 +32,25 @@
 # Bootstrap problem -- we have to build cw before we can use it
 i386_CC=		$(SPRO_VROOT)/bin/cc
 sparc_CC=		$(SPRO_VROOT)/bin/cc
-$(__GNUC)i386_CC=	$(GNU_ROOT)/bin/gcc
-$(__GNUC)sparc_CC=	$(GNU_ROOT)/bin/gcc
+$(__GNUC)i386_CC=	$(GCC_ROOT)/bin/gcc
+$(__GNUC)sparc_CC=	$(GCC_ROOT)/bin/gcc
 
 CFLAGS += $(CCVERBOSE)
 
-# Override CFLAGS when building with gcc.  This is needed only for bootstrap
-# of cw.
+# Override CFLAGS.  This is needed only for bootstrap of cw.
 $(__GNUC)CFLAGS=	-O -D__sun -Wall -Wno-unknown-pragmas -Werror \
 			-std=gnu89 -nodefaultlibs
+$(__SUNC)CFLAGS=	-xspace -Xa  -xildoff -errtags=yes -errwarn=%all \
+			-xc99=%none    -W0,-xglobalstatic -v
+
 
 $(__GNUC)LDLIBS +=	-lc
 $(__GNUC)LDFLAGS= 	$(MAPFILE.NES:%=-Wl,-M%)
 
 CPPFLAGS += -DDEFAULT_CC_DIR='"$(SPRO_VROOT)/bin"'
-CPPFLAGS += -DDEFAULT_GCC_DIR='"$(GNU_ROOT)/bin"'
+CPPFLAGS += -DDEFAULT_GCC_DIR='"$(GCC_ROOT)/bin"'
 CPPFLAGS += -DDEFAULT_CPLUSPLUS_DIR='"$(SPRO_VROOT)/bin"'
-CPPFLAGS += -DDEFAULT_GPLUSPLUS_DIR='"$(GNU_ROOT)/bin"'
+CPPFLAGS += -DDEFAULT_GPLUSPLUS_DIR='"$(GCC_ROOT)/bin"'
 
 $(ROOTONBLDMAN1FILES) := FILEMODE=      644
 
--- a/usr/src/tools/cw/cw.1	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/tools/cw/cw.1	Sat Apr 14 20:29:22 2012 -0400
@@ -231,7 +231,7 @@
 will be used.  Likewise, if CW_GPLUSPLUS_DIR is set, the GNU C++
 compiler in \fI$CW_GPLUSPLUS_DIR\fP will be used.
 Otherwise, if GNU_ROOT is set, the GNU C and C++ compilers
-in \fI$GNU_ROOT/bin\fP will be used.
+in \fI$GCC_ROOT/bin\fP will be used.
 Otherwise, the GNU compilers in a predefined default location
 will be used.
 .LP
--- a/usr/src/tools/cw/cw.c	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/tools/cw/cw.c	Sat Apr 14 20:29:22 2012 -0400
@@ -1140,11 +1140,6 @@
 				break;
 			}
 #if defined(__x86)
-			if (strcmp(arg, "-Wu,-no_got_reloc") == 0) {
-				newae(ctx->i_ae, "-fno-jump-tables");
-				newae(ctx->i_ae, "-fno-constant-pools");
-				break;
-			}
 			if (strcmp(arg, "-Wu,-xmodel=kernel") == 0) {
 				newae(ctx->i_ae, "-ffreestanding");
 				newae(ctx->i_ae, "-mno-red-zone");
@@ -1842,7 +1837,7 @@
 		    "%s/SUNWspro/SS12/bin", dir);
 	}
 
-	if ((dir = getenv("GNU_ROOT")) != NULL) {
+	if ((dir = getenv("GCC_ROOT")) != NULL) {
 		(void) snprintf(default_dir[CW_C_GCC], MAXPATHLEN,
 		    "%s/bin", dir);
 	}
--- a/usr/src/ucbhead/setjmp.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/ucbhead/setjmp.h	Sat Apr 14 20:29:22 2012 -0400
@@ -47,8 +47,6 @@
 #ifndef _SETJMP_H
 #define	_SETJMP_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/types.h>
 #include <sys/signal.h>
 #include <sys/ucontext.h>
@@ -110,21 +108,21 @@
 
 #if defined(__STDC__)
 
-extern int _sigsetjmp(sigjmp_buf, int);
+extern int _sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
 #pragma unknown_control_flow(_sigsetjmp)
 extern void _siglongjmp(sigjmp_buf, int) __NORETURN;
 
-extern int	sigsetjmp(sigjmp_buf, int);
+extern int	sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
 #pragma unknown_control_flow(sigsetjmp)
 extern void	siglongjmp(sigjmp_buf, int) __NORETURN;
 
 #else
 
-extern int _sigsetjmp();
+extern int _sigsetjmp() __RETURNS_TWICE;
 #pragma unknown_control_flow(_sigsetjmp)
 extern void _siglongjmp();
 
-extern int sigsetjmp();
+extern int sigsetjmp() __RETURNS_TWICE;
 #pragma unknown_control_flow(sigsetjmp)
 extern void siglongjmp();
 
--- a/usr/src/uts/Makefile.uts	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/Makefile.uts	Sat Apr 14 20:29:22 2012 -0400
@@ -222,6 +222,7 @@
 CFLAGS_uts		+= $(XAOPT)
 CFLAGS_uts		+= $(CTF_FLAGS)
 CFLAGS_uts		+= $(CERRWARN)
+CFLAGS_uts		+= $(CCNOAUTOINLINE)
 CFLAGS_uts		+= $(CGLOBALSTATIC)
 CFLAGS_uts		+= $(EXTRA_CFLAGS)
 
--- a/usr/src/uts/common/sys/ccompile.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/common/sys/ccompile.h	Sat Apr 14 20:29:22 2012 -0400
@@ -83,13 +83,23 @@
  *
  * Should only be used on 'extern inline' definitions for GCC.
  */
-#if __GNUC_VERSION >= 40300
+#if __GNUC_VERSION >= 40200
 #define	__sun_attr___gnu_inline__	__attribute__((__gnu_inline__))
 #else
 #define	__sun_attr___gnu_inline__
 #endif
 
 /*
+ * The function has control flow such that it may return multiple times (in
+ * the manner of setjmp or vfork)
+ */
+#if __GNUC_VERSION >= 40100
+#define	__sun_attr___returns_twice__	__attribute__((__returns_twice__))
+#else
+#define	__sun_attr___returns_twice__
+#endif
+
+/*
  * This is an appropriate label for functions that do not
  * modify their arguments, e.g. strlen()
  */
@@ -126,6 +136,7 @@
 #define	__KVPRINTFLIKE(__n)	__sun_attr__((__KVPRINTFLIKE__(__n)))
 #define	__NORETURN		__sun_attr__((__noreturn__))
 #define	__GNU_INLINE		__inline__ __sun_attr__((__gnu_inline__))
+#define	__RETURNS_TWICE		__sun_attr__((__returns_twice__))
 #define	__CONST			__sun_attr__((__const__))
 #define	__PURE			__sun_attr__((__pure__))
 
--- a/usr/src/uts/common/sys/fork.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/common/sys/fork.h	Sat Apr 14 20:29:22 2012 -0400
@@ -39,7 +39,7 @@
 
 extern pid_t forkx(int);
 extern pid_t forkallx(int);
-extern pid_t vforkx(int);
+extern pid_t vforkx(int) __RETURNS_TWICE;
 
 #pragma unknown_control_flow(vforkx)
 
--- a/usr/src/uts/common/sys/ontrap.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/common/sys/ontrap.h	Sat Apr 14 20:29:22 2012 -0400
@@ -26,8 +26,6 @@
 #ifndef	_ONTRAP_H
 #define	_ONTRAP_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #if !defined(_ASM)
 #include <sys/types.h>
 #endif
@@ -104,7 +102,7 @@
 
 #if defined(_KERNEL)
 
-extern int on_trap(on_trap_data_t *, uint_t);
+extern int on_trap(on_trap_data_t *, uint_t) __RETURNS_TWICE;
 #pragma	unknown_control_flow(on_trap)
 extern void no_trap(void);
 
--- a/usr/src/uts/common/sys/systm.h	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/common/sys/systm.h	Sat Apr 14 20:29:22 2012 -0400
@@ -247,7 +247,7 @@
 #endif
 
 #if !defined(_BOOT)
-int setjmp(label_t *);
+int setjmp(label_t *) __RETURNS_TWICE;
 extern void longjmp(label_t *)
 	__NORETURN;
 #pragma unknown_control_flow(setjmp)
@@ -260,7 +260,7 @@
 caddr_t caller(void);
 caddr_t callee(void);
 int getpcstack(pc_t *, int);
-int on_fault(label_t *);
+int on_fault(label_t *) __RETURNS_TWICE;
 void no_fault(void);
 void halt(char *);
 int scanc(size_t, uchar_t *, uchar_t *, uchar_t);
--- a/usr/src/uts/i86pc/Makefile.rules	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/i86pc/Makefile.rules	Sat Apr 14 20:29:22 2012 -0400
@@ -218,6 +218,7 @@
 DBOOT_MACH_64	= -D_BOOT_TARGET_amd64
 DBOOT_DEFS	= -D_BOOT $(DBOOT_MACH_$(CLASS))
 DBOOT_DEFS	+= -D_MACHDEP -D_KMEMUSER -U_KERNEL -D_I32LPx
+DBOOT_FLAGS	= $(CCVERBOSE) $(CERRWARN) $(CCNOAUTOINLINE)
 
 DBOOT_CC_INCL	= -I$(SRC)/common $(INCLUDE_PATH)
 DBOOT_AS_INCL	= $(AS_INC_PATH)
@@ -233,16 +234,16 @@
 	$(DBOOT_LINTFLAGS) $(DBOOT_LINTTAGS)
 
 $(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
-	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
 
 $(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
-	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
 
 $(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/intel/ia32/%.s
 	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
 
 $(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
-	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
 
 $(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.s
 	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
--- a/usr/src/uts/i86xpv/Makefile.rules	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/i86xpv/Makefile.rules	Sat Apr 14 20:29:22 2012 -0400
@@ -184,7 +184,7 @@
 
 DBOOT_XARCH_32 = $(i386_XARCH)
 DBOOT_XARCH_64 = $(amd64_XARCH)
-DBOOT_CFLAGS = $(DBOOT_XARCH_$(CLASS)) $(CERRWARN) -O
+DBOOT_CFLAGS = $(DBOOT_XARCH_$(CLASS)) $(CERRWARN) $(CCNOAUTOINLINE) -O
 
 DBOOT_AS_XARCH_32 = $(i386_AS_XARCH)
 DBOOT_AS_XARCH_64 = $(amd64_AS_XARCH)
--- a/usr/src/uts/sparc/Makefile.sparc.shared	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/sparc/Makefile.sparc.shared	Sat Apr 14 20:29:22 2012 -0400
@@ -135,6 +135,8 @@
 CFLAGS		+= $(C99MODE)
 CFLAGS		+= $(CCUNBOUND)
 CFLAGS		+= $(CCSTATICSYM)
+CFLAGS		+= $(CC32BITCALLERS)
+CFLAGS		+= $(CCNOAUTOINLINE)
 CFLAGS		+= $(IROPTFLAG)
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float
--- a/usr/src/uts/sun4u/Makefile.sun4u.shared	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/sun4u/Makefile.sun4u.shared	Sat Apr 14 20:29:22 2012 -0400
@@ -208,7 +208,9 @@
 CFLAGS		+= $(CTF_FLAGS)
 CFLAGS		+= $(C99MODE)
 CFLAGS		+= $(CCUNBOUND)
+CFLAGS		+= $(CCNOAUTOINLINE)
 CFLAGS		+= $(CCSTATICSYM)
+CFLAGS		+= $(CC32BITCALLERS)
 CFLAGS		+= $(IROPTFLAG)
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float
--- a/usr/src/uts/sun4v/Makefile.sun4v.shared	Thu Jun 14 08:00:26 2012 -0700
+++ b/usr/src/uts/sun4v/Makefile.sun4v.shared	Sat Apr 14 20:29:22 2012 -0400
@@ -182,7 +182,9 @@
 CFLAGS		+= $(CTF_FLAGS)
 CFLAGS		+= $(C99MODE)
 CFLAGS		+= $(CCUNBOUND)
+CFLAGS		+= $(CCNOAUTOINLINE)
 CFLAGS		+= $(CCSTATICSYM)
+CFLAGS		+= $(CC32BITCALLERS)
 CFLAGS		+= $(IROPTFLAG)
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float