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

add bottlerocket tools to twoliter binary #47

Merged
merged 7 commits into from
Sep 14, 2023
Merged

add bottlerocket tools to twoliter binary #47

merged 7 commits into from
Sep 14, 2023

Conversation

webern
Copy link
Contributor

@webern webern commented Sep 5, 2023

Issue #, if available:

Closes #14
Closes #9
Closes #32
Partly Addresses #43 (We install it here, but should probably still eliminate it in favor of a lib)

Description of changes:

Embed tools such as buildsys, and scripts such as rpm2img into the Twoliter binary. Use them when building Bottlerocket

Testing

  • Build Bottlerocket on an x86_64 host
  • Build Bottlerocket on an Arm host

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@webern webern marked this pull request as draft September 5, 2023 23:15
.cargo/config.toml Outdated Show resolved Hide resolved
tools/buildsys/src/builder.rs Show resolved Hide resolved
tools/buildsys/src/builder.rs Outdated Show resolved Hide resolved
tools/buildsys/src/gomod.rs Outdated Show resolved Hide resolved
tools/buildsys/src/gomod.rs Outdated Show resolved Hide resolved
twoliter/embedded/Dockerfile Outdated Show resolved Hide resolved
twoliter/embedded/Makefile.toml Outdated Show resolved Hide resolved
twoliter/src/cmd/make.rs Outdated Show resolved Hide resolved
twoliter/src/docker/image.rs Outdated Show resolved Hide resolved
twoliter/src/tools/mod.rs Outdated Show resolved Hide resolved
@webern webern changed the title move bottlerocket tools to twoliter add bottlerocket tools to twoliter binary Sep 6, 2023
@webern
Copy link
Contributor Author

webern commented Sep 6, 2023

tools/buildsys/src/builder.rs Show resolved Hide resolved
twoliter/embedded/Dockerfile Outdated Show resolved Hide resolved
twoliter/embedded/Makefile.toml Outdated Show resolved Hide resolved
twoliter/embedded/Makefile.toml Show resolved Hide resolved
twoliter/embedded/Makefile.toml Outdated Show resolved Hide resolved
twoliter/build.rs Show resolved Hide resolved
@webern
Copy link
Contributor Author

webern commented Sep 8, 2023

.github/workflows/rust.yml Outdated Show resolved Hide resolved
@webern webern force-pushed the tools-install branch 2 times, most recently from cda4f71 to 544cf34 Compare September 11, 2023 22:55
@webern webern force-pushed the tools-install branch 3 times, most recently from 5406dc0 to 14a9919 Compare September 13, 2023 03:10
@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

https://github.com/bottlerocket-os/twoliter/compare/5406dc0f0187d491c24103f23a6c2f29d2cf3376..14a9919c7609da32e8551c03558104d7c09a608d

Substantial rework of how the tools are embedded. As it turns out, and this makes sense, build-dependencies are always built for the host machine. We need the bindeps to be dependencies so they will be built for the --target.

I cannot figure out a way to compress these bytes right now. The include-flate macro requires the path to be an actual string literal (not a macro like env! that evaluates to a string literal). This might be an oversight (not sure how it all works) that is fixable. But also note that the compilation of include-flate seemed to take forever. I'm not sure what is going on there.

rust-toolchain.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

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

Trying to reduce twoliter size a bit, I tested combinations of these settings in Cargo.toml:

[profile.release]
strip = "debuginfo"
codegen-units = 1
lto = true

At a bare minimum, I'd recommend stripping debuginfo.

Setting codegen units to 1 is the biggest one but costs the most in terms of added time. If we go there then we may as well go full LTO for the extra 18% size reduction. This seems worthwhile if our release builders can handle it, but definitely not for CI.

@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

https://github.com/bottlerocket-os/twoliter/compare/9af3a998650d46758e1b34990e39fc23f5f7a7f7..84b795a80985ea12524b7d6a75d37e2ac3ef1eb6

Rebase over the latest tools changes from Bottlerocket.

Includes:

  • rpm2img xfs fix
  • testsys changes

@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

At a bare minimum, I'd recommend stripping debuginfo.

Nice. This change took the binary from 380M to 80M!

@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

@webern webern marked this pull request as ready for review September 13, 2023 22:55
@webern
Copy link
Contributor Author

webern commented Sep 13, 2023

a527e07

Tacked on a commit to stop the unhelpful printing of the entire cargo make invocation which makes it harder for people to find the real error.

Adds Rust tools and scripts, originally located in the Bottlerocket
repo, to Twoliter's embedded tools.
Buildsys requires these changes to work with the tools embedded in the
Twoliter binary.
Adds a command that can be used to dump the tools for further
inspection.
Enable printing the current version with twoliter --version
It is not a good idea to print the entire cargo make command when an
error occurs. This is making it harder for people to find the real'
error and could reveal secrets. Best to be quiet about what command was
invoked under the hood.
@webern
Copy link
Contributor Author

webern commented Sep 14, 2023

Base automatically changed from tools to develop September 14, 2023 00:10
@webern webern merged commit 2e0741a into develop Sep 14, 2023
1 check passed
@webern webern deleted the tools-install branch September 14, 2023 00:12
This was referenced Sep 18, 2023
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.

change build tools install dir twoliter make can build bottlerocket copy tools
3 participants