From 203c5de8a68bb8c22fa06c6c516b7617a1a056f2 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 1 Oct 2021 19:01:54 -0400 Subject: [PATCH 1/2] Ensure internal FreeType uses same compiler as Python Otherwise, mixed compilers might break things when compiled together into the extension. Fixes #21202 --- setupext.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/setupext.py b/setupext.py index 0d85f479d106..c6f9d82804ba 100644 --- a/setupext.py +++ b/setupext.py @@ -605,9 +605,16 @@ def do_custom_build(self, env): if (src_path / 'objs' / '.libs' / libfreetype).is_file(): return # Bail out because we have already built FreeType. + cc = get_ccompiler() + print(f"Building freetype in {src_path}") if sys.platform != 'win32': # compilation on non-windows - env = {**env, "CFLAGS": "{} -fPIC".format(env.get("CFLAGS", ""))} + env = { + **env, + "CC": (shlex.join(cc.compiler) if sys.version_info >= (3, 8) + else " ".join(shlex.quote(x) for x in cc.compiler)), + "CFLAGS": "{} -fPIC".format(env.get("CFLAGS", "")), + } subprocess.check_call( ["./configure", "--with-zlib=no", "--with-bzip2=no", "--with-png=no", "--with-harfbuzz=no", "--enable-static", @@ -660,7 +667,6 @@ def do_custom_build(self, env): f.truncate() f.write(vcxproj) - cc = get_ccompiler() cc.initialize() # Get msbuild in the %PATH% of cc.spawn. cc.spawn(["msbuild", str(sln_path), "/t:Clean;Build", From 76f1516736b0de6f3dfbd644a19b0b01e0298856 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 1 Oct 2021 19:09:12 -0400 Subject: [PATCH 2/2] Use same host triplet for internal FreeType as Python This should fix 32-bit compiles on a 64-bit system, as in #18113, but I could never get a working 32-bit Python to test. --- setupext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setupext.py b/setupext.py index c6f9d82804ba..80cce3ade3fa 100644 --- a/setupext.py +++ b/setupext.py @@ -618,7 +618,8 @@ def do_custom_build(self, env): subprocess.check_call( ["./configure", "--with-zlib=no", "--with-bzip2=no", "--with-png=no", "--with-harfbuzz=no", "--enable-static", - "--disable-shared"], + "--disable-shared", + "--host=" + sysconfig.get_config_var('BUILD_GNU_TYPE')], env=env, cwd=src_path) if 'GNUMAKE' in env: make = env['GNUMAKE']