Skip to content

gh-155813: Stop overwriting LIBFFI_CFLAGS and LIBFFI_LIBS on macOS - #156486

Merged
freakboy3742 merged 1 commit into
python:mainfrom
advitrocks9:build/darwin-libffi-override
Oct 21, 2026
Merged

freakboy3742 merged 1 commit into
python:mainfrom
advitrocks9:build/darwin-libffi-override

Conversation

@advitrocks9

@advitrocks9 advitrocks9 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

On macOS, configure sets LIBFFI_CFLAGS and LIBFFI_LIBS from the SDK before the pkg-config
check, so values passed on the command line are ignored. Doc/using/configure.rst documents both
as overrides. This uses the same preserve-if-set form as the pkg-config fallback and the libuuid
probe.

Configuring with LIBFFI_CFLAGS=-I/nonexistent/include/ffi LIBFFI_LIBS="-L/nonexistent/lib -lffi",
the Makefile currently ends up with the SDK paths:

MODULE__CTYPES_CFLAGS=-fno-strict-overflow -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1 -DUSING_MALLOC_CLOSURE_DOT_C=1
MODULE__CTYPES_LDFLAGS=-lffi -ldl

and with this change keeps the given values:

MODULE__CTYPES_CFLAGS=-fno-strict-overflow -I/nonexistent/include/ffi -DUSING_MALLOC_CLOSURE_DOT_C=1
MODULE__CTYPES_LDFLAGS=-L/nonexistent/lib -lffi -ldl

With no overrides the output is unchanged. USING_APPLE_OS_LIBFFI drops out when overriding
since it guards Apple-libffi code in _ctypes. iOS sets a different ac_sys_system and is
unaffected. The other documented *_CFLAGS/*_LIBS pairs already preserve user values.

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense - thanks for the patch!

@freakboy3742
freakboy3742 merged commit 6839f8c into python:main Oct 21, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @advitrocks9 for the PR, and @freakboy3742 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 21, 2026

Copy link
Copy Markdown

GH-160129 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 21, 2026
@bedevere-app

bedevere-app Bot commented Oct 21, 2026

Copy link
Copy Markdown

GH-160130 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 21, 2026
freakboy3742 pushed a commit that referenced this pull request Oct 21, 2026
…acOS (GH-156486) (#160130)

Ensures that a user-specified LIBFFI_CFLAGS and LIBFFI_LIBS is honored when
building on macOS.
(cherry picked from commit 6839f8c)

Co-authored-by: Advit Arora <[email protected]>
freakboy3742 pushed a commit that referenced this pull request Oct 21, 2026
…acOS (GH-156486) (#160129)

Ensures that a user-specified LIBFFI_CFLAGS and LIBFFI_LIBS is honored when
building on macOS.
(cherry picked from commit 6839f8c)

Co-authored-by: Advit Arora <[email protected]>
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD16 3.15 (tier-3) has failed when building commit 56c0185.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/2103/builds/220) and take a look at the build logs.
  4. Check if the failure is related to this commit (56c0185) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/2103/builds/220

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.15.opsec-fbsd16/build/Lib/test/support/__init__.py", line 949, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('127.0.0.1', 23055), raddr=('127.0.0.1', 47683)>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _SelectorTransport.__del__ at 0x8c6301abe90>:
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.15.opsec-fbsd16/build/Lib/asyncio/selector_events.py", line 879, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: unclosed transport <_SelectorSocketTransport closing fd=8>
k


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.15.opsec-fbsd16/build/Lib/test/support/__init__.py", line 949, in gc_collect
    gc.collect()
    ~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket fd=8, family=2, type=1, proto=6, laddr=('127.0.0.1', 58229), raddr=('127.0.0.1', 23622)>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _SelectorTransport.__del__ at 0x34b28ecb6510>:
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.15.opsec-fbsd16/build/Lib/asyncio/selector_events.py", line 879, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: unclosed transport <_SelectorSocketTransport closing fd=8>
k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants