Skip to content
Draft
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
588 changes: 167 additions & 421 deletions cpython.BUILD.bazel

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions docs/configure-check-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ Run `tools/configure_check_audit.sh` to regenerate this file. CI runs `tools/con
| [x] | `_POSIX_THREADS` | `UNSUPPORTED_PLATFORM` | L4097, L4099, L4103, L4160 | L4411, L4413, L4417, L4474 | L4631, L4633, L4634, L4690 | L4693, L4695, L4696, L4752 | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | The symbol belongs to a platform outside the supported Linux and Darwin arm64 and x86_64 targets. |
| [x] | `_PYTHONFRAMEWORK` | `AUTOCONF_PRODUCER` | L526 | L530 | L695 | L718 | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | `""` | Produced by rules_cc_autoconf in every applicable generated configuration. |
| [x] | `_PYTHREAD_NAME_MAXLEN` | `PLATFORM_SPECIFIC_TARGET_FACT` | — | — | — | L7729, L7730, L7731, L7732, +7 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | `63` | `63` | `15` | `15` | CPython 3.14 uses 15 on Linux and 63 on Darwin. |
| [x] | `_Py_FFI_SUPPORT_C_COMPLEX` | `DEPENDENCY_CONTRACT` | — | — | — | L4202 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | `1` | `1` | `1` | `1` | The pinned libffi build passes libffi_complex_test on every supported POSIX target. |
| [x] | `_Py_FFI_SUPPORT_C_COMPLEX` | `DEPENDENCY_CONTRACT` | — | — | — | L4202 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | `1` | `1` | `1` | `1` | The pinned hermetic libffi build provides ffi_type_complex_double on every supported POSIX target. |
| [x] | `_Py_HACL_CAN_COMPILE_VEC128` | `FIXED_BUILD_POLICY` | — | — | — | L8057 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | The Bazel HACL target compiles CPython 3.14's scalar HACL sources only. |
| [x] | `_Py_HACL_CAN_COMPILE_VEC256` | `FIXED_BUILD_POLICY` | — | — | — | L8089 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | undefined (no producer) | undefined (no producer) | undefined (no producer) | undefined (no producer) | The Bazel HACL target compiles CPython 3.14's scalar HACL sources only. |
| [x] | `_Py_STACK_GROWS_DOWN` | `FIXED_TARGET_FACT` | — | — | — | L1207, L1208, L1209, L1211 | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | not in header | `1` | `1` | `1` | `1` | The stack grows downward on every supported POSIX target. |
Expand Down Expand Up @@ -757,7 +757,6 @@ These decisions are maintained explicitly because they do not emit `pyconfig.h.i
| `xz_dependency` | `DEPENDENCY_CONTRACT` | The _lzma module depends on the pinned xz Bazel module. | Header and function results are dependency contracts rather than host discovery. |
| `libffi_dependency` | `DEPENDENCY_CONTRACT` | The _ctypes module depends on the pinned hermetic libffi build. | ffi_prep_cif_var, ffi_prep_closure_loc, and ffi_closure_alloc follow that dependency. |
| `cpython_3_11_libffi_features` | `DEPENDENCY_CONTRACT` | cpython_static_module_manifest adds HAVE_FFI_CLOSURE_ALLOC, HAVE_FFI_PREP_CIF_VAR, and HAVE_FFI_PREP_CLOSURE_LOC only to the CPython 3.11 _ctypes target. | CPython 3.11 does not expose these extension-specific definitions through pyconfig.h.in. |
| `cpython_3_14_libffi_complex` | `DEPENDENCY_CONTRACT` | libffi_complex_test performs ffi_prep_cif and ffi_call with ffi_type_complex_double on every supported POSIX target. | The test reproduces CPython 3.14's runtime validation for _Py_FFI_SUPPORT_C_COMPLEX. |
| `openssl_dependency` | `DEPENDENCY_CONTRACT` | The _ssl and _hashlib modules depend on the pinned OpenSSL Bazel module. | OpenSSL configuration does not inspect host libraries. |
| `sqlite_dependency` | `DEPENDENCY_CONTRACT` | The _sqlite3 module depends on the pinned SQLite Bazel module. | PY_SQLITE_HAVE_SERIALIZE follows the pinned SQLite build; extension loading remains disabled. |
| `unsupported_optional_dependencies` | `UNSUPPORTED_DEPENDENCY` | readline, curses, panel, gdbm, ndbm, uuid, Tcl/Tk, editline, crypt, zstd, and external libintl symbols have explicit undefined dispositions. | The Bazel module does not declare those optional dependency graphs or modules. |
Expand Down
70 changes: 30 additions & 40 deletions libffi.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,42 @@ config_setting(

libffi_config(name = "libffi_config")

# configure.host selects sysv.S for arm64 on Darwin, Linux, and clang-cl Windows.
ARM64_SOURCES = [
"src/aarch64/ffi.c",
"src/aarch64/sysv.S",
]

POSIX_X86_64_SOURCES = [
"src/x86/ffi64.c",
"src/x86/ffiw64.c",
"src/x86/unix64.S",
"src/x86/win64.S",
]

LIBFFI_TARGET_COMPATIBILITY = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}) + select({
":arm64": [],
":x86_64": [],
"//conditions:default": ["@platforms//:incompatible"],
})

