# Behavior traces — rust-lang/rust

> Canonical page: https://codevetter.com/unpack/rust/behavior-traces

# Behavior traces — rust-lang/rust

Scanned commit c64de18c55c70d62aa88a5722dea8f8e263bacf3 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Three flows traced end-to-end. (1) ./x build: x.py -> bootstrap.py downloads stage0 per src/stage0 -> builds bootstrap binary -> cli_main::main -> Flags::parse -> Config::parse -> out/lock -> Builder runs Step descriptions. (2) rustc hello.rs: main.rs -> rustc_driver_impl::main -> run_compiler -> interface::run_compiler -> parse -> create_and_enter_global_ctxt -> resolver_for_lowering -> analysis -> Linker::codegen_and_build_linker -> link. (3) ./x test: bootstrap test steps build compiletest -> run_tests walks suite dirs -> directive parsing -> per-mode runtest runners -> snapshot diffing. CI is a fourth: ci.yml -> citool matrix -> run-build-from-ci.sh -> x.
- Build startup order: x.py adds src/bootstrap to sys.path and calls bootstrap.main(); bootstrap.py verifies python>=3.x, reads src/stage0 pins, downloads stage0 rustc/cargo tarballs with sha256 verification into build/cache, compiles the bootstrap crate, then execs it. — [x.py](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/x.py) [src/bootstrap/bootstrap.py](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/bootstrap.py) [src/stage0](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/stage0)
- Bootstrap main order: src/bootstrap/src/bin/main.rs -> cli_main::main installs a panic hook that prints the active StepStack, parses Flags then Config, acquires a lock file at config.out.join("lock") unless bypass_bootstrap_lock, then runs the Builder. — [src/bootstrap/src/bin/main.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/src/bin/main.rs) [src/bootstrap/src/cli_main.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/src/cli_main.rs)
- Step dispatch: Builder::get_step_descriptions uses the describe! macro per Kind to map CLI paths to Step impls; run_step_descriptions executes each matching Step's run() in dependency order (builder/mod.rs). — [src/bootstrap/src/core/builder/mod.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/src/core/builder/mod.rs)
- rustc process startup order: rustc_driver_impl::main -> init_rustc_env_logger -> signal_handler::install -> TimePassesCallbacks::default -> install_ice_hook(DEFAULT_BUG_REPORT_URL) -> install_ctrlc_handler (sets rustc_const_eval::CTRL_C_RECEIVED then exits after 100ms) -> catch_with_exit_code(run_compiler). — [compiler/rustc_driver_impl/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_driver_impl/src/lib.rs)
- Compile pipeline order inside run_compiler: arg_expand_all -> handle_options -> build_session_options -> make_input/make_output -> interface::run_compiler -> passes::parse -> (optional pretty-print early exit) -> create_and_enter_global_ctxt -> resolver_for_lowering -> write_dep_info/write_interface -> tcx.ensure_ok().analysis -> Linker::codegen_and_build_linker -> linker.link. — [compiler/rustc_driver_impl/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_driver_impl/src/lib.rs)
- Session construction order inside interface::run_compiler: set_dyn_thread_safe_mode -> jobserver::initialize -> build_target_config -> build_early_session -> get_codegen_backend (dylib __rustc_codegen_backend or make_codegen_backend) -> codegen_backend.init -> build_session -> target_config -> parse_cfg/add_configuration -> parse_check_cfg -> lint store via register_lints. — [compiler/rustc_interface/src/interface.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/interface.rs)
- GlobalCtxt creation order in create_and_enter_global_ctxt: pre_configure_attrs -> get_crate_name -> collect_crate_types -> StableCrateId::new -> build_output_filenames -> setup_dep_graph -> CStore/Definitions/untracked construction -> load_query_result_cache -> clone DEFAULT_QUERY_PROVIDERS -> codegen_backend.provide -> override_queries hook -> TyCtxt::create_global_ctxt with OnceLock gcx_cell and WorkerLocal arenas. — [compiler/rustc_interface/src/passes.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/passes.rs)
- Test-run order: ./x test -> bootstrap build_steps/test.rs builds and runs the compiletest binary -> compiletest::run_tests installs a panic hook, raises the fd limit, sets __COMPAT_LAYER=RunAsInvoker on Windows, walks tests/<suite> dirs collecting files -> directives parsing (FileDirectives/DirectivesCache) -> executor schedules CollectedTests -> runtest::<mode> modules execute compile/run and diff .stderr/.stdout snapshots. — [src/tools/compiletest/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/compiletest/src/lib.rs) [src/tools/compiletest/src/runtest.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/tools/compiletest/src/runtest.rs) [src/bootstrap/src/core/build_steps/test.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/bootstrap/src/core/build_steps/test.rs)
- CI job order: ci.yml 'calculate_matrix' runs citool calculate-job-matrix over jobs.yml -> each matrix job checks out, runs ~15 setup scripts under src/ci/scripts (free-disk-space, install-sccache/clang/ninja/mingw, verify-channel, verify-line-endings, verify-stable-version-number) -> builds citool -> run-build-from-ci.sh executes the build -> doc artifacts to GitHub, dist artifacts to S3, metrics to DataDog via citool upload-build-metrics. — [.github/workflows/ci.yml](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/.github/workflows/ci.yml) [src/ci/github-actions/jobs.yml](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/src/ci/github-actions/jobs.yml)
- Incremental compile ordering: setup_dep_graph decides whether incremental is enabled and returns an IncrCompSession; dep_graph.assert_ignored() runs during HIR construction; load_query_result_cache reads the on-disk cache; after codegen, persist::save writes the new dep graph and work products. — [compiler/rustc_interface/src/passes.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_interface/src/passes.rs) [compiler/rustc_incremental/src/persist/save.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_incremental/src/persist/save.rs)
- Early-exit branches in run_compiler happen in a fixed order: --explain, -Whelp (describe_lints after session/lint registration), help_only, --print (print_crate_info), missing input (fatal 'no input filename given'), -Zls metadata listing, -Zlink-only process_rlink, then pretty-printing, then parse_crate_root_only. — [compiler/rustc_driver_impl/src/lib.rs](https://github.com/rust-lang/rust/blob/c64de18c55c70d62aa88a5722dea8f8e263bacf3/compiler/rustc_driver_impl/src/lib.rs)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
