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

EBPF v2.41. build fails with Amazon Linux 2023 #411

Closed
wkneewalden opened this issue May 14, 2024 · 6 comments
Closed

EBPF v2.41. build fails with Amazon Linux 2023 #411

wkneewalden opened this issue May 14, 2024 · 6 comments

Comments

@wkneewalden
Copy link

Attempted build for EBPF v2.4.1 on Amazon Linux 2023 with following commands including prereqs (go > 1.20):

wget https://go.dev/dl/go1.22.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xvzf go1.22.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
sudo yum install -y clang zlib-devel elfutils-libelf-devel zlib-static glibc-static
sudo yum install -y git make
wget https://github.com/cloudflare/ebpf_exporter/archive/refs/tags/v2.4.1.tar.gz
tar -xvzf v2.4.1.tar.gz
mv ebpf_exporter-2.4.1/ ebpf_exporter/
cd ebpf_exporter/
sudo bash
export PATH=$PATH:/usr/local/go/bin
make build

Did not include 'elfutils-libelf-devel-static' in prereq list as this is not included in Amazon Linux 2023, but it was in Amazon Linux 2 where build worked. However, in Amazon Linux 2023 after prereq installs above can see libelf here:

./usr/lib64/libelf-0.188.so
./usr/lib64/libelf.so.1
./usr/lib64/pkgconfig/libelf.pc
./usr/lib64/libelf.so
./usr/include/libelf.h

Build attempt resulted in this error related to missing -lelf:

[root@ip-XX-XX-XXX-XX ebpf_exporter]# make build
make build-binary GO_LDFLAGS='-extldflags "-static"'
make[1]: Entering directory '/home/ec2-user/ebpf_exporter'
make clean-libbpf
make[2]: Entering directory '/home/ec2-user/ebpf_exporter'
rm -rf /home/ec2-user/ebpf_exporter/libbpf
make[2]: Leaving directory '/home/ec2-user/ebpf_exporter'
git clone --branch v1.3.0 --depth 1 https://github.com/libbpf/libbpf.git /home/ec2-user/ebpf_exporter/libbpf
Cloning into '/home/ec2-user/ebpf_exporter/libbpf'...
remote: Enumerating objects: 154, done.
remote: Counting objects: 100% (154/154), done.
remote: Compressing objects: 100% (141/141), done.
remote: Total 154 (delta 0), reused 67 (delta 0), pack-reused 0
Receiving objects: 100% (154/154), 2.30 MiB | 5.65 MiB/s, done.
Note: switching to '20c0a9e3d7e7d4aeb283eae982543c9cacc29477'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

make -C /home/ec2-user/ebpf_exporter/libbpf/src LIBSUBDIR=lib DESTDIR=../dest install install_uapi_headers
make[2]: Entering directory '/home/ec2-user/ebpf_exporter/libbpf/src'
  MKDIR    staticobjs
  CC       staticobjs/bpf.o
  CC       staticobjs/btf.o
  CC       staticobjs/libbpf.o
  CC       staticobjs/libbpf_errno.o
  CC       staticobjs/netlink.o
  CC       staticobjs/nlattr.o
  CC       staticobjs/str_error.o
  CC       staticobjs/libbpf_probes.o
  CC       staticobjs/bpf_prog_linfo.o
  CC       staticobjs/btf_dump.o
  CC       staticobjs/hashmap.o
  CC       staticobjs/ringbuf.o
  CC       staticobjs/strset.o
  CC       staticobjs/linker.o
  CC       staticobjs/gen_loader.o
  CC       staticobjs/relo_core.o
  CC       staticobjs/usdt.o
  CC       staticobjs/zip.o
  CC       staticobjs/elf.o
  AR       libbpf.a
  MKDIR    sharedobjs
  CC       sharedobjs/bpf.o
  CC       sharedobjs/btf.o
  CC       sharedobjs/libbpf.o
  CC       sharedobjs/libbpf_errno.o
  CC       sharedobjs/netlink.o
  CC       sharedobjs/nlattr.o
  CC       sharedobjs/str_error.o
  CC       sharedobjs/libbpf_probes.o
  CC       sharedobjs/bpf_prog_linfo.o
  CC       sharedobjs/btf_dump.o
  CC       sharedobjs/hashmap.o
  CC       sharedobjs/ringbuf.o
  CC       sharedobjs/strset.o
  CC       sharedobjs/linker.o
  CC       sharedobjs/gen_loader.o
  CC       sharedobjs/relo_core.o
  CC       sharedobjs/usdt.o
  CC       sharedobjs/zip.o
  CC       sharedobjs/elf.o
  CC       libbpf.so.1.3.0
  INSTALL  bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h bpf_helpers.h bpf_helper_defs.h bpf_tracing.h bpf_endian.h bpf_core_read.h skel_internal.h libbpf_version.h usdt.bpf.h
  INSTALL  ./libbpf.pc
  INSTALL  ./libbpf.a ./libbpf.so ./libbpf.so.1 ./libbpf.so.1.3.0
  INSTALL  ../include/uapi/linux/bpf.h ../include/uapi/linux/bpf_common.h ../include/uapi/linux/btf.h
