-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Cross compile telegraf depend on libc.so instead of libc.so.6 #15379
Comments
Hi, Your build file is building with CGO enabled, which is not what we support or do for any of our official builds:
By building with CGO enabled, you building a dynamic binary which will depend on external dependencies rather than a static binary. |
@powersj And there is no workaround regarding this ?. |
Yes, there are a few other consequences as well, but that is the general difference. You can see:
Why do you need to build a dynamic binary? By generating a static binary you avoid this all together. |
The go app that are used in OpenWrt are mostly/all dynamic i guess, "CGO_ENABLED=1" is hardcoded in golang compilation supports on OpenWrt. For compiling telegraf with static linkage, what do I need to do manually?, what is the command line?, does passing "CGO_ENABLED=0" is enough?, it doesn't seems to work for my case. What is the complete command lines , other than simple "make build" ?. |
I thought someone was already building openwrt builds before. Did something change such that it broke?
That is how we produce all our artifacts. That roughly translates to: branch := $(shell git rev-parse --abbrev-ref HEAD)
commit := $(shell git rev-parse --short=8 HEAD)
INTERNAL_PKG=github.com/influxdata/telegraf/internal
LDFLAGS := $(LDFLAGS) -X $(INTERNAL_PKG).Commit=$(commit) -X $(INTERNAL_PKG).Branch=$(branch)
CGO_ENABLED=0 go build -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf You can add additional GO flags if required, like GOOS, GOARCH, etc. Or add LDFLAGS |
I am not a OpenWrt developer, only a user, but a PR that's comes in here .
The compilation is going fine for the targeted devices but It's only for getting telegraf.conf, it's problematic if the libc or target is different than build system, I have tested that PR, if i am building targeting for glibc x86_64 then of course binary running fine. Thank you for those snippet, it will be coming handy if just like old time, there is already extracted or given telegraf.conf somewhere, other than needs to run telegraf binary first. |
Keep in mind the user, you, can generate this later on. The configuration that is produced is not necessary to run telegraf as it is incomplete and does not include a working output. If a user needs this they can run the command and then go through it. Our own builds will run Hopefully all these various steps help. I am going to close this as I don't think this is actually an issue with Telegraf itself. |
Relevant telegraf.conf
NONE
Logs from Telegraf
System info
OpenWrt x86_64 SNAPSHOT musl
Docker
No response
Steps to reproduce
I am on latest debian SID x86_64 glibc compiling for/targeting OpenWrt x86_64 musl,
Upon execution of telegraf for getting the default config :
I am getting :
On readelf -d telegraf
the /lib/x86_64-linux-gnu/libc.so itself is not a binary but a somekind of script :
On searching, the go should be linking with "/lib/x86_64-linux-gnu/libc.so.6" instead of libc.so.6. How to make go linking with "/lib/x86_64-linux-gnu/libc.so.6" by default and delete libc.so dependency.
On below attached the OpenWrt Makefile for telegraf.
Expected behavior
telegraf binary able to run
Actual behavior
telegraf binary binary not able to run
Additional info
OpenWrt telegraf Makefile :
The text was updated successfully, but these errors were encountered: