/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs

https://gitlab.com/rust-lang/rust · Rust · 58 lines · 41 code · 10 blank · 7 comment · 0 complexity · ca282d5da7343a5278a5bc3b0d6da414 MD5 · raw file

  1. // This test checks that a change in a CGU does not invalidate an unrelated CGU
  2. // during incremental ThinLTO.
  3. // revisions: cfail1 cfail2 cfail3
  4. // compile-flags: -Z query-dep-graph -O
  5. // build-pass (FIXME(62277): could be check-pass?)
  6. #![feature(rustc_attrs)]
  7. #![crate_type="rlib"]
  8. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo",
  9. cfg="cfail2",
  10. kind="no")]
  11. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo",
  12. cfg="cfail3",
  13. kind="post-lto")]
  14. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar",
  15. cfg="cfail2",
  16. kind="pre-lto")]
  17. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar",
  18. cfg="cfail3",
  19. kind="post-lto")]
  20. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz",
  21. cfg="cfail2",
  22. kind="post-lto")]
  23. #![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz",
  24. cfg="cfail3",
  25. kind="post-lto")]
  26. mod foo {
  27. #[cfg(cfail1)]
  28. pub fn inlined_fn() -> u32 {
  29. 1234
  30. }
  31. #[cfg(not(cfail1))]
  32. pub fn inlined_fn() -> u32 {
  33. // See `cgu_keeps_identical_fn.rs` for why this is different
  34. // from the other version of this function.
  35. 12345
  36. }
  37. }
  38. pub mod bar {
  39. use foo::inlined_fn;
  40. pub fn caller() -> u32 {
  41. inlined_fn()
  42. }
  43. }
  44. pub mod baz {
  45. pub fn unrelated_to_other_fns() -> u64 {
  46. 0xbeef
  47. }
  48. }