make[2]: Leaving directory '/home/ec2-user/ebpf_exporter/libbpf/src'
CGO_LDFLAGS="-l bpf -L/home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib" CGO_CFLAGS="-I/home/ec2-user/ebpf_exporter/libbpf/dest/usr/include" go build -o ebpf_exporter -v -ldflags="-extldflags "-static" -X github.com/prometheus/common/version.Version=unknown -X github.com/prometheus/common/version.Branch=unknown -X github.com/prometheus/common/version.Revision=unknown -X github.com/prometheus/common/[email protected] -X github.com/prometheus/common/version.BuildDate=2024-05-14T22:00:17+00:00" ./cmd/ebpf_exporter
go: downloading github.com/aquasecurity/libbpfgo v0.6.0-libbpf-1.3
go: downloading github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
go: downloading github.com/mdlayher/sdnotify v1.0.0
go: downloading github.com/prometheus/client_golang v1.19.0
go: downloading github.com/prometheus/common v0.51.1
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading kernel.org/pub/linux/libs/security/libcap/cap v1.2.69
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/elastic/go-perf v0.0.0-20191212140718-9c656876f595
go: downloading github.com/iovisor/gobpf v0.2.0
go: downloading go.opentelemetry.io/otel v1.24.0
go: downloading go.opentelemetry.io/otel/trace v1.24.0
go: downloading golang.org/x/sys v0.18.0
go: downloading go.opentelemetry.io/contrib/exporters/autoexport v0.49.0
go: downloading go.opentelemetry.io/otel/sdk v1.24.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.2.0
go: downloading github.com/prometheus/client_model v0.6.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading google.golang.org/protobuf v1.33.0
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
go: downloading kernel.org/pub/linux/libs/security/libcap/psx v1.2.69
go: downloading github.com/jaypipes/pcidb v1.0.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/prometheus v0.46.0
go: downloading go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.24.0
go: downloading go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0
go: downloading go.opentelemetry.io/otel/sdk/metric v1.24.0
go: downloading github.com/go-logr/logr v1.4.1
go: downloading go.opentelemetry.io/otel/metric v1.24.0
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading go.opentelemetry.io/proto/otlp v1.1.0
go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c
go: downloading google.golang.org/grpc v1.62.0
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/cenkalti/backoff/v4 v4.2.1
go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
go: downloading golang.org/x/net v0.22.0
go: downloading github.com/golang/protobuf v1.5.3
go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c
go: downloading golang.org/x/text v0.14.0
internal/goarch
internal/unsafeheader
internal/cpu
internal/abi
internal/bytealg
internal/chacha8rand
internal/coverage/rtcov
internal/godebugs
internal/goexperiment
internal/goos
runtime/internal/atomic
runtime/internal/math
runtime/internal/sys
runtime/internal/syscall
internal/itoa
math/bits
runtime
math
unicode/utf8
internal/race
sync/atomic
unicode
cmp
slices
internal/nettrace
encoding
log/internal
container/list
crypto/internal/alias
crypto/subtle
crypto/internal/boring/sig
unicode/utf16
vendor/golang.org/x/crypto/cryptobyte/asn1
vendor/golang.org/x/crypto/internal/alias
google.golang.org/protobuf/internal/flags
google.golang.org/protobuf/internal/set
log/slog/internal
go.opentelemetry.io/otel/internal
go.opentelemetry.io/otel/metric/embedded
go.opentelemetry.io/otel/trace/embedded
go.opentelemetry.io/otel/sdk/instrumentation
go.opentelemetry.io/otel/sdk/metric/internal
go.opentelemetry.io/otel/sdk
google.golang.org/grpc/serviceconfig
internal/reflectlite
sync
internal/testlog
internal/bisect
errors
sort
strconv
io
reflect
internal/oserror
syscall
internal/syscall/unix
time
internal/fmtsort
internal/safefilepath
internal/syscall/execenv
path
bytes
internal/poll
io/fs
strings
os
bufio
encoding/binary
fmt
hash
hash/adler32
internal/saferio
context
vendor/golang.org/x/net/dns/dnsmessage
compress/flate
compress/zlib
debug/dwarf
internal/zstd
internal/godebug
internal/singleflight
internal/intern
net/netip
debug/elf
runtime/cgo
path/filepath
encoding/base64
regexp/syntax
net
regexp
gopkg.in/yaml.v2
github.com/cloudflare/ebpf_exporter/v2/config
encoding/hex
github.com/cloudflare/ebpf_exporter/v2/util
golang.org/x/sys/unix
github.com/aquasecurity/libbpfgo
io/ioutil
kernel.org/pub/linux/libs/security/libcap/psx
kernel.org/pub/linux/libs/security/libcap/cap
log
github.com/cloudflare/ebpf_exporter/v2/cgroup
github.com/cloudflare/ebpf_exporter/v2/kallsyms
hash/crc32
compress/gzip
os/exec
github.com/mitchellh/go-homedir
crypto
crypto/cipher
crypto/internal/boring
crypto/internal/randutil
math/rand
math/big
crypto/rand
crypto/aes
crypto/des
crypto/internal/edwards25519/field
crypto/internal/nistec/fiat
embed
crypto/internal/nistec
crypto/ecdh
crypto/elliptic
crypto/internal/bigmod
crypto/internal/boring/bbig
crypto/sha512
encoding/asn1
vendor/golang.org/x/crypto/cryptobyte
crypto/ecdsa
crypto/internal/edwards25519
crypto/ed25519
crypto/hmac
crypto/md5
crypto/rc4
crypto/rsa
crypto/sha1
crypto/sha256
crypto/dsa
crypto/x509/pkix
encoding/pem
net/url
crypto/x509
vendor/golang.org/x/crypto/chacha20
vendor/golang.org/x/crypto/internal/poly1305
vendor/golang.org/x/sys/cpu
vendor/golang.org/x/crypto/chacha20poly1305
vendor/golang.org/x/crypto/hkdf
crypto/tls
vendor/golang.org/x/text/transform
vendor/golang.org/x/text/unicode/bidi
vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/secure/bidirule
net/textproto
vendor/golang.org/x/net/http2/hpack
vendor/golang.org/x/net/idna
mime
vendor/golang.org/x/net/http/httpguts
vendor/golang.org/x/net/http/httpproxy
mime/quotedprintable
net/http/httptrace
net/http/internal
mime/multipart
net/http/internal/ascii
encoding/json
net/http
github.com/beorn7/perks/quantile
github.com/cespare/xxhash/v2
hash/fnv
google.golang.org/protobuf/internal/detrand
google.golang.org/protobuf/internal/errors
google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/internal/pragma
google.golang.org/protobuf/reflect/protoreflect
google.golang.org/protobuf/internal/descfmt
google.golang.org/protobuf/internal/descopts
google.golang.org/protobuf/internal/editiondefaults
go/token
google.golang.org/protobuf/internal/strs
google.golang.org/protobuf/internal/encoding/text
google.golang.org/protobuf/internal/encoding/defval
google.golang.org/protobuf/internal/encoding/messageset
google.golang.org/protobuf/internal/genid
google.golang.org/protobuf/internal/order
google.golang.org/protobuf/reflect/protoregistry
google.golang.org/protobuf/runtime/protoiface
google.golang.org/protobuf/proto
google.golang.org/protobuf/internal/filedesc
google.golang.org/protobuf/encoding/prototext
github.com/jaypipes/pcidb
expvar
github.com/cloudflare/ebpf_exporter/v2/decoder
google.golang.org/protobuf/internal/encoding/tag
google.golang.org/protobuf/internal/impl
google.golang.org/protobuf/internal/version
runtime/metrics
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
google.golang.org/protobuf/encoding/protodelim
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
github.com/prometheus/procfs
runtime/debug
log/slog/internal/buffer
log/slog
google.golang.org/protobuf/internal/filetype
google.golang.org/protobuf/runtime/protoimpl
google.golang.org/protobuf/types/known/timestamppb
github.com/go-logr/logr
github.com/prometheus/client_model/go
github.com/go-logr/logr/funcr
github.com/prometheus/common/model
github.com/go-logr/stdr
go.opentelemetry.io/otel/internal/attribute
go.opentelemetry.io/otel/attribute
go.opentelemetry.io/otel/codes
go.opentelemetry.io/otel/metric
github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/common/expfmt
go.opentelemetry.io/otel/internal/baggage
go.opentelemetry.io/otel/baggage
go.opentelemetry.io/otel/trace
github.com/prometheus/client_golang/prometheus
go.opentelemetry.io/otel/propagation
go.opentelemetry.io/otel/internal/global
go.opentelemetry.io/otel
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/envconfig
github.com/cenkalti/backoff/v4
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/retry
go.opentelemetry.io/otel/metric/noop
go.opentelemetry.io/otel/semconv/v1.24.0
github.com/prometheus/client_golang/prometheus/promhttp
os/user
go.opentelemetry.io/otel/sdk/metric/internal/x
golang.org/x/net/internal/timeseries
html
text/template/parse
go.opentelemetry.io/otel/sdk/resource
go.opentelemetry.io/otel/sdk/metric/metricdata
go.opentelemetry.io/otel/sdk/metric/internal/exemplar
go.opentelemetry.io/otel/sdk/metric/internal/aggregate
text/template
go.opentelemetry.io/otel/sdk/metric
html/template
text/tabwriter
golang.org/x/net/trace
google.golang.org/grpc/backoff
google.golang.org/grpc/internal/grpclog
google.golang.org/grpc/grpclog
google.golang.org/grpc/connectivity
google.golang.org/protobuf/types/descriptorpb
google.golang.org/grpc/attributes
google.golang.org/grpc/internal/credentials
google.golang.org/grpc/internal/grpcrand
google.golang.org/grpc/internal/envconfig
google.golang.org/protobuf/protoadapt
google.golang.org/grpc/internal/backoff
google.golang.org/protobuf/types/known/durationpb
google.golang.org/grpc/binarylog/grpc_binarylog_v1
google.golang.org/protobuf/types/known/anypb
google.golang.org/protobuf/types/gofeaturespb
google.golang.org/genproto/googleapis/rpc/status
google.golang.org/protobuf/reflect/protodesc
google.golang.org/grpc/internal/buffer
google.golang.org/grpc/internal/grpcsync
google.golang.org/grpc/internal/idle
google.golang.org/protobuf/internal/encoding/json
google.golang.org/protobuf/encoding/protojson
github.com/golang/protobuf/proto
golang.org/x/text/transform
golang.org/x/text/unicode/bidi
google.golang.org/grpc/credentials
google.golang.org/grpc/resolver
google.golang.org/grpc/credentials/insecure
google.golang.org/grpc/internal
google.golang.org/grpc/internal/pretty
google.golang.org/grpc/internal/resolver/passthrough
google.golang.org/grpc/internal/channelz
google.golang.org/grpc/metadata
google.golang.org/grpc/codes
google.golang.org/grpc/internal/grpcutil
google.golang.org/grpc/encoding
google.golang.org/grpc/encoding/proto
google.golang.org/grpc/internal/balancerload
google.golang.org/grpc/channelz
google.golang.org/grpc/internal/status
google.golang.org/grpc/balancer
google.golang.org/grpc/status
google.golang.org/grpc/balancer/base
google.golang.org/grpc/internal/binarylog
google.golang.org/grpc/balancer/roundrobin
google.golang.org/grpc/internal/balancer/gracefulswitch
google.golang.org/grpc/internal/metadata
google.golang.org/grpc/internal/serviceconfig
google.golang.org/grpc/internal/transport/networktype
google.golang.org/grpc/internal/resolver/unix
google.golang.org/grpc/internal/resolver
golang.org/x/text/secure/bidirule
golang.org/x/text/unicode/norm
golang.org/x/net/http2/hpack
google.golang.org/grpc/internal/syscall
google.golang.org/grpc/keepalive
google.golang.org/grpc/peer
google.golang.org/grpc/stats
google.golang.org/grpc/tap
net/http/httputil
golang.org/x/net/idna
google.golang.org/grpc/balancer/grpclb/state
golang.org/x/net/http/httpguts
google.golang.org/grpc/internal/resolver/dns/internal
google.golang.org/grpc/internal/resolver/dns
golang.org/x/net/http2
google.golang.org/grpc/resolver/dns
google.golang.org/grpc/encoding/gzip
go.opentelemetry.io/proto/otlp/common/v1
go.opentelemetry.io/proto/otlp/resource/v1
go.opentelemetry.io/proto/otlp/metrics/v1
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform
flag
github.com/grpc-ecosystem/grpc-gateway/v2/utilities
github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule
google.golang.org/genproto/googleapis/api/httpbody
google.golang.org/protobuf/types/known/fieldmaskpb
google.golang.org/protobuf/types/known/structpb
google.golang.org/protobuf/types/known/wrapperspb
google.golang.org/genproto/googleapis/rpc/errdetails
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal/envconfig
google.golang.org/grpc/internal/transport
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal/retry
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform
go.opentelemetry.io/otel/sdk/internal
go.opentelemetry.io/otel/sdk/internal/env
go.opentelemetry.io/otel/trace/noop
runtime/trace
go.opentelemetry.io/otel/sdk/trace
google.golang.org/grpc
go.opentelemetry.io/proto/otlp/trace/v1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform
go.opentelemetry.io/otel/exporters/otlp/otlptrace
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry
go.opentelemetry.io/otel/exporters/prometheus
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric
go.opentelemetry.io/otel/sdk/trace/tracetest
go.opentelemetry.io/otel/exporters/stdout/stdouttrace
go.opentelemetry.io/otel/semconv/v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/oconf
google.golang.org/grpc/health/grpc_health_v1
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal/oconf
github.com/grpc-ecosystem/grpc-gateway/v2/runtime
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig
github.com/elastic/go-perf
go.opentelemetry.io/proto/otlp/collector/metrics/v1
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
go.opentelemetry.io/proto/otlp/collector/trace/v1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
github.com/iovisor/gobpf/pkg/cpurange
github.com/iovisor/gobpf/pkg/cpuonline
github.com/coreos/go-systemd/activation
go.opentelemetry.io/contrib/exporters/autoexport
github.com/mdlayher/sdnotify
github.com/prometheus/common/version
github.com/prometheus/client_golang/prometheus/collectors/version
github.com/alecthomas/template/parse
github.com/cloudflare/ebpf_exporter/v2/tracing
github.com/cloudflare/ebpf_exporter/v2/exporter
github.com/alecthomas/template
github.com/alecthomas/units
go/scanner
go/ast
go/doc/comment
internal/lazyregexp
internal/profile
go/doc
gopkg.in/alecthomas/kingpin.v2
runtime/pprof
net/http/pprof
github.com/cloudflare/ebpf_exporter/v2/cmd/ebpf_exporter
# github.com/cloudflare/ebpf_exporter/v2/cmd/ebpf_exporter
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: cannot find -lelf: No such file or directory
/usr/bin/ld: /tmp/go-link-2711201152/000055.o: in function `mygetgrouplist':
getgrouplist_unix.cgo2.c:(.text+0x60): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-2711201152/000054.o: in function `mygetgrgid_r':
cgo_lookup_cgo.cgo2.c:(.text+0x1d9): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-2711201152/000054.o: in function `mygetgrnam_r':
cgo_lookup_cgo.cgo2.c:(.text+0x270): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-2711201152/000054.o: in function `mygetpwnam_r':
cgo_lookup_cgo.cgo2.c:(.text+0x131): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-2711201152/000054.o: in function `mygetpwuid_r':
cgo_lookup_cgo.cgo2.c:(.text+0x85): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /tmp/go-link-2711201152/000004.o: in function `_cgo_97ab22c4dc7b_C2func_getaddrinfo':
cgo_unix_cgo.cgo2.c:(.text+0x81): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status

