-
Notifications
You must be signed in to change notification settings - Fork 34
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
Makefile: Update variables for package builds with external artifacts #56
Conversation
23a349f
to
f8ad7be
Compare
(huh apparently the static build test would need to update LDFLAGS to include --static now, but the bpftool dependency build doesn't like that, so that'd need to first build bpftool without LDFLAGS set and then build retsnoop with LDFLAGS set... I guess that can wait a bit as this isn't in mergeable state anyway; I'll do that some other day) |
Glad it's useful. I'm planning to do a bunch more work on retsnoop in the coming months, have been putting this off for a while while busy with other work stuff.
Let's keep both CFLAGS and LDFLAGS. Maybe also submit this as a separate PR with a proper commit message?
I think I'm fine with this, just SIDECAR_LDPATH name doesn't seem right, it's not LDPATH. Maybe SIDECAR_EMBED_NAME or something like that?
Yes, I do occasionally need some libbpf feature that hasn't been released, so using libbpf outside of submodule sometimes might not work. If you are up to test and deal with these breakages in your specific setup, I don't see much problem to allow user to override libbpf.a location. It's still statically linked, so I'm fine with this.
yeah, this is not good for "normal" build path. What we can do, perhaps, is to have DEFAULT_SIDECAR vs SIDECAR that can be overridden, and if they don't match, don't even trigger cargo (as it's pointless anyways). Let's do this as a separate PR still?
Yep, let's split three changes and review/discuss each individually. |
In order to package retsnoop it is useful to be able to use libbpf provided by the system and to build the addr2line sidecar separately, as we can currently do with BPFTOOL. The ld command for addr2line uses some magic symbol based on the binary's path: try to set it automatically through substitution (. and / converted to _), but allow overriding it as well. Also allow setting the prefix as that seems to be an omission Signed-off-by: Dominique Martinet <[email protected]>
f8ad7be
to
52effc0
Compare
Thanks for the reply! I've split the commits and applied suggestions. Replying to the parts concering the commit left here below.
Right, I looked through the ld documentation and was unable to find a reference to this behaviour (very little about -b binary, and nothing about
This makes sense -- I'll add some test to make sure a basic trace works when updating either libbpf or retsnoop when packaging it. |
Hi!
I'm still using retsnoop once in a while and needed it at home (nixos), so figured I'd package it there.
First commit is mostly unrelated -- the link command ought to use LDFLAGS and not CFLAGS. Keeping CFLAGS doesn't really hurt but shouldn't be required so I removed it, happy to use both flags instead as long as LDFLAGS are added.
The second commit is a bit more complicated: Nixos requires the build to not use internet, so I need to build the addr2line sidecar crate with a frozen cargo command independently of the rest -- that's internal nixos mess and I'm not expecting any help here, but I also had problem with the sidecar ld command in the past (#31 -- actually that'd need an extra subst for
-
->_
, I wonder if make has a better syntax for this, sure couldn't find it... At least that can be overwritten with an env var now), so the SIDECAR_LDPATH might make that a bit simpler to use and at least ought to clarify where that magic symbol comes from.Similarly, nixos libbpf package provides a libbpf.a, so we're more or less supposed to use it unless there's a very good reason not to -- the libbpf package is kept up to date and while the submodule is a bit more up to date than 1.3.0 I haven't seen any problem with the latest release so far.
I know what you're thinking about not using the submodule and I'm sure that'll come bite me at some point, but I'm expecting libbpf to have stabilized enough to be manageable since 1.0, so the worst that can happen is probably me bugging you for a new libbpf release if you tag a new retsnoop release that requires a new call from libbpf, and libbpf itself isn't getting updated. Hopefully not too often :)
The last commit is complete garbage, but I couldn't come up with a way to flag that I don't want to rebuild the sidecar (the
::
make target will always try to run cargo and that'll fail for me); I think I'll just patch it on the nixos side but bringing it up here if you have a better idea.With all of this, I can build retsnoop by just setting a few env vars as follow (after building addr2line and copying it to the current directory):
There's no hurry on anything here, just tell me what you think we can keep when you have a moment and I'll clean up a bit, and I'll submit the nixos package when that's done.