pypy3-exe: Add patch to respect system PKG_CONFIG

Our build environment requires the usage of wrapped pkg-config instances
corresponding to build targets. This patch allows the pypy3 build to
read the PKG_CONFIG environment variable to respect that requirement.

Upstream Gentoo PR: https://github.com/gentoo/gentoo/pull/17090

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

Change-Id: I946fc9db2cce74aaf5f8ac1f5748a8bad5cae98e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2343732
Commit-Queue: Chris McDonald <cjmcdonald@chromium.org>
Tested-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-respect-pkg-config.patch b/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-respect-pkg-config.patch
new file mode 100644
index 0000000..ca922bb
--- /dev/null
+++ b/dev-python/pypy3-exe/files/pypy3-exe-7.3.1-respect-pkg-config.patch
@@ -0,0 +1,14 @@
+diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py
+index d53449a..4463831 100644
+--- a/rpython/translator/platform/posix.py
++++ b/rpython/translator/platform/posix.py
+@@ -62,7 +62,8 @@ class BasePosix(Platform):
+ 
+     def _pkg_config(self, lib, opt, default, check_result_dir=False):
+         try:
+-            ret, out, err = _run_subprocess("pkg-config", [lib, opt])
++            pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
++            ret, out, err = _run_subprocess(pkg_config, [lib, opt])
+         except OSError as e:
+             err = str(e)
+             ret = 1
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 e652cdb..8d56f96 100644
--- a/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild
+++ b/dev-python/pypy3-exe/pypy3-exe-7.3.1.ebuild
@@ -38,6 +38,10 @@
 		)
 	)"
 
+PATCHES=(
+	"${FILESDIR}/pypy3-exe-7.3.1-respect-pkg-config.patch"
+)
+
 check_env() {
 	if use low-memory; then
 		CHECKREQS_MEMORY="1750M"
@@ -76,7 +80,7 @@
 }
 
 src_configure() {
-	tc-export CC
+	tc-export CC PKG_CONFIG
 
 	local jit_backend
 	if use jit; then