pypy3-exe: Add patch to not override CC

pypy3's build probes for `gcc` and overrides the CC variable if found in
some cases. We don't ever want that in our build, so change its behavior
to only set CC if it is otherwise unset.

BUG=chromium:1114277
TEST=`emerge pypy3-exe`

Change-Id: I21bab95fe31416251694e05ff615108d137f30b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2399423
Tested-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-no-override-CC.patch b/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-no-override-CC.patch
new file mode 100644
index 0000000..ed5294e
--- /dev/null
+++ b/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-no-override-CC.patch
@@ -0,0 +1,13 @@
+diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py b/rpython/rtyper/lltypesystem/ll2ctypes.py
+index 33853fc..5cf48c1 100644
+--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
++++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
+@@ -1181,7 +1181,7 @@ if sys.platform == 'darwin':
+         expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
+         fdout, ccout = tempfile.mkstemp()
+         os.close(fdout)
+-        cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; else CC=cc; fi;' \
++        cmd = 'if type gcc >/dev/null 2>&1; then : ${CC:=gcc}; else : ${CC:=cc}; fi;' \
+               '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
+         try:
+             f = os.popen(cmd)
diff --git a/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild b/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild
index 8d56f96..47796f6 100644
--- a/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild
+++ b/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild
@@ -40,6 +40,7 @@
 
 PATCHES=(
 	"${FILESDIR}/pypy3-exe-7.3.1-respect-pkg-config.patch"
+	"${FILESDIR}/pypy3-exe-7.3.1-no-override-CC.patch"
 )
 
 check_env() {
@@ -136,7 +137,7 @@
 	# translate into the C sources
 	# we're going to make them ourselves since otherwise pypy does not
 	# free up the unneeded memory before spawning the compiler
-	set -- "${interp[@]}" rpython/bin/rpython --batch --source "${args[@]}"
+	set -- "${interp[@]}" rpython/bin/rpython --batch --source --cc="${CC}" "${args[@]}"
 	echo -e "\033[1m${@}\033[0m"
 	"${@}" || die "translation failed"
 }