From 18e2fb1e780bcbb72d8bd66f9f78ca65cf399e6b Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Wed, 28 Jan 2026 10:14:15 -0500 Subject: [PATCH] fix(loader): account for `nm`/`ld` fix on newer powerpc linux toolchains Previously a bug in linux powerpc linkers/nm caused function symbols to be incorrectly reported in the data "D" section. Newer toolchains now correctly report these symbols' sections as "T". Account for both to maintain compatibility with older toolchains --- crates/loader/src/loader.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/loader/src/loader.rs b/crates/loader/src/loader.rs index ac7b94105..ce5202003 100644 --- a/crates/loader/src/loader.rs +++ b/crates/loader/src/loader.rs @@ -1295,10 +1295,13 @@ impl Loader { } else { "" }; - let section = if cfg!(all(target_arch = "powerpc64", target_os = "linux")) { - " D " + let section = " T "; + // Older ppc toolchains incorrectly report functions in the Data section. This bug has been + // fixed, but we still need to account for older systems. + let old_ppc_section = if cfg!(all(target_arch = "powerpc64", target_os = "linux")) { + Some(" D ") } else { - " T " + None }; let mut must_have = vec![ format!("{prefix}tree_sitter_{name}_external_scanner_create"), @@ -1317,7 +1320,7 @@ impl Loader { if output.status.success() { let mut found_non_static = false; for line in String::from_utf8_lossy(&output.stdout).lines() { - if line.contains(section) { + if line.contains(section) || old_ppc_section.is_some_and(|s| line.contains(s)) { if let Some(function_name) = line.split_whitespace().collect::>().get(2) {