Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abi3audit check for stable ABI violations to CI #6

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

nicholasjng
Copy link
Owner

Only applies to CPython>=3.12.

@nicholasjng nicholasjng self-assigned this Mar 6, 2024
@nicholasjng
Copy link
Owner Author

Nice, the wheel ABI tag comes out correct, and no ABI violations are found (although it would probably be hard to produce one with just the given example?).

@nicholasjng nicholasjng merged commit 97e3db2 into master Mar 6, 2024
16 checks passed
@nicholasjng nicholasjng deleted the stable-abi-builds branch March 6, 2024 10:33
@wjakob
Copy link

wjakob commented Mar 6, 2024

When compiling stable ABI wheels, are you passing Py_LIMITED_API? (Without that flag, nanobind will index into various version-specific data structures, but such a violation may not necessarily be found by an ABI audit that checks for the presence of disallowed symbols)

@nicholasjng
Copy link
Owner Author

I compile the nanobind .so with -DPy_LIMITED_API=0x030?0000, given via the selected ABI version here:

def pyversionhex():
return select({
"@nanobind_bazel//:cp312": ["Py_LIMITED_API=0x030C0000"],
"@nanobind_bazel//:cp313": ["Py_LIMITED_API=0x030D0000"],
"@nanobind_bazel//:pyunlimitedapi": [],
})

I pass that as a define to @nanobind//:nanobind here:

defines = pyversionhex(),

which by default propagates to consuming rules. I do not, however, define the Py_LIMITED_API macro in the setuptools.Extension, for example in your nanobind_example, but that should not be an issue, since setuptools' C++ toolchain is not used by Bazel.

Does that seem correct?

@wjakob
Copy link

wjakob commented Mar 6, 2024

The first part sounds good, the second part I don't understand. In the nanobind_example, it's cmake that produces the commands that will eventually compile and link code, hence it is the component responsible for setting these flags. I don't think setuptools does anything interesting here besides, perhaps, choosing the name of the final wheel.

@nicholasjng
Copy link
Owner Author

Sorry, I meant on the bazel branch which you allowed me to push, that contains a setuptools+Bazel approach (though it's very rough).

@wjakob
Copy link

wjakob commented Mar 6, 2024

got it, thanks!

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.

2 participants