Commit c14d0372 authored by Christoph Reiter's avatar Christoph Reiter 🐍

ccompiler: don't use Python compiler flags. Fixes #150

Only use flags provided by env vars from the user and never from the
Python sysconfig. The sysconfig values depend on the way Python was built,
might conflict when using g-i with a different compiler and can't be controlled
by the g-i user.
parent 508ec4aa
Pipeline #48255 passed with stages
in 7 minutes and 1 second
......@@ -36,13 +36,13 @@ from . import utils
def customize_compiler(compiler):
"""This is a version of distutils.sysconfig.customize_compiler, without
any macOS specific bits.
any macOS specific bits and which tries to avoid using any Python specific
defaults if alternatives through env vars are given.
"""
if compiler.compiler_type == "unix":
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
(cc, cxx, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
if 'CC' in os.environ:
cc = os.environ['CC']
......@@ -57,8 +57,10 @@ def customize_compiler(compiler):
if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
cflags = os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
else:
cflags = ''
if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
......@@ -74,7 +76,7 @@ def customize_compiler(compiler):
compiler.set_executables(
preprocessor=cpp,
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared,
compiler_so=cc_cmd,
compiler_cxx=cxx,
linker_so=ldshared,
linker_exe=cc,
......
......@@ -191,7 +191,6 @@ class UnixCCompilerTest(unittest.TestCase):
args = self.preprocess_args()
self.assertIn('-I.', args)
@unittest.skip("Currently Python build time CPPFLAGS are included as well")
def test_preprocess_command(self):
""""Checks complete preprocessing command."""
args = self.preprocess_args(environ=dict(CPP='gcc -E'),
......@@ -199,7 +198,6 @@ class UnixCCompilerTest(unittest.TestCase):
self.assertEqual(['gcc', '-E', '-I.', '-C', '/tmp/file.c'],
args)
@unittest.skip("Currently Python build time CFLAGS and CPPFLAGS are included as well")
def test_compile_command(self):
"""Checks complete compilation command."""
args = self.compile_args(environ=dict(CC='clang'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment