Skip to content

Commit 545aebd

Browse files
authored
[3.10] bpo-45881: Use CC from env first for cross building (GH-29752). (GH-29753)
Co-authored-by: Christian Heimes <[email protected]>
1 parent 57100c8 commit 545aebd

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``setup.py`` now uses ``CC`` from environment first to discover multiarch
2+
and cross compile paths.

setup.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def get_platform():
8686
MACOS = (HOST_PLATFORM == 'darwin')
8787
AIX = (HOST_PLATFORM.startswith('aix'))
8888
VXWORKS = ('vxworks' in HOST_PLATFORM)
89+
CC = os.environ.get("CC")
90+
if not CC:
91+
CC = sysconfig.get_config_var("CC")
8992

9093

9194
SUMMARY = """
@@ -467,6 +470,9 @@ def set_compiler_executables(self):
467470

468471
def build_extensions(self):
469472
self.set_srcdir()
473+
self.set_compiler_executables()
474+
self.configure_compiler()
475+
self.init_inc_lib_dirs()
470476

471477
# Detect which modules should be compiled
472478
self.detect_modules()
@@ -476,7 +482,6 @@ def build_extensions(self):
476482

477483
self.update_sources_depends()
478484
mods_built, mods_disabled = self.remove_configured_extensions()
479-
self.set_compiler_executables()
480485

481486
if LIST_MODULE_NAMES:
482487
for ext in self.extensions:
@@ -662,12 +667,11 @@ def check_extension_import(self, ext):
662667
def add_multiarch_paths(self):
663668
# Debian/Ubuntu multiarch support.
664669
# https://wiki.ubuntu.com/MultiarchSpec
665-
cc = sysconfig.get_config_var('CC')
666670
tmpfile = os.path.join(self.build_temp, 'multiarch')
667671
if not os.path.exists(self.build_temp):
668672
os.makedirs(self.build_temp)
669673
ret = run_command(
670-
'%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
674+
'%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile))
671675
multiarch_path_component = ''
672676
try:
673677
if ret == 0:
@@ -729,11 +733,10 @@ def add_search_path(line):
729733
d = os.path.normpath(d)
730734
add_dir_to_list(self.compiler.library_dirs, d)
731735

732-
cc = sysconfig.get_config_var('CC')
733736
tmpfile = os.path.join(self.build_temp, 'wrccpaths')
734737
os.makedirs(self.build_temp, exist_ok=True)
735738
try:
736-
ret = run_command('%s --print-search-dirs >%s' % (cc, tmpfile))
739+
ret = run_command('%s --print-search-dirs >%s' % (CC, tmpfile))
737740
if ret:
738741
return
739742
with open(tmpfile) as fp:
@@ -751,11 +754,10 @@ def add_search_path(line):
751754
pass
752755

753756
def add_cross_compiling_paths(self):
754-
cc = sysconfig.get_config_var('CC')
755757
tmpfile = os.path.join(self.build_temp, 'ccpaths')
756758
if not os.path.exists(self.build_temp):
757759
os.makedirs(self.build_temp)
758-
ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
760+
ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (CC, tmpfile))
759761
is_gcc = False
760762
is_clang = False
761763
in_incdirs = False
@@ -1876,9 +1878,6 @@ def detect_uuid(self):
18761878
self.missing.append('_uuid')
18771879

18781880
def detect_modules(self):
1879-
self.configure_compiler()
1880-
self.init_inc_lib_dirs()
1881-
18821881
self.detect_simple_extensions()
18831882
if TEST_EXTENSIONS:
18841883
self.detect_test_extensions()

0 commit comments

Comments
 (0)