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

Static builds with newer libelf require -l zstd #429

Closed
bobrik opened this issue May 14, 2024 · 3 comments · Fixed by #434
Closed

Static builds with newer libelf require -l zstd #429

bobrik opened this issue May 14, 2024 · 3 comments · Fixed by #434
Assignees
Labels
bug Something isn't working

Comments

@bobrik
Copy link
Contributor

bobrik commented May 14, 2024

Ubuntu 24.04 links libelf.so against libzstd.so. This doesn't matter at all for dynamically linked builds, but if you want a link a fully static binary, you need -l zstd in CGO_LDFLAGS. Currently libbpfgo only has:

#cgo LDFLAGS: -lelf -lz

I worked around this in ebpf_exporter:

# If libelf is new and it links to zstd, then zstd needs to be manually linked in.
ifneq ($(shell ldd $(shell /sbin/ldconfig -n -p | grep libelf.so.1 | awk '{ print $$NF }') | grep zstd),)
CGO_LDFLAGS := $(CGO_LDFLAGS) -l zstd
endif

Perhaps there's a better way in libbpfgo itself.

@geyslan
Copy link
Member

geyslan commented May 20, 2024

@bobrik thanks for reporting this.

@trvll is it the same that you facing? Could you test it?

@bobrik
Copy link
Contributor Author

bobrik commented May 21, 2024

I think you can replicate this in Github actions by bumping Ubuntu 22.04 to 24.04.

@geyslan
Copy link
Member

geyslan commented May 21, 2024

Thanks @bobrik. zstd is indeed a requirement depending on the environment when a static build is the target. I'll be bumping this repo as soon as possible and tackling that.

@geyslan geyslan mentioned this issue May 22, 2024
@geyslan geyslan self-assigned this May 28, 2024
@geyslan geyslan added the bug Something isn't working label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants