From 8e9a4e6ae8759b42855162a33aa2cc3afc4aa5cd Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 13 Nov 2025 09:25:14 +1100 Subject: [PATCH] Search /usr/local/llvm[n] on FreeBSD This is where versioned binary LLVM packages get installed on FreeBSD. Fixes #79. --- build.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build.rs b/build.rs index df4ef93..d697557 100644 --- a/build.rs +++ b/build.rs @@ -102,6 +102,22 @@ fn locate_llvm_config() -> Option { } } + // On FreeBSD, LLVM binary packages install to /usr/local/llvm{version} (where version is "21", + // "20" and so forth down to 11 as the earliest available as of 2025-11-13) and aren't on PATH. + // Search for one of those if nothing else worked, newest first. + if target_os_is("freebsd") { + let mut prefix = PathBuf::from("/usr/local/"); + + for version in (11..=(CRATE_VERSION.major / 10)).rev() { + prefix.push(format!("llvm{version}/bin")); + if let Some(x) = llvm_compatible_binary_name(&prefix) { + return Some(x); + } + prefix.pop(); + prefix.pop(); + } + } + None } -- GitLab