Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:

- name: cargo clippy
if: (needs.changes.result != 'success' || needs.changes.outputs.rust == 'true') && needs.changes.outputs.rust_full != 'false'
run: cargo clippy --locked -p celox-test-suite -p celox -p celox-frontend-core -p celox-frontend-sv -p celox-frontend-veryl -p celox-macros -p celox-napi -p celox-sv-analyzer -p celox-ts-gen -p celox-vpi -p lydite-ir -p lydite -p lydite-celox -p lydite-solver -p lydite-syntax -p lydite-verify --all-targets --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus --no-deps
run: cargo clippy --locked --workspace --all-targets --features celox/systemverilog,celox-test-suite/verilator,celox-test-suite/icarus --no-deps

- name: Lint the crates this pull request can affect
if: needs.changes.outputs.rust_full == 'false' && needs.changes.outputs.rust_lint_packages != ''
Expand Down Expand Up @@ -402,7 +402,7 @@ jobs:

- uses: actions/setup-python@v7
with:
python-version: "3.13"
python-version: "3.14"

- name: Install the official runner dependency
run: python -m pip install -r conformance/sv-tests/requirements.txt
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
{ path = "std::eprintln", reason = "library diagnostics must use tracing or a caller-provided writer" },
]

Expand Down
7 changes: 7 additions & 0 deletions crates/celox-backend-arm64/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![cfg_attr(
test,
allow(
clippy::disallowed_macros,
reason = "thread-local instrumentation exists only in unit tests; non-test library builds enforce the ban"
)
)]
//! Self-contained AArch64 code-generation backend.
//!
//! Production code lowers source-independent SIR directly into AArch64-owned
Expand Down
7 changes: 7 additions & 0 deletions crates/celox-backend-x86/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![cfg_attr(
test,
allow(
clippy::disallowed_macros,
reason = "thread-local instrumentation exists only in unit tests; non-test library builds enforce the ban"
)
)]
//! Self-contained x86-64 code-generation kernel.
//!
//! The crate consumes source-independent SIR plus a finalized physical state
Expand Down
25 changes: 15 additions & 10 deletions crates/celox-bench/src/bin/celox-heliodor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(clippy::disallowed_macros)] // CLI errors and progress intentionally use stderr

use std::io::Write as _;
use std::{
fs,
path::{Path, PathBuf},
Expand Down Expand Up @@ -176,7 +175,7 @@ fn main() {
.with_ansi(false)
.init();
if let Err(e) = run() {
eprintln!("error: {e}");
let _ = writeln!(std::io::stderr().lock(), "error: {e}");
std::process::exit(1);
}
}
Expand Down Expand Up @@ -393,7 +392,7 @@ fn run() -> Result<(), CeloxHeliodorError> {
) {
Ok(cache) => Some(cache),
Err(error) => {
eprintln!("build cache disabled: {error}");
let _ = writeln!(std::io::stderr().lock(), "build cache disabled: {error}");
println!("CELOX_BUILD_CACHE test={} status=bypass", opts.test);
None
}
Expand Down Expand Up @@ -494,15 +493,17 @@ fn run() -> Result<(), CeloxHeliodorError> {
let sir = trace.format_post_optimized_sir();
if let Some(pre_optimized_sir) = &pre_optimized_sir {
fs::write(&pre_sir_path, pre_optimized_sir)?;
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote pre-optimized SIR ({} bytes) to {}",
pre_optimized_sir.len(),
pre_sir_path.display()
);
}
if let Some(sir) = &sir {
fs::write(&sir_path, sir)?;
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote post-optimized SIR ({} bytes) to {}",
sir.len(),
sir_path.display()
Expand Down Expand Up @@ -547,22 +548,26 @@ fn run() -> Result<(), CeloxHeliodorError> {
fs::write(&mir_path, &mir)?;
fs::write(&reactive_graph_path, &reactive_graph)?;
fs::write(&state_layout_path, &state_layout)?;
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote native optimized SIR ({} bytes) to {}",
native_sir.len(),
native_sir_path.display()
);
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote full native MIR ({} bytes) to {}",
mir.len(),
mir_path.display()
);
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote reactive event graph ({} bytes) to {}",
reactive_graph.len(),
reactive_graph_path.display()
);
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"wrote native state-layout analysis ({} bytes) to {}",
state_layout.len(),
state_layout_path.display()
Expand Down
12 changes: 8 additions & 4 deletions crates/celox-bench/src/bin/celox-rica.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::disallowed_macros)] // CLI errors and progress intentionally use stderr

