diff --git a/bin/package b/bin/package index aa8a1478f098..21605f5df023 100755 --- a/bin/package +++ b/bin/package @@ -5442,12 +5442,12 @@ make|view) esac ;; esac - # Hack for Solaris 11.4, which needs -D_XPG6 in C flags to not segfault + # Hack for Solaris gcc, which needs -D_XPG6 in C flags to not segfault case `uname` in - SunOS) case " $CCFLAGS " in + SunOS) case "$CC, $CCFLAGS " in *" -D_XPG6 "*) ;; - *) CCFLAGS="-D_XPG6${CCFLAGS:+ $CCFLAGS}" + *gcc,*) CCFLAGS="-D_XPG6${CCFLAGS:+ $CCFLAGS}" export CCFLAGS ;; esac diff --git a/src/cmd/INIT/cc.sol11.i386 b/src/cmd/INIT/cc.sol11.i386 index f70c469cdd2a..cf8615c1f832 100755 --- a/src/cmd/INIT/cc.sol11.i386 +++ b/src/cmd/INIT/cc.sol11.i386 @@ -1,4 +1,4 @@ -: solaris.i386 cc wrapper for reasonable ansi C defaults and 32 bit : 2012-05-18 : +: solaris.i386 cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-16 : HOSTTYPE=sol11.i386 @@ -6,4 +6,11 @@ case " $* " in *" -dumpmachine "*) echo $HOSTTYPE; exit ;; esac +# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. +case ${CC_EXPLICIT:=$CC} in +'' | cc) + PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' + CC_EXPLICIT=cc +esac + $CC_EXPLICIT -m32 -xc99 -D_XPG6 "$@" diff --git a/src/cmd/INIT/cc.sol11.i386-64 b/src/cmd/INIT/cc.sol11.i386-64 index ac961cf26163..2d8e5983e77d 100755 --- a/src/cmd/INIT/cc.sol11.i386-64 +++ b/src/cmd/INIT/cc.sol11.i386-64 @@ -1,4 +1,4 @@ -: solaris.i386-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2012-05-18 : +: solaris.i386-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-16 : HOSTTYPE=sol11.i386-64 @@ -6,4 +6,11 @@ case " $* " in *" -dumpmachine "*) echo $HOSTTYPE; exit ;; esac +# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. +case ${CC_EXPLICIT:=$CC} in +'' | cc) + PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' + CC_EXPLICIT=cc +esac + $CC_EXPLICIT -m64 -xc99 -D_XPG6 "$@" diff --git a/src/cmd/INIT/cc.sol11.sparc b/src/cmd/INIT/cc.sol11.sparc index c12b40daf321..e0463bfbbd6c 100755 --- a/src/cmd/INIT/cc.sol11.sparc +++ b/src/cmd/INIT/cc.sol11.sparc @@ -1,4 +1,4 @@ -: solaris.sparc cc wrapper for reasonable ansi C defaults and 32 bit : 2012-05-18 : +: solaris.sparc cc wrapper for reasonable ansi C defaults and 32 bit : 2021-01-16 : HOSTTYPE=sol11.sparc @@ -6,4 +6,11 @@ case " $* " in *" -dumpmachine "*) echo $HOSTTYPE; exit ;; esac +# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. +case ${CC_EXPLICIT:=$CC} in +'' | cc) + PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' + CC_EXPLICIT=cc +esac + $CC_EXPLICIT -m32 -xc99 -D_XPG6 "$@" diff --git a/src/cmd/INIT/cc.sol11.sparc-64 b/src/cmd/INIT/cc.sol11.sparc-64 index 2565b642f83a..a2bd5441e1c7 100755 --- a/src/cmd/INIT/cc.sol11.sparc-64 +++ b/src/cmd/INIT/cc.sol11.sparc-64 @@ -1,4 +1,4 @@ -: solaris.sparc-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2012-05-18 : +: solaris.sparc-64 cc wrapper for reasonable ansi C defaults and 64 bit : 2021-01-16 : HOSTTYPE=sol11.sparc-64 @@ -6,4 +6,11 @@ case " $* " in *" -dumpmachine "*) echo $HOSTTYPE; exit ;; esac +# Solaris build scripts set $CC_EXPLICIT. If not set, function without it. +case ${CC_EXPLICIT:=$CC} in +'' | cc) + PATH=`/usr/bin/getconf PATH` # avoid infinite recursion executing 'cc' + CC_EXPLICIT=cc +esac + $CC_EXPLICIT -m64 -xc99 -D_XPG6 "$@" diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index a47da92ea12a..1ced626de625 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -5441,12 +5441,12 @@ make|view) esac ;; esac - # Hack for Solaris 11.4, which needs -D_XPG6 in C flags to not segfault + # Hack for Solaris gcc, which needs -D_XPG6 in C flags to not segfault case `uname` in - SunOS) case " $CCFLAGS " in + SunOS) case "$CC, $CCFLAGS " in *" -D_XPG6 "*) ;; - *) CCFLAGS="-D_XPG6${CCFLAGS:+ $CCFLAGS}" + *gcc,*) CCFLAGS="-D_XPG6${CCFLAGS:+ $CCFLAGS}" export CCFLAGS ;; esac