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

Reproducible build: introduce a tool to help reproducible build #268

Merged
merged 1 commit into from
May 27, 2022

Conversation

longlongyang
Copy link
Contributor

fix #256

  1. Introduce a reproducible tool, td-reproducible-tool, to help reproducible
  2. Add strip = "symbols" to cargo.toml in root workspace to remove symbols

Signed-off-by: Longlong Yang longlong.yang@intel.com

@gaojiaqi7
Copy link
Member

The CI failure caused by secure boot verification is due to strip = "symbols", there may be some hidden optimizations which are not compatible with the new setting

@jyao1 jyao1 closed this May 16, 2022
@jyao1 jyao1 reopened this May 16, 2022
```

Solution: <br>

Copy link
Member

Choose a reason for hiding this comment

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

Could 2, 3, 4 also be solved by using build container to normalize the build env?

Copy link
Member

@jyao1 jyao1 May 19, 2022

Choose a reason for hiding this comment

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

It is based upon the definition of "reproducible build".

In our definition, "reproducible build" means
A) Release build
B) Build with same code and version
C) Build with same compiler and version
D) Build at different time.
E) Build at different directory/path <==

If we normalize the build, then E) is not requirement, then we don't need 2/3/4.

Copy link
Member

Choose a reason for hiding this comment

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

The final design:
1 and 2 are handled by build option.
3 and 4 are handled by post-build tool as an option.
5. Timestamp is always cleared.

// check out CARGO_HOME and RUSTUP_HOME
cargo_home = if cargo_home == "" {
if env::var("CARGO_HOME").is_err() {
panic!("Neither --cargo_home nor system environment for \"CARGO_HOME\" is found! ")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make it optional?

It is optional now, please check the latest code change.

// check out CARGO_HOME and RUSTUP_HOME
cargo_home = if cargo_home == "" {
if env::var("CARGO_HOME").is_err() {
panic!("Neither --cargo_home nor system environment for \"CARGO_HOME\" is found! ")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make it optional?

It is optional now, please check the latest code change.


rustup_home = if rustup_home == "" {
if env::var("RUSTUP_HOME").is_err() {
panic!("Neither --rustup_home nor system environment for \"RUSTUP_HOME\" is found! ")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make it optional?

It is optional now, please check the latest code change.


rustup_home = if rustup_home == "" {
if env::var("RUSTUP_HOME").is_err() {
panic!("Neither --rustup_home nor system environment for \"RUSTUP_HOME\" is found! ")
Copy link
Member

Choose a reason for hiding this comment

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

Can we make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is optional now, please check the latest code change.

@longlongyang longlongyang force-pushed the main branch 2 times, most recently from 47de45f to c3a977b Compare May 27, 2022 02:29

rustup_home = if rustup_home == "" {
if env::var("RUSTUP_HOME").is_err() {
panic!("Neither --rustup_home nor system environment for \"RUSTUP_HOME\" is found!\n")
Copy link
Member

Choose a reason for hiding this comment

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

still panic?

Copy link
Contributor Author

@longlongyang longlongyang May 27, 2022

Choose a reason for hiding this comment

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

still panic?

// No more action is needed if strip_path is not specified.
if !strip_path {
println!(
"INFO: -s or --strip_path is not specified, Skipping strip related rust file path."
);
return Ok(());
}
// Check out CARGO_HOME and RUSTUP_HOME, proceed to strip rust file path.
cargo_home = if cargo_home == "" {
if env::var("CARGO_HOME").is_err() {
panic!("Neither --cargo_home nor system environment for \"CARGO_HOME\" is found!\n")
} else {
env::var("CARGO_HOME").unwrap()

If need to strip file path(-s or --strip_path is pecified), then this two is required to set. We can't strip file path without this file path prefix known to us. So I just panic here if not found the path prefix.

Copy link
Member

Choose a reason for hiding this comment

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

OK. I did not found -s or --strip_path in readme.

Please add it.

Copy link
Contributor Author

@longlongyang longlongyang May 27, 2022

Choose a reason for hiding this comment

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

OK. I did not found -s or --strip_path in readme.

Please add it.

Sorry for forgot to update readme. Now added, please check the latest readme.md

// Check out CARGO_HOME and RUSTUP_HOME, proceed to strip rust file path.
cargo_home = if cargo_home == "" {
if env::var("CARGO_HOME").is_err() {
panic!("Neither --cargo_home nor system environment for \"CARGO_HOME\" is found!\n")
Copy link
Member

Choose a reason for hiding this comment

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

still panic?

1. Introduce a reproducible tool, td-reproducible-tool, to help reproducible
2. Add strip = "symbols" to cargo.toml in root workspace to remove symbols

Signed-off-by: Longlong Yang <longlong.yang@intel.com>
@jyao1 jyao1 merged commit fc436aa into confidential-containers:main May 27, 2022
@liuw1
Copy link
Contributor

liuw1 commented May 28, 2022

I validated reproducible build with the latest code, there are still some differences. And the secure boot issue was found in the latest CI test.

image

@jyao1
Copy link
Member

jyao1 commented May 28, 2022

@liuw1 , please file a new issue, or reopen the old issue.

@longlongyang
Copy link
Contributor Author

I validated reproducible build with the latest code, there are still some differences. And the secure boot issue was found in the latest CI test.

image

This position is the where TimeDateStamp sit at, Did you run reproducible tool after every binary built?
And are you sure you observed the secure boot issue using the commit newer or equal to commit#fc436aabae?

@jyao1
Copy link
Member

jyao1 commented May 29, 2022

@longlongyang , I think we need update readme.md to add step for reproducible tool.
Otherwise, people may forget that step.

@longlongyang
Copy link
Contributor Author

@longlongyang , I think we need update readme.md to add step for reproducible tool. Otherwise, people may forget that step.

Okay, will update.

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.

[Bug] td-shim should support reproducible build
5 participants