//! Run a Rica ELF on the `HardwareCoreTestTop` board-memory model with Celox
//! and report split benchmark timing.
//!
Expand All @@ -10,6 +8,7 @@
//! mirrors `--timed-clocks`, which evaluates coincident edges atomically with
//! the timed scheduler.

use std::io::Write as _;
use std::{
collections::BTreeMap,
fs,
Expand Down Expand Up @@ -795,7 +794,7 @@ fn report(

fn main() {
if let Err(error) = run(Cli::parse()) {
eprintln!("error: {error}");
let _ = writeln!(std::io::stderr().lock(), "error: {error}");
std::process::exit(1);
}
}
Expand Down Expand Up @@ -888,7 +887,12 @@ fn run(cli: Cli) -> Result<(), RicaError> {
let text = text.ok_or_else(|| message(format!("{name} was not captured")))?;
let path = output_dir.join(name);
fs::write(&path, &text)?;
eprintln!("wrote {name} ({} bytes) to {}", text.len(), path.display());
let _ = writeln!(
std::io::stderr().lock(),
"wrote {name} ({} bytes) to {}",
text.len(),
path.display()
);
}
compiled.into_program_image()
} else {
Expand Down
12 changes: 10 additions & 2 deletions crates/celox-bench/src/bin/heliodor/build_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ impl BuildCache {
match self.try_load() {
Ok(image) => image,
Err(error) => {
eprintln!("build cache ignored {}: {error}", self.path.display());
let _ = writeln!(
std::io::stderr().lock(),
"build cache ignored {}: {error}",
self.path.display()
);
None
}
}
Expand Down Expand Up @@ -423,7 +427,11 @@ impl BuildCache {

pub(super) fn store(&self, image: &NativeProgramImage, dependencies: &[FileDependency]) {
if let Err(error) = self.try_store(image, dependencies) {
eprintln!("build cache write skipped {}: {error}", self.path.display());
let _ = writeln!(
std::io::stderr().lock(),
"build cache write skipped {}: {error}",
self.path.display()
);
}
}

Expand Down
8 changes: 5 additions & 3 deletions crates/celox-bench/src/bin/parallel-report.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Capture compiler decisions and real lane execution into an offline report.
#![allow(clippy::disallowed_macros)]

use celox::{SimBackend, Simulator};
use clap::{Parser, ValueEnum};
use serde_json::{Value, json};
use std::io::Write as _;
use std::{
collections::BTreeMap,
fs,
Expand Down Expand Up @@ -201,7 +201,8 @@ impl<S: Subscriber + for<'a> LookupSpan<'a>> Layer<S> for Capture {
}
let mut events = self.events.lock().unwrap();
if events.len().is_multiple_of(100_000) {
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"Captured {} records; event {}",
events.len(),
fields.0.get("event").unwrap_or(&Value::Null)
Expand Down Expand Up @@ -333,7 +334,8 @@ fn exercise_testbench<B: SimBackend>(
celox::testbench::compile_initial_testbench(&sim).ok_or("No initial testbench found")?;
window.active.store(false, Ordering::Relaxed);
window.running.store(true, Ordering::Relaxed);
eprintln!(
let _ = writeln!(
std::io::stderr().lock(),
"Running {} for up to {ticks} ticks; capture kernel calls {}..{}",
args.top,
window.after + 1,
Expand Down
5 changes: 2 additions & 3 deletions crates/celox-bench/src/bin/veryl-heliodor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(clippy::disallowed_macros)] // CLI errors intentionally use stderr

use std::io::Write as _;
use std::{fs, path::PathBuf, time::Instant};

use clap::Parser as ClapParser;
Expand Down Expand Up @@ -52,7 +51,7 @@ enum VerylHeliodorError {

fn main() {
if let Err(error) = run() {
eprintln!("error: {error}");
let _ = writeln!(std::io::stderr().lock(), "error: {error}");
std::process::exit(1);
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/celox-sv-analyzer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![cfg_attr(
test,
allow(
clippy::disallowed_macros,
reason = "thread-local counters exist only in unit tests; non-test library builds enforce the ban"
)
)]
//! SystemVerilog analyzer for Celox.
//!
//! Native syntax and source storage belong to [`celox_sv_syntax`]. This crate
Expand Down
2 changes: 1 addition & 1 deletion crates/celox/examples/sv_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//! ```

#![allow(clippy::disallowed_methods)] // This binary is the process environment boundary.
#![allow(clippy::disallowed_macros)] // Driver diagnostics intentionally use stderr.

use std::{collections::BTreeSet, env, path::PathBuf, process::ExitCode};

Expand Down Expand Up @@ -227,6 +226,7 @@ fn simulate(mut sim: celox::Simulation) -> Result<(), String> {
Ok(())
}

#[allow(clippy::disallowed_macros)] // CLI diagnostics intentionally use stderr.
fn main() -> ExitCode {
let args: Vec<String> = env::args().skip(1).collect();
if args.as_slice() == ["--version"] {
Expand Down
7 changes: 7 additions & 0 deletions crates/celox/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![cfg_attr(
test,
allow(
clippy::disallowed_macros,
reason = "thread-local instrumentation exists only in unit tests; non-test library builds enforce the ban"
)
)]
mod backend;
#[cfg(all(feature = "arm64-codegen", feature = "x86_64-codegen"))]
compile_error!("arm64-codegen and x86_64-codegen cannot be enabled together");
Expand Down
5 changes: 5 additions & 0 deletions crates/lydite-celox/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
25 changes: 23 additions & 2 deletions crates/lydite-celox/src/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//! lifter and the Python conformance tools. Celox's own serde types carry the
//! design and SIR; only the envelope around them is defined here.
use celox_design::{
ElaboratedDesign, InitialStateValue, RegionedStateAddr, RuntimeEventSite, StateAddr,
VariableMetadata,
DomainKind, ElaboratedDesign, InitialStateValue, RegionedStateAddr, RuntimeEventSite,
StateAddr, VariableMetadata,
};
use celox_frontend_core::VariableKind;
use celox_sir::{ExecutionUnit, SirProgram};
Expand Down Expand Up @@ -44,6 +44,13 @@ pub struct Design {
pub state_objects: Vec<StateObject>,
pub initial_state: Vec<InitialStateValue<StateAddr>>,
pub ordered_events: Vec<StateAddr>,
/// Canonical edge kinds, including kinds carried by aliases of registers.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub event_kinds: Vec<(StateAddr, DomainKind)>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub derived_events: Vec<(StateAddr, Vec<StateAddr>)>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub combinational_derived: Vec<(StateAddr, Vec<StateAddr>)>,
pub cascaded_events: BTreeSet<StateAddr>,
pub event_aliases: Vec<(StateAddr, StateAddr)>,
pub reset_clocks: Vec<(StateAddr, StateAddr)>,
Expand All @@ -70,8 +77,22 @@ impl Compiled {
}
impl From<ElaboratedDesign<StateAddr>> for Design {
fn from(design: ElaboratedDesign<StateAddr>) -> Self {
let mut event_kinds: Vec<_> = design.event_kinds().into_iter().collect();
event_kinds.sort_by_key(|(address, _)| *address);
let events = design.events;
Self {
event_kinds,
derived_events: events.derived_events.into_iter().collect(),
combinational_derived: events
.combinational_derived
.into_iter()
.map(|(source, clocks)| {
(
source,
clocks.into_iter().map(|clock| clock.clock).collect(),
)
})
.collect(),
state_objects: design
.state_objects
.into_iter()
Expand Down
5 changes: 5 additions & 0 deletions crates/lydite-ir/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
5 changes: 5 additions & 0 deletions crates/lydite-solver/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
5 changes: 5 additions & 0 deletions crates/lydite-syntax/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
5 changes: 5 additions & 0 deletions crates/lydite-verify/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
5 changes: 5 additions & 0 deletions crates/lydite/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# lydite is a standalone verifier CLI: Celox's simulator-library rules in the
# workspace clippy.toml (no env reads, no eprintln, Fx hash maps) do not apply.

# Explicit state ownership also applies to the verifier crates.
disallowed-macros = [
{ path = "std::thread_local", reason = "production state must be owned and passed explicitly; only test-local instrumentation may opt out" },
]
Loading
Loading