-
Notifications
You must be signed in to change notification settings - Fork 338
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
Simplify guest linker configuration #559
Conversation
shkoo
commented
May 11, 2023
•
edited
edited
- Remove custom linker script in favor of -Ttext= linker arg
- Stack pointer and .text are now based on values in memory.rs instead of a separate linker script. .data and .bss follow .text.
- When using "std" on the guest, we no longer need to include #![no_main] or risc0_zkvm::entry!(...); just a standard "pub fn main" will do. (Unfortunately we still have to force inclusion of the risc0 zkvm crate with "use risc0_zkvm as _" if we don't use anything else from it)
9935bf7
to
8f0f15a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building full projects, would users now need to use cargo risczero build/test
instead of cargo build/test
? Or are these just utilities for building/testing pure guest code (i.e. in the absence of host code)?
Benchmark for Linux-cuda 5a16c82Click to hide benchmark
Benchmark for Linux-default
Benchmark for macOS-default 5a16c82Click to hide benchmark
Benchmark for macOS-metal
|
These are just utilities for building/testing pure guest code in the absence of host code. Going this direction could support the other use case too though, if that's the direction we want to go! |
Great, that seems like a useful feature to have available! IMO, in the absence of technical benefits/problems to the two approaches, using |
After discussion with Frank and Jeremy, I'm going to refactor and work on doing the following:
|
The impact of the |
I changed the entry code to allow "risc0_zkvm::entry!" even when in "std" mode, and reverted the changes in "examples" since we don't need them anymore, so we should be good on that front. This should have no effect on any bonsai integration. This should be ready to review now! |
Benchmark for Linux-cuda
Benchmark for Linux-default
Benchmark for macOS-default
Benchmark for macOS-metal
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things:
- We should ban
#[doc(hidden)]
or have clear justification for its use. - Each PR should try to aim to address a single thing. This seems to have a mix of linker script changes along with
risczero build
support, which doesn't seem directly dependent on one another. - Without an explicit linker script, it's unclear where the DATA section is. There's an
_end
symbol that needs more documentation or a reference/link to how this symbol is defined. Do we know if this will work with all compilers?
On 1 and 2, both were originally included in the draft PR I put up mostly for visibility. Maybe we split that off? |
Remove custom linker script in favor of -Ttext= linkeer arg Stack pointer and .text are now based on values in memory.rs instead of a separate linker script. .data and .bss follow .text. When using "std" on the guest, we no longer need to include #![no_main] or risc0_zkvm::entry!(...); just a standard "pub fn main" will do. (Unfortunately we still have to force inclusion of the risc0 zkvm crate with "use risc0_zkvm as _" if we don't use anything else from it)
c03ef83
to
28bef28
Compare
Benchmark for Linux-cuda
Benchmark for Linux-default
Benchmark for macOS-default
Benchmark for macOS-metal
|
Benchmark for Linux-cuda
Benchmark for Linux-default
Benchmark for macOS-default 08cdac9Click to hide benchmark
Benchmark for macOS-metal
|
Benchmark for Linux-cuda
Benchmark for Linux-default
Benchmark for macOS-default
Benchmark for macOS-metal
|
* Simplify guest linker configuration Remove custom linker script in favor of -Ttext= linkeer arg Stack pointer and .text are now based on values in memory.rs instead of a separate linker script. .data and .bss follow .text. When using "std" on the guest, we no longer need to include #![no_main] or risc0_zkvm::entry!(...); just a standard "pub fn main" will do. (Unfortunately we still have to force inclusion of the risc0 zkvm crate with "use risc0_zkvm as _" if we don't use anything else from it) * Add comments with links to how the linker works --------- Co-authored-by: nils <shkoo@users.noreply.github.com>