Git Product home page Git Product logo

Comments (4)

rafaeldtinoco avatar rafaeldtinoco commented on May 25, 2024

This was somehow handled by:

#28

But now we have to address the following:

#28 (comment)

So I would say this issue has become the issue described above.

from libbpfgo.

rafaeldtinoco avatar rafaeldtinoco commented on May 25, 2024

The Makefile file in tracee uses pkgconfig for the libbpf static compilation:

image

libbpfgo could do the same and use:

// #cgo pkg-config: libelf zlib

to have this issue addressed.

from libbpfgo.

ShubhamPalriwala avatar ShubhamPalriwala commented on May 25, 2024

Just faced the exact same bug when trying to run a test here in Tracee with:

tracee/cmd/tracee-ebpf/internal/printer
go test -v

from libbpfgo.

MaciekLeks avatar MaciekLeks commented on May 25, 2024

I've struggled the same or almost the same "thing".
So, this code does not work:

CGO_CFLAGS_STATIC = "-I$(abspath $(LIBBPF_DIR))"
CGO_LDFLAGS_STATIC = "-lelf -lz $(LIBBPF_STATIC_LIB)"
CGO_EXTLDFLAGS_STATIC = '-w -extldflags "-static"'
.PHONY: k8s-build-cmd
k8s-build-cmd:  $(CMD_K8S_GO_SOURCE) $(TARGET_BPF) 
	CGO_CFLAGS=$(CGO_CFLAGS_STATIC) \
	CGO_LDFLAGS=$(CGO_LDFLAGS_STATIC) \
	$(GO) build -x \
	-tags netgo -ldflags $(CGO_EXTLDFLAGS_STATIC) \
	-o $(TARGET_K8S) ./cmd/kubernetes/$(MAIN).go

but this works well:

CGO_CFLAGS_STATIC = "-I$(abspath $(LIBBPF_DIR))"
CGO_LDFLAGS_STATIC = "-lelf -lz $(LIBBPF_STATIC_LIB)"
GO_EXTLDFLAGS_STATIC = '-w -extldflags "-static $(LIBBPF_STATIC_LIB) -lelf -lz"'
#^ librabbry order is important for GO_EXTLDFLAGS_STATIC
k8s-build-cmd: $(CMD_K8S_GO_SOURCE) $(TARGET_BPF)
	CGO_CFLAGS=$(CGO_CFLAGS_STATIC) \
	$(GO) build -x \
	-tags netgo -ldflags $(GO_EXTLDFLAGS_STATIC) \
	-o $(TARGET_K8S) ./cmd/kubernetes/$(MAIN).go

So, the only difference is moving LDFLAGS on the go build level and changing order of the libs.

from libbpfgo.

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.