Skip to content

Commit 9c7f702

Browse files
committed
refactor linker check to avoid false positives with linker names
1 parent a52c28f commit 9c7f702

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

aimdb-embassy-adapter/build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ fn main() {
3535
let linker = env::var(&linker_env)
3636
.or_else(|_| env::var("RUSTC_LINKER"))
3737
.unwrap_or_default();
38-
if linker.contains("ld") {
38+
39+
// Check for GNU ld specifically, avoiding false positives with lld or paths containing 'ld'
40+
let linker_name = linker
41+
.split('/')
42+
.last()
43+
.unwrap_or(&linker)
44+
.split('\\')
45+
.last()
46+
.unwrap_or(&linker);
47+
48+
if linker_name == "ld" || linker_name.starts_with("arm-") && linker_name.ends_with("-ld") {
3949
println!("cargo:rustc-link-arg=-Wl,--gc-sections");
4050
}
4151
println!("cargo:rustc-cfg=embedded_target");

0 commit comments

Comments
 (0)