-
Notifications
You must be signed in to change notification settings - Fork 347
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
fix: non absolute build paths are relative to the build manifest #1819
base: dev
Are you sure you want to change the base?
Conversation
SP1 Performance Test Results Branch: n/build
|
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.
Is there a way to avoid exposing build_program_with_maybe_args
and the macro?
crates/build/src/lib.rs
Outdated
@@ -119,14 +126,56 @@ pub fn build_program(path: &str) { | |||
/// | |||
/// # Arguments | |||
/// | |||
/// * `path` - A string slice that holds the path to the program directory. | |||
/// * `path` - A path to the guest program directory |
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.
nit punc
/// `args` - A [`BuildArgs`] struct that contains various build configuration options. | ||
/// If not provided, the default options are used. | ||
#[macro_export] | ||
macro_rules! build_program_from_path { |
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.
wait why does this have to be a macro?
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.
Because we need to inline the manifest dir at compile time so the path is always relative from the crate dir
from slack:
My contrived example of why this is bad is:
Crate A: lives in dir A exports a function build_A_program that uses a relative path to call sp1_build::build_program
Crate B: lives in dir B imports this function
Crate B: Calls build_A_program with working dir B
this call will then try to look for the path relative to B which is def incorrect
/// ### Note: | ||
/// This function is only exposed to support the `build_program_from_path!` macro. | ||
/// It is not recommended to use this function directly. | ||
pub fn build_program_with_maybe_args(path: impl AsRef<Path>, args: Option<BuildArgs>) { |
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.
i think we should avoid exposing this function if possible, though ngl i'm not really sure how we'd do it.
sp1 build searches for the programs from the current dir
this can have unexpected behaviour if calling from an importing crate in a differnt location
opt in, but deprecating, way to have more reliable program resolution