Skip to content

Commit c34acc5

Browse files
kesmit13claude
andcommitted
Recognize .abi3.so native extensions in linker scanner
The directory scanner in prelink.rs only matched native WASM extensions ending in .cpython-314-wasm32-wasi.so, ignoring stable-ABI extensions (.abi3.so) even though CPython's EXTENSION_SUFFIXES includes them. This adds .abi3.so to the set of recognized suffixes and validates candidates with a WASM magic byte check to avoid accidentally treating native (ELF) .abi3.so files as WASM modules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 43fddde commit c34acc5

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/prelink.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ use zstd::Decoder;
1616

1717
use crate::{ComponentizePyConfig, ConfigContext, Library, RawComponentizePyConfig};
1818

19-
static NATIVE_EXTENSION_SUFFIX: &str = ".cpython-314-wasm32-wasi.so";
19+
static NATIVE_EXTENSION_SUFFIXES: &[&str] = &[
20+
".cpython-314-wasm32-wasi.so",
21+
".abi3.so",
22+
];
23+
24+
/// Check if a file starts with the WASM magic bytes (`\0asm`).
25+
fn is_wasm_file(path: &Path) -> bool {
26+
fs::read(path)
27+
.map(|bytes| bytes.starts_with(b"\0asm"))
28+
.unwrap_or(false)
29+
}
2030

2131
type ConfigsMatchedWorlds<'a> =
2232
IndexMap<String, (ConfigContext<ComponentizePyConfig>, Option<&'a str>)>;
@@ -235,7 +245,9 @@ fn search_directory(
235245
search_directory(root, &entry?.path(), libraries, configs, modules_seen)?;
236246
}
237247
} else if let Some(name) = path.file_name().and_then(|name| name.to_str()) {
238-
if name.ends_with(NATIVE_EXTENSION_SUFFIX) {
248+
if NATIVE_EXTENSION_SUFFIXES.iter().any(|suffix| name.ends_with(suffix))
249+
&& is_wasm_file(path)
250+
{
239251
libraries.push(path.to_owned());
240252
} else if name == "componentize-py.toml" {
241253
let root = root

0 commit comments

Comments
 (0)