GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ARCHFLAGS does not properly override ‑arch in sysconfig.get_config_vars() values since Python 3.13 · Issue #161805 · python/cpython

ARCHFLAGS does not properly override ‑arch in sysconfig.get_config_vars() values since Python 3.13 #161805

New issue
Copy link
New issue
Copy link
Open
Open
ARCHFLAGS does not properly override ‑arch in sysconfig.get_config_vars() values since Python 3.13#161805
Copy link
Assignees
ned-deily
Labels
buildThe build process and cross-buildThe build process and cross-buildtopic-sysconfigtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@jmarshall
jmarshall
opened on Nov 11, 2026
Issue body actions

Bug report

On macOS, various adjustments are made to sysconfig.get_config_vars() values via Lib/_osx_support.py. In particular, if $ARCHFLAGS is set in the environment, any -arch XYZ options are removed from CFLAGS and similar entries and are replaced by the value of $ARCHFLAGS.

For example, with Python 3.9 (the macOS system Python, one of the few non-brew hence universal2 Pythons I have locally installed):

$ python3.9 -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'
-Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -Wno-error=unused-but-set-variable -Wno-error=cast-function-type-mismatch -Wno-unknown-warning-option

ARCHFLAGS='-arch foo' python3.9 -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'
-Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers   -Werror=implicit-function-declaration -Wno-error=unreachable-code -Wno-error=unused-but-set-variable -Wno-error=cast-function-type-mismatch -Wno-unknown-warning-option -arch foo

Notice that -arch arm64 -arch x86_64 has been removed in the middle (leaving several adjacent spaces where they were removed) and -arch foo has been appended.

With Python 3.13 installed from python.org, we get:

$ python3.13 -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'
-fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64

$ ARCHFLAGS='-arch foo' python3.13 -c 'import sysconfig; print(sysconfig.get_config_var("CFLAGS"))'
-fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall  -arch x86_64 -arch foo

Notice that -arch arm64 has been removed (leaving two adjacent spaces marking the location) but -arch x86_64 was not removed, and -arch foo has been appended.

Cibuildwheel sets ARCHFLAGS to build single-architecture wheels on a universal2 Python. Runs such as this pysam wheel build (see the macOS jobs in particular) exercise this functionality on a variety of Python versions. They show the -arch flags being modified correctly on versions up to 3.12, but incorrectly on 3.13, 3.14, and 3.15.

Up to version 3.12 the original CFLAGS value has these -arch options in the middle of the string. From version 3.13 onwards, the original CFLAGS value has them at the end of the string, and the last one (right at the end of the string) should be removed but is not.

CPython versions tested on:

3.13, 3.14, 3.15 releases, CPython main branch

Operating systems tested on:

macOS

Activity

  1. jmarshall
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 11, 2026
  2. jmarshall commented on Nov 11, 2026

    @jmarshall
    jmarshall
    on Nov 11, 2026
    ContributorAuthor
    More actions

    This has been tested on macOS on 3.13, 3.14, and 3.15 (and observed to be working correctly on 3.12 and prior), and the same code bug has been observed on the main branch.

    This is caused by the regexes in Lib/_osx_support.py:

    cpython/Lib/_osx_support.py

    Lines 315 to 327 in de9a4fb

    def _override_all_archs(_config_vars):
    """Allow override of all archs with ARCHFLAGS env var"""
    # NOTE: This name was introduced by Apple in OSX 10.5 and
    # is used by several scripting languages distributed with
    # that OS release.
    if 'ARCHFLAGS' in os.environ:
    arch = os.environ['ARCHFLAGS']
    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 = flags + ' ' + arch
    _save_modified_value(_config_vars, cv, flags)

    Notice the regex on line 325 ends in \s so requires whitespace after the -arch option and its argument. Thus it matches these ‑arch XYZ options within the string but not at the end of the string.

    There are several other similar regexes in Lib/_osx_support.py with similar problems.

  3. picnixz
    added
    buildThe build process and cross-buildThe build process and cross-build
    topic-sysconfig
    on Nov 11, 2026
  4. picnixz commented on Nov 11, 2026

    @picnixz
    picnixz
    on Nov 11, 2026
    Member
    More actions

    cc @ned-deily

  5. jmarshall
    changed the title [-]ARCHFLAGS does not properly override ‑arch since Python 3.13[/-] [+]ARCHFLAGS does not properly override ‑arch in sysconfig.get_config_vars() values since Python 3.13[/+] on Nov 11, 2026
  6. ned-deily
    self-assigned this
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ned-deily
    ned-deily

Labels

buildThe build process and cross-buildThe build process and cross-buildtopic-sysconfigtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.