cc_library(
name = "libffi",
copts = select({
":windows_arm64": [],
":windows_x86_64": [],
"@platforms//os:windows": [],
"//conditions:default": ["-fexceptions"],
}),
defines = select({
":windows_arm64": ["FFI_STATIC_BUILD=1"],
":windows_x86_64": ["FFI_STATIC_BUILD=1"],
"@platforms//os:windows": ["FFI_STATIC_BUILD=1"],
"//conditions:default": [],
}),
features = select({
":windows_arm64": ["dynamic_link_msvcrt"],
":windows_x86_64": ["dynamic_link_msvcrt"],
"@platforms//os:windows": ["dynamic_link_msvcrt"],
"//conditions:default": [],
}),
srcs = [
Expand All @@ -90,31 +111,8 @@ cc_library(
"src/tramp.c",
"src/types.c",
] + select({
":darwin_arm64": [
"src/aarch64/ffi.c",
"src/aarch64/sysv.S",
],
":darwin_x86_64": [
"src/x86/ffi64.c",
"src/x86/ffiw64.c",
"src/x86/unix64.S",
"src/x86/win64.S",
],
":linux_arm64": [
"src/aarch64/ffi.c",
"src/aarch64/sysv.S",
],
":linux_x86_64": [
"src/x86/ffi64.c",
"src/x86/ffiw64.c",
"src/x86/unix64.S",
"src/x86/win64.S",
],
":windows_arm64": [
# configure.host classifies clang-cl as Clang and selects sysv.S.
"src/aarch64/ffi.c",
"src/aarch64/sysv.S",
],
":arm64": ARM64_SOURCES,
":x86_64": POSIX_X86_64_SOURCES,
":windows_x86_64": [
# configure.host classifies clang-cl as Clang and selects win64.S.
"src/x86/ffiw64.c",
Expand Down Expand Up @@ -148,14 +146,6 @@ cc_library(
":arm64": ["src/aarch64"],
":x86_64": ["src/x86"],
}),
target_compatible_with = select({
":darwin_arm64": [],
":darwin_x86_64": [],
":linux_arm64": [],
":linux_x86_64": [],
":windows_arm64": [],
":windows_x86_64": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
target_compatible_with = LIBFFI_TARGET_COMPATIBILITY,
textual_hdrs = ["src/dlmalloc.c"],
)
63 changes: 23 additions & 40 deletions python/private/install_tree.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,57 +102,40 @@ def cpython_install_tree(
],
exclude = _INSTALL_ONLY_STDLIB_EXCLUDES,
) + [pyconfig]
posix_sources = [
python,
sysconfig_data,
"LICENSE",
":_install_tree_posix_marker",
]
windows_sources = [
python,
pythonw,
windows_license,
":_install_tree_windows_marker",
] + (
windows_core_libraries +
windows_runtime_libraries +
windows_venv_launchers +
_extension_labels(extensions.install_only_windows)
)

copy_to_directory(
name = "install_tree",
srcs = common_sources + install_metadata + select({
":darwin_arm64": [
python,
sysconfig_data,
"LICENSE",
":_install_tree_posix_marker",
] + _extension_labels(extensions.install_only_darwin_arm64),
":darwin_x86_64": [
python,
sysconfig_data,
"LICENSE",
":_install_tree_posix_marker",
] + _extension_labels(extensions.install_only_darwin_x86_64),
":linux_arm64": [
python,
sysconfig_data,
"LICENSE",
":_install_tree_posix_marker",
] + _extension_labels(extensions.install_only_linux_arm64),
":linux_x86_64": [
python,
sysconfig_data,
"LICENSE",
":_install_tree_posix_marker",
] + _extension_labels(extensions.install_only_linux_x86_64),
":windows_arm64": [
python,
pythonw,
windows_license,
":_install_tree_windows_marker",
] + windows_core_libraries + windows_runtime_libraries + windows_venv_launchers + _extension_labels(extensions.install_only_windows),
":windows_x86_64": [
python,
pythonw,
windows_license,
":_install_tree_windows_marker",
] + windows_core_libraries + windows_runtime_libraries + windows_venv_launchers + _extension_labels(extensions.install_only_windows),
"@platforms//os:macos": posix_sources + _extension_labels(extensions.install_only_darwin),
":linux_arm64": posix_sources + _extension_labels(extensions.install_only_linux_arm64),
":linux_x86_64": posix_sources + _extension_labels(extensions.install_only_linux_x86_64),
"@platforms//os:windows": windows_sources,
}),
out = "install",
hardlink = "off",
include_external_repositories = ["*msvc_runtime*"],
replace_prefixes = select({
":darwin_arm64": _posix_replacements(version, extensions.install_only_darwin_arm64),
":darwin_x86_64": _posix_replacements(version, extensions.install_only_darwin_x86_64),
"@platforms//os:macos": _posix_replacements(version, extensions.install_only_darwin),
":linux_arm64": _posix_replacements(version, extensions.install_only_linux_arm64),
":linux_x86_64": _posix_replacements(version, extensions.install_only_linux_x86_64),
":windows_arm64": _windows_replacements(version, extensions.install_only_windows),
":windows_x86_64": _windows_replacements(version, extensions.install_only_windows),
"@platforms//os:windows": _windows_replacements(version, extensions.install_only_windows),
}),
root_paths = [
".",
Expand Down
6 changes: 0 additions & 6 deletions python/private/libffi/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
exports_files([
"call_test.c",
"closure_test.c",
"complex_test.c",
"seh_test.c",
])
30 changes: 0 additions & 30 deletions python/private/libffi/call_test.c

This file was deleted.

54 changes: 0 additions & 54 deletions python/private/libffi/closure_test.c

This file was deleted.

25 changes: 0 additions & 25 deletions python/private/libffi/complex_test.c

This file was deleted.

49 changes: 0 additions & 49 deletions python/private/libffi/seh_test.c

This file was deleted.

7 changes: 3 additions & 4 deletions python/private/pyconfig.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ def pyconfig(name, version, windows_pyconfig_template = False):
windows_header = ":" + name + "_windows"
copy_file(
name = name + "_windows",
allow_symlink = True,
src = "PC/pyconfig.h.in",
out = "PC/pyconfig.h",
)
Expand Down Expand Up @@ -1346,8 +1347,7 @@ def pyconfig(name, version, windows_pyconfig_template = False):
target_policy_checks = select({
"//:darwin_arm64": _darwin_policy_checks(version, 1 if version in ["3.13", "3.14"] else 2),
"//:darwin_x86_64": _darwin_policy_checks(version, 1),
"//:linux_arm64": _linux_policy_checks(version),
"//:linux_x86_64": _linux_policy_checks(version),
"@platforms//os:linux": _linux_policy_checks(version),
})

autoconf(
Expand Down Expand Up @@ -1393,8 +1393,7 @@ def pyconfig(name, version, windows_pyconfig_template = False):
native.alias(
name = name,
actual = select({
"//:windows_arm64": windows_header,
"//:windows_x86_64": windows_header,
"@platforms//os:windows": windows_header,
"//conditions:default": ":" + name + "_posix",
}),
)
Loading
Loading