Bug #304
closedgcc6: "error: code model kernel does not support PIC mode"
0%
Description
On a Debian Sid compiling for a 4.9-rc3 kernel with gcc 6.2.0-10, I curently get the following error:
root@Linus-Debian:/mnt/batman-adv-t_x# make /mnt/batman-adv-t_x/gen-compat-autoconf.sh /mnt/batman-adv-t_x/compat-autoconf.h mkdir -p /mnt/batman-adv-t_x/build/net/batman-adv/ compat-patches/replacements.sh touch /mnt/batman-adv-t_x/build/net/batman-adv/.compat-prepared make -C /lib/modules/4.9.0-rc3+/build M=/mnt/batman-adv-t_x PWD=/mnt/batman-adv-t_x REVISION=2016.4 CONFIG_BATMAN_ADV=m CONFIG_BATMAN_ADV_DEBUG=n CONFIG_BATMAN_ADV_DEBUGFS=y CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y CONFIG_BATMAN_ADV_NC=n CONFIG_BATMAN_ADV_MCAST=y CONFIG_BATMAN_ADV_BATMAN_V=n INSTALL_MOD_DIR=updates/ modules make[1]: Entering directory '/usr/src/linux-headers-4.9.0-rc3+' cat: -: No such file or directory CC [M] /mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o /mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.c:1:0: error: code model kernel does not support PIC mode /* scripts/Makefile.build:290: recipe for target '/mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o' failed make[3]: *** [/mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o] Error 1 scripts/Makefile.build:475: recipe for target '/mnt/batman-adv-t_x/build/net/batman-adv' failed make[2]: *** [/mnt/batman-adv-t_x/build/net/batman-adv] Error 2 Makefile:1482: recipe for target '_module_/mnt/batman-adv-t_x' failed make[1]: *** [_module_/mnt/batman-adv-t_x] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-rc3+' Makefile:89: recipe for target 'all' failed make: *** [all] Error 2
It seems to have something to do with PIE hardening which got enabled by default in gcc6 last week in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835148
Compiling with '$ make EXTRA_CFLAGS="-fno-pie"' helps.
So my question is, whether this flag should be added to the batman-adv out-of-tree Makefile.
Some comments seem to suggest, that PIE does not work for kernels / kernel modules by design. (I have not looked at what PIE hardening actually is, so I have no clue yet whether disabling is the right choice)
Updated by Sven Eckelmann over 7 years ago
- Status changed from New to Rejected
Problem of Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841420
Updated by Sven Eckelmann over 7 years ago
Seems that Ben gave up and included following patch in his kernel tree: https://anonscm.debian.org/cgit/kernel/linux.git/tree/debian/patches/bugfix/all/kbuild-add-fno-pie.patch?id=25e532ff97db2fb2990e8b6e0fb74a9313255656
But it seems not to be enough. At least when I read following correctly: https://www.spinics.net/lists/linux-kbuild/msg13620.html
So I would still say that it is not a flag we should include but which should be included in the kernel. And hopefully in a way which doesn't break older GCC versions (which simply including this flag by us will do).
Updated by Sven Eckelmann over 7 years ago
The upstream kernel fixes (hm, maybe we should call them workarounds) are:
- https://git.kernel.org/cgit/linux/kernel/git/mmarek/kbuild.git/commit/?id=8ae94224c9d72fc4d9aaac93b2d7833cf46d7141
- https://git.kernel.org/cgit/linux/kernel/git/mmarek/kbuild.git/commit/?id=82031ea29e454b574bc6f49a33683a693ca5d907
- https://git.kernel.org/cgit/linux/kernel/git/mmarek/kbuild.git/commit/?id=90944e40ba1838de4b2a9290cf273f9d76bd3bdd
I will have a lot of fun later when porting them to 3.2-4.9 for the build_test.git repository.