Skip to content

Commit

Permalink
Scope libatomic allowance to MIPS on Python 3.13 (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Dec 7, 2024
1 parent 0ed9d38 commit b0070c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions cpython-unix/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"pthread",
"rt",
"util",
"atomic",
}
MACOS_ALLOW_SYSTEM_LIBRARIES = {"dl", "m", "pthread"}
MACOS_ALLOW_FRAMEWORKS = {"CoreFoundation"}
Expand Down Expand Up @@ -543,6 +542,13 @@ def python_build_info(

bi["object_file_format"] = object_file_format

# Determine allowed libaries on Linux
mips = target_triple.split("-")[0] in {"mips", "mipsel"}
linux_allowed_system_libraries = LINUX_ALLOW_SYSTEM_LIBRARIES.copy()
if mips and version == "3.13":
# See https://github.com/indygreg/python-build-standalone/issues/410
linux_allowed_system_libraries.add("atomic")

# Add in core linking annotations.
libs = extra_metadata["python_config_vars"].get("LIBS", "").split()
skip = False
Expand All @@ -554,7 +560,7 @@ def python_build_info(
if lib.startswith("-l"):
lib = lib[2:]

if platform == "linux64" and lib not in LINUX_ALLOW_SYSTEM_LIBRARIES:
if platform == "linux64" and lib not in linux_allowed_system_libraries:
raise Exception("unexpected library in LIBS (%s): %s" % (libs, lib))
elif platform == "macos" and lib not in MACOS_ALLOW_SYSTEM_LIBRARIES:
raise Exception("unexpected library in LIBS (%s): %s" % (libs, lib))
Expand Down
8 changes: 5 additions & 3 deletions src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const ELF_ALLOWED_LIBRARIES: &[&str] = &[
"libpthread.so.0",
"librt.so.1",
"libutil.so.1",
"libatomic.so.1",
];

const PE_ALLOWED_LIBRARIES: &[&str] = &[
Expand Down Expand Up @@ -223,8 +222,11 @@ static ELF_ALLOWED_LIBRARIES_BY_TRIPLE: Lazy<HashMap<&'static str, Vec<&'static
vec!["ld-linux-armhf.so.3", "libgcc_s.so.1"],
),
("i686-unknown-linux-gnu", vec!["ld-linux-x86-64.so.2"]),
("mips-unknown-linux-gnu", vec!["ld.so.1"]),
("mipsel-unknown-linux-gnu", vec!["ld.so.1"]),
("mips-unknown-linux-gnu", vec!["ld.so.1", "libatomic.so.1"]),
(
"mipsel-unknown-linux-gnu",
vec!["ld.so.1", "libatomic.so.1"],
),
("mips64el-unknown-linux-gnuabi64", vec![]),
("ppc64le-unknown-linux-gnu", vec!["ld64.so.1", "ld64.so.2"]),
("s390x-unknown-linux-gnu", vec!["ld64.so.1"]),
Expand Down

0 comments on commit b0070c6

Please sign in to comment.