falcosecurity / event-generator

Generate a variety of suspect actions that are detected by Falco rulesets
Apache License 2.0
95 stars 40 forks source link

build: fix cross-compilation #228

Closed jacalvo closed 1 month ago

jacalvo commented 1 month ago

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind documentation

/kind tests

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area commands

/area pkg

/area events

What this PR does / why we need it:

On a Mac M1, trying to cross-compile for linux/amd64 fails when trying to run the file-bundler tool with the wrong arch:

$ GOOS=linux GOARCH=amd64 make
rm -f -R event-generator
rm -f events/k8saudit/yaml/bundle.go
rm -f -R event-generator evtgen-docgen
go run ./tools/file-bundler/ events/k8saudit/yaml
fork/exec /var/folders/t_/1ckd5szj47g4pcb36j5zgmnr0000gp/T/go-build630400765/b001/exe/file-bundler: exec format error
make: *** [events/k8saudit/yaml/bundle.go] Error 1

After this fix unsetting the values for those vars to use the system default it works:

$ GOOS=linux GOARCH=amd64 make
rm -f -R event-generator
rm -f events/k8saudit/yaml/bundle.go
rm -f -R event-generator evtgen-docgen
GOOS= GOARCH= go run ./tools/file-bundler/ events/k8saudit/yaml
CGO_ENABLED=0 go build -buildmode=pie -buildvcs=false -ldflags "-X k8s.io/client-go/pkg/version.gitCommit=v0.31.1 -X k8s.io/client-go/pkg/version.gitVersion=v0.12.0-3-g120ae6f" -o event-generator .

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

poiana commented 1 month ago

Welcome @jacalvo! It looks like this is your first PR to falcosecurity/event-generator 🎉

poiana commented 1 month ago

LGTM label has been added.

Git tree hash: b6c1ce7fba95bf8c8a49766cd673bff61a534a63

poiana commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alacuku, jacalvo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/falcosecurity/event-generator/blob/main/OWNERS)~~ [alacuku] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment