netobserv / flowlogs-pipeline

Transform flow logs into metrics
Apache License 2.0
69 stars 21 forks source link

unable to build with M1 #477

Open aslom opened 10 months ago

aslom commented 10 months ago

It seems go should be enough to build local version? That owuld be great for local testing ...

It fails on macbook M1:

$ make build
(re)installing /Users/aslom/Documents/awsm/go/src/github.ibm.com/z-cloud-integration/flowlogs-pipeline/bin/golangci-lint-v1.53.3
/Users/aslom/Documents/awsm/go/src/github.ibm.com/z-cloud-integration/flowlogs-pipeline/bin/golangci-lint-v1.53.3 run --enable goimports --enable gofmt --enable ineffassign --timeout 5m
/Users/aslom/Documents/awsm/go/src/github.ibm.com/z-cloud-integration/flowlogs-pipeline/bin/golangci-lint-v1.53.3: /Users/aslom/Documents/awsm/go/src/github.ibm.com/z-cloud-integration/flowlogs-pipeline/bin/golangci-lint-v1.53.3: cannot execute binary file
make: *** [lint] Error 126

Macbook pro 16 M1:

$ uname -a
Darwin m1.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
$ sw_vers
ProductName:        macOS
ProductVersion:     13.5.1
BuildVersion:       22G90
aslom commented 10 months ago

Here is workaround for current version - if go build fails:

$ go build -ldflags "-X 'main.BuildVersion=0.1.10-rc1-daa0340-dirty' -X 'main.BuildDate=2023-08-30 13:26'" "./cmd/flowlogs-pipeline"
# github.com/netobserv/netobserv-ebpf-agent/pkg/utils
vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go:76:18: undefined: syscall.Utsname
vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go:77:20: undefined: syscall.Uname
vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go:80:42: cannot infer T (/Users/aslom/Documents.../vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go:84:17)

then patch vendor/github.com/netobserv/netobserv-ebpf-agent/pkg/utils/utils.go

 func currentKernelVersion() (uint32, error) {
-       var buf syscall.Utsname
-       if err := syscall.Uname(&buf); err != nil {
-               return 0, err
-       }
-       releaseString := strings.Trim(utsnameStr(buf.Release[:]), "\x00")
+       // var buf syscall.Utsname
+       // if err := syscall.Uname(&buf); err != nil {
+       //      return 0, err
+       // }
+       // releaseString := strings.Trim(utsnameStr(buf.Release[:]), "\x00")
+       releaseString := "macos"
        return kernelVersionFromReleaseString(releaseString)
 }

then build works:

$ file flowlogs-pipeline flowlogs-pipeline: Mach-O 64-bit executable arm64 ./flowlogs-pipeline -h Transform, persist and expose flow-logs as network metrics ...



@ronensc