Skip to content

Commit

Permalink
fix nightly build
Browse files Browse the repository at this point in the history
In recent versions of the nightly / beta compilers, the use of linkme
causes linker errors. (dtolnay/linkme#94) This
is due to the new linker set as default in these versions.

Add linker flags to nightly builds to revert to the old linker
behaviour.

See:
  - dtolnay/linkme#88
  - https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html
  • Loading branch information
niklasdewally committed Jun 19, 2024
1 parent 1cc0853 commit 4b14701
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/conjure_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "conjure_core"
version = "0.0.1"
edition = "2021"

[build-dependencies]
rustc_version = "0.2"

[dependencies]
conjure_macros = { path = "../conjure_macros" }
enum_compatability_macro = { path = "../enum_compatability_macro" }
Expand Down
18 changes: 18 additions & 0 deletions crates/conjure_core/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use rustc_version::{version_meta, Channel};
fn main() {
// Linkme does not (currently) work using the linker provided by nightly/beta Rust.
// See: https://github.com/dtolnay/linkme/pull/88,
// https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html
//
// This should eventually be fixed in linkme, making this code redundant:
// https://github.com/dtolnay/linkme/issues/94
//
// --niklasdewally
#[allow(clippy::unwrap_used)]
match version_meta().unwrap().channel {
Channel::Stable => {}
_ => {
println!("cargo::rustc-link-arg=-Wl,-z,nostart-stop-gc")
}
}
}
3 changes: 3 additions & 0 deletions crates/conjure_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = "2021"
[lib]
proc_macro = true

[build-dependencies]
rustc_version = "0.2"

[dependencies]
quote = "1.0.36"
syn = { version = "2.0.60", features = ["full"] }
Expand Down
18 changes: 18 additions & 0 deletions crates/conjure_macros/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use rustc_version::{version_meta, Channel};
fn main() {
// Linkme does not (currently) work using the linker provided by nightly/beta Rust.
// See: https://github.com/dtolnay/linkme/pull/88,
// https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html
//
// This should eventually be fixed in linkme, making this code redundant:
// https://github.com/dtolnay/linkme/issues/94
//
// --niklasdewally
#[allow(clippy::unwrap_used)]
match version_meta().unwrap().channel {
Channel::Stable => {}
_ => {
println!("cargo::rustc-link-arg=-Wl,-z,nostart-stop-gc")
}
}
}

0 comments on commit 4b14701

Please sign in to comment.