Skip to content

Commit a4360b7

Browse files
Merge pull request #99 from dtolnay-contrib/gold
Unforce gold linker on recent toolchains
2 parents c3463f7 + 4dc3320 commit a4360b7

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ default = ["arbitrary"]
3232
[dependencies]
3333
arbitrary = { version = "1", optional = true }
3434
rustc_version = "0.4"
35+
semver = "1"
3536

3637
[dev-dependencies]
3738
rand = "0.8"

src/bin/cargo-hfuzz.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_version::Channel;
12
use std::env;
23
use std::fs;
34
use std::os::unix::process::CommandExt;
@@ -207,7 +208,21 @@ where
207208
let honggfuzz_target = env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| HONGGFUZZ_TARGET.into());
208209

209210
// HACK: temporary fix, see https://github.com/rust-lang/rust/issues/53945#issuecomment-426824324
210-
let use_gold_linker: bool = match Command::new("which") // check if the gold linker is available
211+
let use_gold_linker: bool = match rustc_version::version_meta() {
212+
Ok(version_meta) => match version_meta.channel {
213+
Channel::Nightly | Channel::Dev => {
214+
// old nightly
215+
version_meta
216+
.commit_date
217+
.map_or(false, |date| *date < *"2025-03-08")
218+
}
219+
Channel::Stable | Channel::Beta => {
220+
// old non-nightly
221+
version_meta.semver < semver::Version::new(1, 87, 0)
222+
}
223+
},
224+
Err(_) => false,
225+
} && match Command::new("which") // only if gold linker is available
211226
.args(&["ld.gold"])
212227
.stdout(Stdio::null())
213228
.stderr(Stdio::null())

0 commit comments

Comments
 (0)