Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RISC-V assembler #1852

Merged
merged 6 commits into from
Oct 2, 2024
Merged

Remove RISC-V assembler #1852

merged 6 commits into from
Oct 2, 2024

Conversation

lvella
Copy link
Member

@lvella lvella commented Sep 30, 2024

Removal of a quite important feature.

Better get many approvals.

Comment on lines +1 to +21
/// A single 32-bit data value.
pub enum SingleDataValue {
/// A literal value.
Value(u32),
/// The value of a pointer to a text label. Since there may be not a
/// 1-to-1 correspondence between nativa ISAs and Powdr ASM instructions,
/// this is passed unresolved to the code generator.
LabelReference(String),
/// Currently not supported.
Offset(String, String),
}

pub fn quote(s: &str) -> String {
// TODO more things to quote
format!("\"{}\"", s.replace('\\', "\\\\").replace('\"', "\\\""))
}

pub fn escape_label(l: &str) -> String {
// TODO make this proper
l.replace('.', "_dot_").replace('/', "_slash_")
}
Copy link
Member Author

@lvella lvella Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all that survived from the old powdr-asm-utils crate.

@lvella lvella marked this pull request as draft September 30, 2024 15:13
@lvella lvella marked this pull request as ready for review September 30, 2024 15:18
@leonardoalt
Copy link
Member

@chriseth had a point that if we ever add new frontends via assembly (like WASM), we'd need some of this code back. I guess we can always revive stuff in the future.

@lvella
Copy link
Member Author

lvella commented Oct 1, 2024

I believe there is a binary version of WASM that is actually deployed and is easier to parse than assembly.

@lvella
Copy link
Member Author

lvella commented Oct 1, 2024

But much of the ELF parser is reusable for any architecture that has ELF targets, so it can be split and placed on the the new crate powdr-isa-utils for reuse.

@leonardoalt
Copy link
Member

yea, makes sense

Copy link
Member

@leonardoalt leonardoalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Some small comments

run: rustup component add rust-src --toolchain nightly-2024-08-01-x86_64-unknown-linux-gnu
- name: Install riscv target
run: rustup target add riscv32imac-unknown-none-elf --toolchain nightly-2024-08-01-x86_64-unknown-linux-gnu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we not need this before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We built the core libraries from source, since we needed the .s files. Now we can use the pre-built.

Then you ask: "Then why do we still need the line above, that installs the rust source?"

Because the risc0 target we use for std support is a lower tier and doesn't have pre-builds, so we still need to build std from source when using it.

.github/workflows/pr-tests.yml Show resolved Hide resolved
.unwrap()
.contains(&"std".into())
.flat_map(|package| {
package["targets"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where was this before? I don't see it in the removed parts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new code.

The previous version used the JSON from cargo -Zunstable-options --build-plan to get details from every compilation unit and find the assembly files. But it is an unstable feature with a heavy run cost (it needs a new target directory to run, and redo a lot of work).

Now that we just need to find the executables, so we use the stable and and lightweight JSON from cargo metadata (that was already been called to figure out if this is a std or no-std build).

Comment on lines -443 to -452
// TODO: if asm path is removed, there are better ways to find the
// executable name than relying on the unstable build plan.
if produce_build_plan {
args.extend(as_ref![
OsStr;
"-Zunstable-options",
"--build-plan"
]);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leonardoalt Here is the cargo command we don't need anymore.

@lvella lvella added this pull request to the merge queue Oct 2, 2024
Merged via the queue into main with commit a68d0b7 Oct 2, 2024
14 checks passed
@lvella lvella deleted the remove_asm branch October 2, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants