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

embedded: Delete support #2742

Merged
merged 9 commits into from
Nov 16, 2023
Merged

embedded: Delete support #2742

merged 9 commits into from
Nov 16, 2023

Conversation

danobi
Copy link
Member

@danobi danobi commented Sep 2, 2023

PR description

This builds on #2736 in that we will rely on the appimage to do for us
what the embedded build used to do. That is, to provide a static binary.

Supporting and maintaining the embedded builds was very difficult,
as the combinations between distros were essentially endless. This
led to a maze of difficult-to-understand-and-modify build and ci code.
Unifying on the nix build will provide both simplicity and reproducibility.

A farewell

But let us not go without saying how awesome the embedded binaries
were. They were extremely useful on countless occasions for myself alone.
As I'm sure they were for other people. But engineering is full of tradeoffs
and I think it's time to let the embedded builds ride off into the sunset.

Hopefully the appimage can live up to the legacy left behind by the static
build.

This closes #2741.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

@danobi danobi force-pushed the rm_embedded branch 6 times, most recently from 7a8925c to 167fff4 Compare September 2, 2023 17:55
@danobi danobi added do-not-merge Changes are not ready to be merged into master yet do-not-squash Do not squash PR commits labels Sep 2, 2023
@danobi
Copy link
Member Author

danobi commented Sep 2, 2023

I've pulled out two of the more independent changes into #2744 and #2745 .

@danobi danobi marked this pull request as ready for review September 4, 2023 13:52
@danobi danobi assigned danobi and unassigned danobi Sep 4, 2023
@danobi danobi removed the do-not-merge Changes are not ready to be merged into master yet label Sep 4, 2023
Copy link
Contributor

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

This is an awesome cleanup!

Main README also contains mentions of build-static.sh (section Development), you'll want to remove that, too.

Also, I'd like to clarify what is the currently recommended development workflow. Previously, we had the bcc and libbpf submodules, build-libs.sh to build them locally, and we statically linked bpftrace against them. This made sure that we were always developing for a single BCC/libbpf version (the latest one) and didn't have to deal with supporting multiple versions that we did before.

Do we have something similar with nix? Can we document that somewhere?

@danobi
Copy link
Member Author

danobi commented Sep 5, 2023

This is an awesome cleanup!

Main README also contains mentions of build-static.sh (section Development), you'll want to remove that, too.

Ack. Good catch.

Also, I'd like to clarify what is the currently recommended development workflow. Previously, we had the bcc and libbpf submodules, build-libs.sh to build them locally, and we statically linked bpftrace against them. This made sure that we were always developing for a single BCC/libbpf version (the latest one) and didn't have to deal with supporting multiple versions that we did before.

Do we have something similar with nix? Can we document that somewhere?

The flake defines the exact libbpf and bcc version to use: https://github.com/iovisor/bpftrace/blob/e6e4318a2005992df121c6d25412c725e1cfb6d1/flake.nix#L24-L60

It downloads and builds from github.

For people on bleeding edge distros (like me on arch linux), I don't expect the flake will be required. The distro libbpf + bcc should be new enough. But for folks on more stable distros, maybe we could recommend them use nix develop shell?

They are also welcome to install libbpf + bcc from source too.

If that sounds reasonable I can document that in the developers.md doc

@danobi danobi force-pushed the rm_embedded branch 2 times, most recently from 40da90c to a3473b9 Compare September 5, 2023 16:00
@danobi
Copy link
Member Author

danobi commented Sep 5, 2023

I updated the README and removed all the references to build-libs.sh and recursive cloning in INSTALL.md. Also removed the docker bits in INSTALL.md.

Copy link
Contributor

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

Couple of comments:

  • Yesterday at the office hours, we discussed that the installation instructions for various distros in INSTALL.md are often outdated b/c some packages were renamed, etc. The original purpose of some Dockerfiles (e.g. Dockerfile.fedora30) was to simplify maintaining those instructions. While they're probably outdated, too, we plan to update them to serve their original purpose so I'm not sure that deleting them is the best approach. I think we should eventually end up with something like Dockerfile.fedora, Dockerfile.ubuntu, Dockerfile.alpine, etc., each for the latest version of the distro.
  • I may be missing something but I believe that this breaks our current process of building and pushing images to quay. Should we update docs/release_process.md until we fix it?

@viktormalik
Copy link
Contributor

For people on bleeding edge distros (like me on arch linux), I don't expect the flake will be required. The distro libbpf + bcc should be new enough. But for folks on more stable distros, maybe we could recommend them use nix develop shell?

They are also welcome to install libbpf + bcc from source too.

If that sounds reasonable I can document that in the developers.md doc

Sounds good, would be nice to add it to developers.md.

@danobi
Copy link
Member Author

danobi commented Sep 6, 2023

Couple of comments:

* Yesterday at the office hours, we discussed that the installation instructions for various distros in `INSTALL.md` are often outdated b/c some packages were renamed, etc. The original purpose of some Dockerfiles (e.g. `Dockerfile.fedora30`) was to simplify maintaining those instructions. While they're probably outdated, too, we plan to update them to serve their original purpose so I'm not sure that deleting them is the best approach. I think we should eventually end up with something like `Dockerfile.fedora`, `Dockerfile.ubuntu`, `Dockerfile.alpine`, etc., each for the latest version of the distro.

Agreed, Dockerfiles were good documentation. However, in the current (now deleted) state, they reflected fairly old distro releases with quite a few manually built packages (like libcereal and in certain cases pahole). So they will require a rewrite.

I've tacked #2756 onto #2626 . Mind if I take that on in a followup PR?

* I may be missing something but I believe that this breaks our current process of building and pushing images to quay. Should we update `docs/release_process.md` until we fix it?

Yes, you are right. My plan was to upload the appimage as a workflow artifact (see https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts?tool=webui). I don't think it's too difficult -- let me add that to this PR and update docs

@danobi
Copy link
Member Author

danobi commented Sep 6, 2023

I cleaned up the commits a bit as well as addressing feedback

@danobi danobi closed this Oct 2, 2023
@danobi danobi reopened this Oct 2, 2023
Copy link
Member

@ajor ajor left a comment

Choose a reason for hiding this comment

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

@danobi It seems like we'd be able to get a lot of the build simplifications by just removing the embedded build and leaving the STATIC_LINKING option alone. Would that make sense?

@tnovak When the USE_SYSTEM_BPF_BCC option goes away, it'll be in favour of always using the system libraries rather than the other way around, so you won't need to change anything for this part. (I think we could look into using CMake's FetchContent to get the best of both worlds here: use system libraries if installed, otherwise automatically vendor them)

@tnovak
Copy link
Contributor

tnovak commented Oct 3, 2023

Hey @danobi!

Why is appimage not viable for android?

I'm not too familiar with AppImage, but a cursory search indicates that Android isn't supported out of the box; presumably because Android is just different enough from a typical Linux distribution that making it work would be non-trivial.

For example, Android uses its own dynamic loader (installed as /system/bin/linker) and libc so an AppImage built against glibc wouldn't run. (Even if one were to link against glibc statically, some of its functionality may not work -- for example, getaddrinfo() in Android is implemented by talking to a separate netd process).

In general, there are only a few libraries that are guaranteed to be available.

Are you using our pre-built static binaries at all? Or just the STATIC_LINKING build flag?

Just STATIC_LINKING (and USE_SYSTEM_BPF_BCC). This file has the flags passed to CMake, in addition to those from cmake.mk linked above.

@danobi
Copy link
Member Author

danobi commented Oct 3, 2023

@danobi It seems like we'd be able to get a lot of the build simplifications by just removing the embedded build and leaving the STATIC_LINKING option alone. Would that make sense?

Yeah, that's was I was thinking too. I wouldn't mind keeping the STATIC_LINKING support in and having a light CI job that does a static build. That seems like it has a worthwhile value to maintenance ratio.

@danobi
Copy link
Member Author

danobi commented Oct 3, 2023

Btw, we have an office hours this week if anyone wants to drop in and chat about this. Should be links to the meeting info in the main readme

@danobi
Copy link
Member Author

danobi commented Oct 15, 2023

As discussed during office hours last week, we will keep STATIC_LINKING support in the build. And we will exercise it with a CI job (nix if possible, docker otherwise). But still remove embedded build pipeline.

@danobi
Copy link
Member Author

danobi commented Nov 12, 2023

Ready for another look. I'm fairly pleased with what we've arrived at

This deletes all the infra for embedded builds as well as the infra for
doing custom libbpf and bcc builds. We will be replacing this with the
nix + the bpftrace appimage.

Next commit we will delete embedded build support from the build system.
This deletes build support for embedded builds. Note we leave in support
for semi-static builds. IOW: statically link against all dependencies
except libc (b/c libc cannot be statically linked reliably).
This flag was used to link bpftrace against system installed libbpf and
bcc. Now that we are controlling those dependencies with nix instead of
submodules, we no longer need this flag.
It's good to have all the developer documentation in a single place.
This commit creates a new GHA job that builds and uploads the bpftrace
appimage to the commit's build artifacts. This is intended to replace
the previous quay.io images.

Also update scripts/create-assets.md and release_process.md to use the
appimage. Note we stop compressing the bpftrace binary alone -- the
appimage is already zstd compressed.
Most of what changed was that you need to link against all the llvm
backends that the distro originally built llvm with. So that's the
LLVM_TARGETS_TO_BUILD bit.

The other bit was more or less present in the previous embedded build
logic -- the unlinking of transitive dependencies. llvm's infra seems to
want to link against shared libraries even for static archives. Odd. But
we can work around it.
Copy link
Contributor

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

Looks good, great cleanup! Just one nit, otherwise I'd be happy to get this in ASAP, a problem with embedded builds is blocking me from opening a PR.

This commit adds a simple CI job that just tests if bpftrace can build
statically. No additional tests are run -- in the past we have not seen
much benefit in embedded-build tests. It was, however, a massive
headache to maintain. So this time we only build.

Nix was not chosen to do static builds as the `pkgsStatic` ecosystem has
some pretty annoying bugs. Basically pkgsStatic applies overlays to try
and statically build all the packages it typically dynamically links
for. While clever, there are bugs everywhere. So it wasn't worth the
hassle. Alpine linux + docker seemed like a much easier option to
maintain.
@danobi
Copy link
Member Author

danobi commented Nov 14, 2023

Sounds like this is final call then. I'll wait 48 hrs before merging.

There will also probably be a while where we can do a clean revert.

Copy link
Member

@ajor ajor left a comment

Choose a reason for hiding this comment

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

Looks good to me

@danobi danobi merged commit baf41c9 into bpftrace:master Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete deprecated scripts / tools
4 participants