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?

This isn’t working for me even with your branch.

[main]     2021-08-08 14:00:31 (38.2 MB/s) - ‘kernel_modules_headers.tar.gz’ saved [12334251/12334251]
[main]     
[main]     make: Entering directory '/tmp/tmp.1VPby1ZUzA'
[main]       CC [M]  /usr/src/app/output/example_module_raspberrypicm4-ioboard_2.71.3+rev5.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]     scripts/Makefile.build:265: recipe for target '/usr/src/app/output/example_module_raspberrypicm4-ioboard_2.71.3+rev5.prod/hello.o' failed
[main]     make[1]: *** [/usr/src/app/output/example_module_raspberrypicm4-ioboard_2.71.3+rev5.prod/hello.o] Error 1
[main]     
[main]     Makefile:1732: recipe for target '/usr/src/app/output/example_module_raspberrypicm4-ioboard_2.71.3+rev5.prod' failed
[main]     make: Leaving directory '/tmp/tmp.1VPby1ZUzA'
[main]     make: *** [/usr/src/app/output/example_module_raspberrypicm4-ioboard_2.71.3+rev5.prod] Error 2
[main]     
[main]     Removing intermediate container 30aa27479d54
[main]     The command '/bin/sh -c BALENA_MACHINE_NAME=raspberrypicm4-ioboard ./build.sh build --device raspberrypicm4-ioboard --os-version "$VERSION" --src example_module' returned a non-zero code: 2

@jleppert This works for me using the gcc-10 branch. I even used raspberrypicm4-ioboard and 2.71.3+rev5 to be sure. Can you confirm from the top of your build log that gcc-10 is being installed?

Selecting previously unselected package g++-10.
Preparing to unpack .../14-g++-10_10.2.1-6_arm64.deb ...
Unpacking g++-10 (10.2.1-6) ...
Preparing to unpack .../15-g++_4%3a10.2.1-1_arm64.deb ...
Unpacking g++ (4:10.2.1-1) over (4:8.3.0-1) ...
(Reading database ... 20908 files and directories currently installed.)
Removing g++-8 (8.3.0-6) ...
Removing gcc-8 (8.3.0-6) ...