Skip to content

Commit

Permalink
fix CI in newer rust
Browse files Browse the repository at this point in the history
The culprit lied in rust-lang/rust#116505

In short, with default features turned off, main was trivial enough to
be marked as inline function automatically which then made the symbol
weak. Since nobody was referencing it, it got stripped away.

Marking main in default-features=false config as #[inline(never)] or
replacing 1 + 1 in it's body with a simple println!("foo") call (to make
the main function sophisticated enough not to be subject to the new
automatic marking as inline) makes the test pass again.
  • Loading branch information
pacak committed Dec 29, 2023
1 parent 8955190 commit e7e31ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sample/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl SeedableRng for MyRngCore {
}

#[cfg(not(feature = "superbanana"))]
#[inline(never)]
pub fn main() -> u32 {
1 + 1
}
Expand All @@ -38,6 +39,7 @@ impl Bar {
}

#[cfg(feature = "superbanana")]
#[inline(never)]
pub fn main() {
let mut rng = BlockRng::<MyRngCore>::seed_from_u64(0);
for ix in 0..10 {
Expand Down
2 changes: 1 addition & 1 deletion sample_rlib/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[inline(never)]
pub fn add(a: usize, b: usize) -> usize {
a + b
}

0 comments on commit e7e31ac

Please sign in to comment.