falcosecurity / driverkit

Kit for building Falco drivers: kernel modules or eBPF probes
Apache License 2.0
62 stars 52 forks source link

chore(pkg/driverbuiler): avoid overriding `CC` at build time. #322

Closed FedeDP closed 4 months ago

FedeDP commented 4 months ago

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

/area pkg

What this PR does / why we need it:

Instead, set CMAKE_C_COMPILER variable at cmake configure step.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE
poiana commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP

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/driverkit/blob/master/OWNERS)~~ [FedeDP] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
FedeDP commented 4 months ago

Uh it seems like debian for example (but possible other builders) overriddes CC in the kernel sources makefiles, using the gcc it was built with; in Debian, we set CMAKE_C_COMPILER to /usr/bin/gcc-11.0.0 but then it tries to build it using gcc-10:

level=DEBUG msg="+ cmake -Wno-dev -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME=falco -DPROBE_NAME=falco -DBUILD_BPF=On -DDRIVER_VERSION=17f5df52a7d9ed6bb12d3b1768460def8439936d -DPROBE_VERSION=17f5df52a7d9ed6bb12d3b1768460def8439936d -DGIT_COMMIT=17f5df52a7d9ed6bb12d3b1768460def8439936d -DDRIVER_DEVICE_NAME=falco -DPROBE_DEVICE_NAME=falco -DCMAKE_C_COMPILER=/usr/bin/gcc-11.0.0 .."

...

level=DEBUG msg="make[6]: gcc-10: No such file or directory"

and indeed:

level=DEBUG msg="+ grep -R CC_VERSION /usr/src/linux-headers-5.10.0-10-amd64" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/scripts/Kbuild.include:cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/.config:CONFIG_CC_VERSION_TEXT=\"gcc-10 (Debian 10.2.1-6) 10.2.1 20210110\"" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/.config:CONFIG_GCC_VERSION=100201" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/include/generated/autoconf.h:#define CONFIG_CC_VERSION_TEXT \"gcc-10 (Debian 10.2.1-6) 10.2.1 20210110\"" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/include/generated/autoconf.h:#define CONFIG_GCC_VERSION 100201" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/include/config/auto.conf:CONFIG_CC_VERSION_TEXT=\"gcc-10 (Debian 10.2.1-6) 10.2.1 20210110\"" level=DEBUG msg="/usr/src/linux-headers-5.10.0-10-amd64/include/config/auto.conf:CONFIG_GCC_VERSION=100201"

FedeDP commented 4 months ago

/close

poiana commented 4 months ago

@FedeDP: Closed this PR.

In response to [this](https://github.com/falcosecurity/driverkit/pull/322#issuecomment-1983940476): >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.