Skip to content

Commit 3283d91

Browse files
committed
Ensure internal FreeType uses same compiler as Python
Otherwise, mixed compilers might break things when compiled together into the extension. Fixes #21202
1 parent 18bfee3 commit 3283d91

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

setupext.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,16 @@ def do_custom_build(self, env):
605605
if (src_path / 'objs' / '.libs' / libfreetype).is_file():
606606
return # Bail out because we have already built FreeType.
607607

608+
cc = get_ccompiler()
609+
608610
print(f"Building freetype in {src_path}")
609611
if sys.platform != 'win32': # compilation on non-windows
610-
env = {**env, "CFLAGS": "{} -fPIC".format(env.get("CFLAGS", ""))}
612+
env = {
613+
**env,
614+
"CC": (shlex.join(cc.compiler) if sys.version_info >= (3, 8)
615+
else " ".join(shlex.quote(x) for x in cc.compiler)),
616+
"CFLAGS": "{} -fPIC".format(env.get("CFLAGS", "")),
617+
}
611618
subprocess.check_call(
612619
["./configure", "--with-zlib=no", "--with-bzip2=no",
613620
"--with-png=no", "--with-harfbuzz=no", "--enable-static",
@@ -660,7 +667,6 @@ def do_custom_build(self, env):
660667
f.truncate()
661668
f.write(vcxproj)
662669

663-
cc = get_ccompiler()
664670
cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
665671
cc.spawn(["msbuild", str(sln_path),
666672
"/t:Clean;Build",

0 commit comments

Comments
 (0)