rust/compiler/rustc_monomorphize/src
Matthias Krüger 3481c0d3cb
Rollup merge of #150569 - check_static_initializer_acyclic, r=workingjubilee
Ensure that static initializers are acyclic for NVPTX

NVPTX does not support cycles in static initializers (see rust-lang/rust#146787). LLVM produces an error when attempting to generate code for such constructs, like self-referential structs.

To avoid LLVM UB, we emit a post-monomorphization error on the Rust side before reaching codegen.

This is achieved by analyzing a subgraph of the "mono item graph" that only contains statics.
1. Calculate the strongly connected components (SCCs) of the graph.
2. Check for cycles (more than one node in an SCC or one node that references itself).
2026-01-08 16:25:30 +01:00
..
collector rlib handling 2025-11-19 00:17:37 -05:00
graph_checks Ensure that static initializers are acyclic for NVPTX 2026-01-06 17:00:21 +01:00
mono_checks mono: require target feature for scalable vectors 2025-12-16 11:01:26 +00:00
collector.rs Ensure that static initializers are acyclic for NVPTX 2026-01-06 17:00:21 +01:00
errors.rs Ensure that static initializers are acyclic for NVPTX 2026-01-06 17:00:21 +01:00
lib.rs Ensure that static initializers are acyclic for NVPTX 2026-01-06 17:00:21 +01:00
partitioning.rs Rollup merge of #150569 - check_static_initializer_acyclic, r=workingjubilee 2026-01-08 16:25:30 +01:00
util.rs Move users of span_to_embeddable_string to span_to_diagnostic_string 2025-12-12 07:32:25 +01:00