# Error when compiling kernel module in the kernel module build example

**URL:** <https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256>\
**Category:** Product support\
**Tags:** docker, kernelmodules, kernel-module, raspberrypi4\
**Created:** [April 30, 2021, 11:18am UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256 "2021-04-30T11:18:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhan.charler](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jhan.charler](https://forums.balena.io/u/jhan.charler)\
**Post date:** [April 30, 2021, 11:18am UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/1 "2021-04-30T11:18:05Z")

</div>

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](https://github.com/balena-os/kernel-module-build))

Here is the log:

```auto
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:

 ![image](https://global.discourse-cdn.com/balena/original/2X/4/4a8646a1505e5d9bf5d496a0e21d683d449ba2d1.png)

---

<div class="post-metadata">

**Author:** ![gelbal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gelbal/32/1109_2.png) [@gelbal](https://forums.balena.io/u/gelbal)\
**Post date:** [April 30, 2021, 1:24pm UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/2 "2021-04-30T13:24:10Z")

</div>

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

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.

---

<div class="post-metadata">

**Author:** ![jhan.charler](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jhan.charler](https://forums.balena.io/u/jhan.charler)\
**Post date:** [April 30, 2021, 1:39pm UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/4 "2021-04-30T13:39:31Z")

</div>

Hi @gelbal , here is the project: [GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena](https://github.com/balena-os/kernel-module-build)

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.

---

<div class="post-metadata">

**Author:** ![klutchell](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/klutchell/32/861_2.png) [@klutchell](https://forums.balena.io/u/klutchell)\
**Post date:** [April 30, 2021, 4:27pm UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/6 "2021-04-30T16:27:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jleppert](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jleppert](https://forums.balena.io/u/jleppert)\
**Post date:** [August 8, 2021, 2:17pm UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/9 "2021-08-08T14:17:07Z")

</div>

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

```auto
[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

```

---

<div class="post-metadata">

**Author:** ![klutchell](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/klutchell/32/861_2.png) [@klutchell](https://forums.balena.io/u/klutchell)\
**Post date:** [August 19, 2021, 3:51pm UTC](https://forums.balena.io/t/error-when-compiling-kernel-module-in-the-kernel-module-build-example/306256/10 "2021-08-19T15:51:23Z")

</div>

@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?

```auto
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) ...

```
