Skip to content

Commit af7fcbb

Browse files
thesamesamjaraco
authored andcommitted
Use CFLAGS if set as-is, match CXXFLAGS behavior
Since 2c93711, CXXFLAGS is used as-is if set in the envionment rather than clobbered by whatever CPython happened to be built with. Do the same for CFLAGS: use it as-is if set in the environment, don't prepend CPython's saved flags. Fixes: #299
1 parent a8eec20 commit af7fcbb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

distutils/sysconfig.py

+1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def customize_compiler(compiler):
340340

341341
ldshared = _add_flags(ldshared, 'LD')
342342
ldcxxshared = _add_flags(ldcxxshared, 'LD')
343+
cflags = os.environ.get('CFLAGS', cflags)
343344
cflags = _add_flags(cflags, 'C')
344345
ldshared = _add_flags(ldshared, 'C')
345346
cxxflags = os.environ.get('CXXFLAGS', cxxflags)

distutils/tests/test_sysconfig.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def test_customize_compiler(self):
130130
comp = self.customize_compiler()
131131
assert comp.exes['archiver'] == 'env_ar --env-arflags'
132132
assert comp.exes['preprocessor'] == 'env_cpp --env-cppflags'
133-
assert comp.exes['compiler'] == 'env_cc --sc-cflags --env-cflags --env-cppflags'
133+
assert comp.exes['compiler'] == 'env_cc --env-cflags --env-cflags --env-cppflags'
134134
assert comp.exes['compiler_so'] == (
135-
'env_cc --sc-cflags --env-cflags --env-cppflags --sc-ccshared'
135+
'env_cc --env-cflags --env-cflags --env-cppflags --sc-ccshared'
136136
)
137137
assert (
138138
comp.exes['compiler_cxx']

0 commit comments

Comments
 (0)