make[1]: *** [Makefile:81: build-binary] Error 1
make[1]: Leaving directory '/home/ec2-user/ebpf_exporter'
make: *** [Makefile:73: build-static] Error 2
@bobrik
Copy link
Contributor

bobrik commented May 14, 2024

You are trying to build a static binary, but you do not have libelf.a:

/usr/bin/ld: cannot find -lelf: No such file or directory

You need to either install libelf.a on your host or build a dynamically linked binary with make build-dynamic.

@wkneewalden
Copy link
Author

Thanks! I tried make build-dynamic and build completed, same with examples build using make -C examples clean build. However logs indicate error when exporter runs:

 /home/ec2-user/ebpf_exporter/ebpf_exporter: error while loading shared libraries: libbpf.so.1: cannot open shared object file: No such file or directory
ebpf_exporter.service: Main process exited, code=exited, status=127/n/a

Guessing that make build-dynamic BUILD_LIBBPF=0 is required then? There are libraries existing:

./usr/include/bpf/libbpf.h
./usr/include/bpf/libbpf_common.h
./usr/include/bpf/libbpf_legacy.h
./usr/include/bpf/libbpf_version.h
./home/ec2-user/ebpf_exporter/libbpf
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-compact-darkbg.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-compact-mono.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-compact.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sideways-darkbg.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sideways-mono.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sideways.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sparse-darkbg.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sparse-mono.png
./home/ec2-user/ebpf_exporter/libbpf/assets/libbpf-logo-sparse.png
./home/ec2-user/ebpf_exporter/libbpf/docs/libbpf_build.rst
./home/ec2-user/ebpf_exporter/libbpf/docs/libbpf_naming_convention.rst
./home/ec2-user/ebpf_exporter/libbpf/docs/libbpf_overview.rst
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.c
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.h
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.map
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.pc.template
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_common.h
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_errno.c
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_internal.h
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_legacy.h
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_probes.c
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf_version.h
./home/ec2-user/ebpf_exporter/libbpf/src/staticobjs/libbpf.o
./home/ec2-user/ebpf_exporter/libbpf/src/staticobjs/libbpf_errno.o
./home/ec2-user/ebpf_exporter/libbpf/src/staticobjs/libbpf_probes.o
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.a
./home/ec2-user/ebpf_exporter/libbpf/src/sharedobjs/libbpf.o
./home/ec2-user/ebpf_exporter/libbpf/src/sharedobjs/libbpf_errno.o
./home/ec2-user/ebpf_exporter/libbpf/src/sharedobjs/libbpf_probes.o
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.so.1.3.0
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.so.1
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.so
./home/ec2-user/ebpf_exporter/libbpf/src/libbpf.pc
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/include/bpf/libbpf.h
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/include/bpf/libbpf_common.h
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/include/bpf/libbpf_legacy.h
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/include/bpf/libbpf_version.h
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib/pkgconfig/libbpf.pc
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib/libbpf.a
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib/libbpf.so
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib/libbpf.so.1
./home/ec2-user/ebpf_exporter/libbpf/dest/usr/lib/libbpf.so.1.3.0
./root/go/pkg/mod/cache/download/github.com/aquasecurity/libbpfgo
./root/go/pkg/mod/github.com/aquasecurity/[email protected]
./root/go/pkg/mod/github.com/aquasecurity/[email protected]/libbpf_cb.go
./root/go/pkg/mod/github.com/aquasecurity/[email protected]/libbpfgo.c
./root/go/pkg/mod/github.com/aquasecurity/[email protected]/libbpfgo.go
./root/go/pkg/mod/github.com/aquasecurity/[email protected]/libbpfgo.h
./root/go/pkg/mod/github.com/aquasecurity/[email protected]/selftest/build/libbpfgo_test.bpf.c
./root/go/pkg/mod/github.com/iovisor/[email protected]/elf/include/libbpf.h

@bobrik
Copy link
Contributor

bobrik commented May 14, 2024

You need to set LD_LIBRARY_PATH to where your libbpf.so.1 is (libbpf/src/ in the build dir) or you need to install libbpf on your system.

@bobrik
Copy link
Contributor

bobrik commented May 14, 2024

BUILD_LIBBPF=0 might also work.

@wkneewalden
Copy link
Author

wkneewalden commented May 15, 2024

Thanks a lot! Assigning LD_LIBRARY_PATH resolved issue.

@wkneewalden
Copy link
Author

Also mentioning that v2.4.1 fixed issue with PCI ID error on start up in Amazon Linux distros. #377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants