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 8d5edea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/check-and-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ jobs:
- name: Build all the things
run: cargo build --tests

- name: xxx
run: rustc --version

- name: xxx1
run: cargo run -- --manifest-path sample/Cargo.toml --intel --everything

- name: xxx2
run: cargo run -- --manifest-path sample/Cargo.toml

- name: Run unit tests
run: cargo test --all-features

Expand Down
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 8d5edea

Please sign in to comment.