-
Notifications
You must be signed in to change notification settings - Fork 65
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
Strip absolute local paths from binaries #1445
Comments
I do intend to write a patch to fix this specific issue, which will improve reproducibility when built from different configurations of the same host platform. It won't result in reproducible builds when built on different host platforms though because of host-specific data leaking into cargo's |
@brson This may be a long shot and I'm not entirely sure how you'd go about testing it on your end, but zig released https://github.com/rust-cross/cargo-zigbuild?tab=readme-ov-file as a drop in solution to rust cross compilation issues that I think may be relevant to the issues you're facing. And full disclaimer, I am by no means a rust developer, this is just pure anectdotal speculation on my end based on what I know about Zig Here are a few links that I found interesting that may be of relevance as well. some other maybe useful links about Zig |
One thing to note here is that this affects the builtin |
What problem does your feature solve?
For builds to be reproducible, the binaries cannot contain absolute filesystem paths. Today there are cases where rustc embeds absolute paths even when debuginfo is stripped.
Namely, panic messages emit paths via the builtin
file!
macro. In some cases these paths are relative (the local project, the prebuilt standard library); but in some they are absolute (crates.io dependencies, the standard library built from source).So e.g. today the
eth_abi
example crate includes absolute paths for thesoroban-sdk
crate and thealloy-sol-types
crate because it calls functions in these crates that in turn may panic.Soroban probably doesn't care about these paths at all - I don't know if they make it all the way to soroban's own panic logging; and they increase wasm size.
What would you like to see?
Soroban-cli should invoke the compiler in a way that eliminates these absolute paths.
The main mechanism for doing this is the
--remap-path-prefix
flag torustc
.There are more sophisticated mechanisms for controlling these paths in cargo via `trim-paths but they are unstable.
The linked
trim-paths
docs describe which paths cargo tellsrustc
to sanitize, and soroban-cli can do the same. The path to the local registry cache is the most important; the path to the local standard library also may be useful to remap.The following patch to
contract/build.rs
is a working proof of concept for remapping the registry path:Unfortunately it seems like this must be done through the
RUSTFLAGS
variable, which adds some complications if the caller is also using it.What alternatives are there?
Discussed above.
The text was updated successfully, but these errors were encountered: