Error when compiling kernel module in the kernel module build example

I followed the README in the example, changed the ENV VERSION in the Dockerfile.template file to 2.73.1+rev1.prod, then did a git push balena master to my Balena remote.

Unfortunately I get a GCC error gcc: error: unrecognized command line option '-mstack-protector-guard=sysreg'; did you mean '-fstack-protector-strong'?

The hardware I’m using is a Raspberry Pi 4.

It looks to be an issue with gcc but I can’t find a way to resolve it.

Any help is appreciated!

(Project GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena)

Here is the log:

main]     make: Entering directory '/tmp/tmp.U9THnSfxfP'
[main]       CC [M]  /usr/src/app/output/example_module_raspberrypi4-64_2.73.1+rev1.prod/hello.o
[main]     gcc: error: unrecognized command line option '-mstack-protector-guard=sysreg'; did you mean '-fstack-protector-strong'?
[main]     
[main]     gcc: error: unrecognized command line option '-mstack-protector-guard-reg=sp_el0'; did you mean '-fstack-protector-all'?
[main]     
[main]     gcc: error: unrecognized command line option '-mstack-protector-guard-offset=1336'; did you mean '-fstack-protector-strong'?
[main]     
[main]     make[1]: *** [scripts/Makefile.build:266: /usr/src/app/output/example_module_raspberrypi4-64_2.73.1+rev1.prod/hello.o] Error 1
[main]     
[main]     make: *** [Makefile:1732: /usr/src/app/output/example_module_raspberrypi4-64_2.73.1+rev1.prod] Error 2
[main]     
[main]     make: Leaving directory '/tmp/tmp.U9THnSfxfP'
[main]     Removing intermediate container e9788411e598
[main]     The command '/bin/sh -c BALENA_MACHINE_NAME=raspberrypi4-64 ./build.sh build --device raspberrypi4-64 --os-version "$VERSION" --src example_module' returned a non-zero code: 2
[Info]     Uploading images
[Success]  Successfully uploaded images
[Error]    Some services failed to build:
[Error]      Service: main
[Error]        Error: The command '/bin/sh -c BALENA_MACHINE_NAME=raspberrypi4-64 ./build.sh build --device raspberrypi4-64 --os-version "$VERSION" --src example_module' returned a non-zero code: 2
[Info]     Built on arm02
[Error]    Not deploying release.

And a picture:

Hi @jhan.charler, first of all welcome to the balena community :grinning_face_with_smiling_eyes:

Can you please post a link to the example you are using?
Next, it’d help us with troubleshooting if you could share a minimal dockerfile that produces this error.

As this looks like a compiler error, I wonder if the issue here is the device architecture. Specifically something to do with 64bit architecture of RPi4.

1 Like

Hi @gelbal , here is the project: GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena

I’m just running that project without any modifications except the version number in Dockerfile.

Please let me know if there is any more information is required.

Hey @jhan-charler, I replied directly to your GH issue with a branch that should resolve the GCC 8 issue with recent OS releases. Could you give it a try and respond there if it works and I’ll complete the merge?