Skip to content

Commit

Permalink
Use CFLAGS if set as-is, match CXXFLAGS behavior
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thesamesam authored and jaraco committed Dec 27, 2024
1 parent a8eec20 commit af7fcbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def customize_compiler(compiler):

ldshared = _add_flags(ldshared, 'LD')
ldcxxshared = _add_flags(ldcxxshared, 'LD')
cflags = os.environ.get('CFLAGS', cflags)
cflags = _add_flags(cflags, 'C')
ldshared = _add_flags(ldshared, 'C')
cxxflags = os.environ.get('CXXFLAGS', cxxflags)
Expand Down
4 changes: 2 additions & 2 deletions distutils/tests/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def test_customize_compiler(self):
comp = self.customize_compiler()
assert comp.exes['archiver'] == 'env_ar --env-arflags'
assert comp.exes['preprocessor'] == 'env_cpp --env-cppflags'
assert comp.exes['compiler'] == 'env_cc --sc-cflags --env-cflags --env-cppflags'
assert comp.exes['compiler'] == 'env_cc --env-cflags --env-cflags --env-cppflags'
assert comp.exes['compiler_so'] == (
'env_cc --sc-cflags --env-cflags --env-cppflags --sc-ccshared'
'env_cc --env-cflags --env-cflags --env-cppflags --sc-ccshared'
)
assert (
comp.exes['compiler_cxx']
Expand Down

0 comments on commit af7fcbb

Please sign in to comment.