From ab1f321fa51c110e70236895272e5514a4564117 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 21 Mar 2024 06:10:47 +0000 Subject: [PATCH] Look for underscored name in rust 1.79 See https://github.com/rust-lang/cargo/pull/12783. --- Cargo.toml | 1 + build.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 609307b..28427c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,5 @@ anyhow = "1.0.72" cargo_metadata = "0.18.0" prettyplease = "0.2.10" quote = "1.0.29" +rustversion = "1.0" syn = { version = "2.0.26", features = ["full"] } diff --git a/build.rs b/build.rs index c145857..005d6c4 100644 --- a/build.rs +++ b/build.rs @@ -59,6 +59,14 @@ mod llvm { impl Generator { pub fn parse_llvm_sys_crate(&mut self) -> Result<&mut Self, Error> { + // See https://github.com/rust-lang/cargo/pull/12783. + + #[rustversion::before(1.79)] + const LLVM_SYS_CRATE_TARGET: &str = "llvm-sys"; + + #[rustversion::since(1.79)] + const LLVM_SYS_CRATE_TARGET: &str = "llvm_sys"; + let metadata = MetadataCommand::new() .exec() .context("Unable to get crate metadata")?; @@ -72,7 +80,7 @@ mod llvm { targets .into_iter() .find_map(|Target { name, src_path, .. }| { - (name == "llvm-sys").then_some(src_path) + (name == LLVM_SYS_CRATE_TARGET).then_some(src_path) }) }) .flatten()