Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/_osx_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def _remove_universal_flags(_config_vars):
# Do not alter a config var explicitly overridden by env var
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub(r'-arch\s+\w+\s', ' ', flags, flags=re.ASCII)
flags = re.sub(r'-arch\s+\S+', '', flags, flags=re.ASCII)
flags = re.sub(r'-isysroot\s*\S+', ' ', flags)
_save_modified_value(_config_vars, cv, flags)

Expand Down Expand Up @@ -306,7 +306,7 @@ def _remove_unsupported_archs(_config_vars):
for cv in _UNIVERSAL_CONFIG_VARS:
if cv in _config_vars and cv not in os.environ:
flags = _config_vars[cv]
flags = re.sub(r'-arch\s+ppc\w*\s', ' ', flags)
flags = re.sub(r'-arch\s+ppc\S*', '', flags)
_save_modified_value(_config_vars, cv, flags)

return _config_vars
Expand All @@ -322,7 +322,7 @@ def _override_all_archs(_config_vars):
for cv in _UNIVERSAL_CONFIG_VARS:
if cv in _config_vars and '-arch' in _config_vars[cv]:
flags = _config_vars[cv]
flags = re.sub(r'-arch\s+\w+\s', ' ', flags)
flags = re.sub(r'-arch\s+\S+', '', flags)
flags = flags + ' ' + arch
_save_modified_value(_config_vars, cv, flags)

Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test__osx_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test__find_appropriate_compiler(self):
def test__remove_universal_flags(self):
config_vars = {
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ',
'BASECFLAGS': '-O3 -arch i386 -arch ppc',
'LDFLAGS': '-arch ppc -arch i386 -g',
'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk',
'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g',
Expand All @@ -163,6 +164,7 @@ def test__remove_universal_flags(self):
}
expected_vars = {
'CFLAGS': '-fno-strict-aliasing -g -O3 ',
'BASECFLAGS': '-O3 ',
'LDFLAGS': ' -g',
'CPPFLAGS': '-I. ',
'BLDSHARED': 'gcc-4.0 -bundle -g',
Expand Down Expand Up @@ -201,6 +203,7 @@ def test__remove_unsupported_archs(self):
config_vars = {
'CC': 'clang',
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ',
'BASECFLAGS': '-O3 -arch i386 -arch ppc64',
'LDFLAGS': '-arch ppc -arch i386 -g',
'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk',
'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g',
Expand All @@ -210,6 +213,7 @@ def test__remove_unsupported_archs(self):
expected_vars = {
'CC': 'clang',
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch i386 ',
'BASECFLAGS': '-O3 -arch i386 ',
'LDFLAGS': ' -arch i386 -g',
'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk',
'BLDSHARED': 'gcc-4.0 -bundle -arch i386 -g',
Expand All @@ -236,6 +240,7 @@ def test__override_all_archs(self):
config_vars = {
'CC': 'clang',
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch ppc -arch i386 ',
'BASECFLAGS': '-O3 -arch i386 -arch ppc',
'LDFLAGS': '-arch ppc -arch i386 -g',
'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk',
'BLDSHARED': 'gcc-4.0 -bundle -arch ppc -arch i386 -g',
Expand All @@ -245,6 +250,7 @@ def test__override_all_archs(self):
expected_vars = {
'CC': 'clang',
'CFLAGS': '-fno-strict-aliasing -g -O3 -arch x86_64',
'BASECFLAGS': '-O3 -arch x86_64',
'LDFLAGS': ' -g -arch x86_64',
'CPPFLAGS': '-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk',
'BLDSHARED': 'gcc-4.0 -bundle -g -arch x86_64',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`sysconfig.get_config_vars` so that it adjusts ``-arch`` options
on macOS even when they appear at the very end of ``CFLAGS`` et al.
Loading