cfallin requested abrown for a review on PR #4143.
cfallin opened PR #4143 from isle-no-checked-in-code
to main
:
This PR fixes #4066: it modifies the Cranelift
build.rs
workflow to
invoke the ISLE DSL compiler on every compilation, rather than only
when the user specifies a special "rebuild ISLE" feature.The main benefit of this change is that it vastly simplifies the mental
model required of developers, and removes a bunch of failure modes
we have tried to work around in other ways. There is now just one
"source of truth", the ISLE source itself, in the repository, and so there
is no need to understand a special "rebuild" step and how to handle
merge errors. There is no special process needed to develop the compiler
when modifying the DSL. And there is no "noise" in the git history produced
by constantly-regenerated files.The two main downsides we discussed in #4066 are:
- Compile time could increase, by adding a "meta" step before the main build;
- It becomes less obvious where the source definitions are (everything becomes
more "magic"), which makes exploration and debugging harder.This PR addresses each of these concerns:
To maintain reasonable compile time, it includes work to cut down the
dependencies of thecranelift-isle
crate to nothing (only the Rust stdlib),
in the default build. It does this by putting the error-reporting bits
(miette
crate) under an optional feature, and the logging (log
crate) under
a feature-controlled macro, and manually writing anError
impl rather than
usingthiserror
. This completely avoids proc macros and thesyn
build slowness.The user can still get nice errors out of
miette
: this is enabled by specifying
a Cargo feature--features isle-errors
.To allow the user to optionally inspect the generated source, which nominally
lives in a hard-to-find path insidetarget/
now, this PR adds a featureisle-in-source-tree
that, as implied by the name, moves the target for ISLE generated source into
the source tree, atcranelift/codegen/isle_generated_source/
. It seems reasonable
to do this when an explicit feature (opt-in) is specified because this is how ISLE regeneration
currently works as well. To prevent surprises, if the feature is not specified, the
build fails if this directory exists.The compile-time measures as follows on my system: a clean build (
cargo clean
first
thencargo build -p cranelift-codegen
) on a MacBook M1 Air (macOS/aarch64) gives:Before:
Finished dev [unoptimized + debuginfo] target(s) in 8.26s cargo build -p cranelift-codegen 22.29s user 2.05s system 291% cpu 8.348 total
After:
Finished dev [unoptimized + debuginfo] target(s) in 9.96s cargo build -p cranelift-codegen 28.08s user 2.43s system 303% cpu 10.055 total
so about 1.7 seconds slower.
With a default configuration, an ISLE error looks like this during build:
--- stderr Error building ISLE files: ISLE errors: parse error: Unexpected token Symbol("asdf") To see a more detailed error report, run: $ cargo check -p cranelift-codegen --features isle-errors
When specifying the feature, one instead gets
--- stderr Error building ISLE files: × parse error: Unexpected token Symbol("asdf") ╭─[src/isa/aarch64/inst.isle:1:1] 1 │ asdf · ┬ · ╰── Unexpected token Symbol("asdf") 2 │ ╰────
cfallin requested fitzgen for a review on PR #4143.
cfallin requested alexcrichton for a review on PR #4143.
cfallin edited PR #4143 from isle-no-checked-in-code
to main
:
This PR fixes #4066: it modifies the Cranelift
build.rs
workflow to
invoke the ISLE DSL compiler on every compilation, rather than only
when the user specifies a special "rebuild ISLE" feature.The main benefit of this change is that it vastly simplifies the mental
model required of developers, and removes a bunch of failure modes
we have tried to work around in other ways. There is now just one
"source of truth", the ISLE source itself, in the repository, and so there
is no need to understand a special "rebuild" step and how to handle
merge errors. There is no special process needed to develop the compiler
when modifying the DSL. And there is no "noise" in the git history produced
by constantly-regenerated files.The two main downsides we discussed in #4066 are:
- Compile time could increase, by adding more to the "meta" step before the main build;
- It becomes less obvious where the source definitions are (everything becomes
more "magic"), which makes exploration and debugging harder.This PR addresses each of these concerns:
To maintain reasonable compile time, it includes work to cut down the
dependencies of thecranelift-isle
crate to nothing (only the Rust stdlib),
in the default build. It does this by putting the error-reporting bits
(miette
crate) under an optional feature, and the logging (log
crate) under
a feature-controlled macro, and manually writing anError
impl rather than
usingthiserror
. This completely avoids proc macros and thesyn
build slowness.The user can still get nice errors out of
miette
: this is enabled by specifying
a Cargo feature--features isle-errors
.To allow the user to optionally inspect the generated source, which nominally
lives in a hard-to-find path insidetarget/
now, this PR adds a featureisle-in-source-tree
that, as implied by the name, moves the target for ISLE generated source into
the source tree, atcranelift/codegen/isle_generated_source/
. It seems reasonable
to do this when an explicit feature (opt-in) is specified because this is how ISLE regeneration
currently works as well. To prevent surprises, if the feature is not specified, the
build fails if this directory exists.The compile-time measures as follows on my system: a clean build (
cargo clean
first
thencargo build -p cranelift-codegen
) on a MacBook M1 Air (macOS/aarch64) gives:Before:
Finished dev [unoptimized + debuginfo] target(s) in 8.26s cargo build -p cranelift-codegen 22.29s user 2.05s system 291% cpu 8.348 total
After:
Finished dev [unoptimized + debuginfo] target(s) in 9.96s cargo build -p cranelift-codegen 28.08s user 2.43s system 303% cpu 10.055 total
so about 1.7 seconds slower.
With a default configuration, an ISLE error looks like this during build:
--- stderr Error building ISLE files: ISLE errors: parse error: Unexpected token Symbol("asdf") To see a more detailed error report, run: $ cargo check -p cranelift-codegen --features isle-errors
When specifying the feature, one instead gets
--- stderr Error building ISLE files: × parse error: Unexpected token Symbol("asdf") ╭─[src/isa/aarch64/inst.isle:1:1] 1 │ asdf · ┬ · ╰── Unexpected token Symbol("asdf") 2 │ ╰────
cfallin updated PR #4143 from isle-no-checked-in-code
to main
.
abrown submitted PR review.
abrown submitted PR review.
abrown created PR review comment:
logging = ["log"]
cfallin updated PR #4143 from isle-no-checked-in-code
to main
.
cfallin submitted PR review.
cfallin created PR review comment:
Fixed, thanks!
cfallin updated PR #4143 from isle-no-checked-in-code
to main
.
cfallin merged PR #4143.
Last updated: Nov 22 2024 at 16:03 UTC