Git Product home page Git Product logo

Comments (7)

powersj avatar powersj commented on June 14, 2024

Hi,

Your build file is building with CGO enabled, which is not what we support or do for any of our official builds:

CGO_ENABLED=1

By building with CGO enabled, you building a dynamic binary which will depend on external dependencies rather than a static binary.

from telegraf.

vortexilation avatar vortexilation commented on June 14, 2024

@powersj
I don't know much about golang, I guess in traditional sense, you've meant static linkage?. By "CGO_ENABLED=1" is dynamic linkage?.

And there is no workaround regarding this ?.

from telegraf.

powersj avatar powersj commented on June 14, 2024

I guess in traditional sense, you've meant static linkage?. By "CGO_ENABLED=1" is dynamic linkage?.

Yes, there are a few other consequences as well, but that is the general difference. You can see:

And there is no workaround regarding this ?.

Why do you need to build a dynamic binary? By generating a static binary you avoid this all together.

from telegraf.

vortexilation avatar vortexilation commented on June 14, 2024

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" ?.

from telegraf.

powersj avatar powersj commented on June 14, 2024

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.

I thought someone was already building openwrt builds before. Did something change such that it broke?

other than simple "make build" ?.

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

from telegraf.

vortexilation avatar vortexilation commented on June 14, 2024

I am not a OpenWrt developer, only a user, but a PR that's comes in here .

$(1)/usr/bin/telegraf config > $(1)/etc/telegraf.conf

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.

from telegraf.

powersj avatar powersj commented on June 14, 2024

$(1)/usr/bin/telegraf config > $(1)/etc/telegraf.conf

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 go run ./cmd/telegraf config > etc/telegraf.conf to generate the full config. This avoids running the locally built binary which as you discovered may be built for a different architecture.

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.

from telegraf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.