From 3552a2bafdc0ec4679c32db2eeafea975d87e814 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 4 Jun 2020 20:53:23 +0200 Subject: [PATCH] Restore building on old Mac OS X (Darwin) with GCC (re: e74e98b8) In making ksh build on new macOS, it stopped building on old Mac OS X (old gcc-based Darwin). There is no real reason for this. We can just restore the old cc wrapper script and use it if an old gcc compiler is detected. This is only tested on Mac OS X 10.3 on my old Power Mac G5 so far. But at least that allows me to test fixes on that platform. Unusual platforms sometimes expose corner case bugs... bin/package, src/cmd/INIT/package.sh: - If /usr/bin/cc is GCC, change 'darwin' host name to 'darwin_old'. This removes the long-obsolete 'darwin7' host name. src/cmd/INIT/cc.darwin_old: - Restore the old cc.darwin script for darwin_old hosts. (cherry picked from commit 93d4c6497ea8e9cc9f4977b75d06a673a2229f80) --- bin/package | 4 +-- src/cmd/INIT/cc.darwin_old | 73 ++++++++++++++++++++++++++++++++++++++ src/cmd/INIT/package.sh | 4 +-- 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100755 src/cmd/INIT/cc.darwin_old diff --git a/bin/package b/bin/package index d7f880dc7..5e9b10865 100755 --- a/bin/package +++ b/bin/package @@ -2395,8 +2395,8 @@ int main() esac case $lhs in bsdi) lhs=bsd ;; - darwin) case $rel in - [01234567].*) lhs=${lhs}7 ;; + darwin) case $(/usr/bin/cc --version) in + *'(GCC)'*) lhs=${lhs}_old ;; esac ;; freebsd) case $rel in diff --git a/src/cmd/INIT/cc.darwin_old b/src/cmd/INIT/cc.darwin_old new file mode 100755 index 000000000..081bd43b5 --- /dev/null +++ b/src/cmd/INIT/cc.darwin_old @@ -0,0 +1,73 @@ +: unix wrapper for mac osx cc : 2012-01-20 : + +HOSTTYPE=darwin.generic + +case " $* " in +*" -dumpmachine "*) echo $HOSTTYPE; exit ;; +esac + +CC=/usr/bin/cc +op=init +for arg +do case $op in + init) op=ld + set '' + ;; + esac + case $arg in + -c) op=cc + ;; + -E) op=cpp + continue + ;; + -G) op=dll + continue + ;; + -lc) continue + ;; + -lm) continue + ;; + -O) continue + ;; + esac + set "$@" "$arg" +done +case $# in +0) ;; +*) shift ;; +esac +case $* in +-v) $CC "$@"; exit ;; +esac +case $op in +init) echo "cc: arguments expected" >&2 + exit 1 + ;; +cpp) $CC -E "$@" + ;; +cc) $CC -DCLK_TCK=100 "$@" + ;; +dll) # what a compatibility mess -- surely they can get the apis to play nice + tmp=/tmp/cc.${USER:-$LOGNAME}.$$.err + trap "rm -f $tmp" EXIT + case `MACOSX_DEPLOYMENT_TARGET=10.3 ld -undefined dynamic_lookup 2>&1` in + *undefined*dynamic_lookup*) + ld -m -flat_namespace -undefined suppress -dylib -dynamic \ + -ldylib1.o "$@" -lcc_dynamic -framework System >$tmp 2>&1 + status=$? + ;; + *) MACOSX_DEPLOYMENT_TARGET=10.3 $CC -Wl,-flat_namespace -dynamiclib -undefined dynamic_lookup "$@" >$tmp 2>&1 + status=$? + ;; + esac + egrep -v ' (warning .*multiple definitions|definition) of ' $tmp >&2 + exit $status + ;; +ld) tmp=/tmp/cc.${USER:-$LOGNAME}.$$.err + trap "rm -f $tmp" EXIT + $CC -Wl,-m -DCLK_TCK=100 "$@" >$tmp 2>&1 + status=$? + egrep -v ' (warning .*multiple definitions of|definition of|as lazy binding|not from earlier dynamic) ' $tmp >&2 + exit $status + ;; +esac diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index ca116b56d..1a7ca4ac3 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -2394,8 +2394,8 @@ int main() esac case $lhs in bsdi) lhs=bsd ;; - darwin) case $rel in - [01234567].*) lhs=${lhs}7 ;; + darwin) case $(/usr/bin/cc --version) in + *'(GCC)'*) lhs=${lhs}_old ;; esac ;; freebsd) case $rel in