Greater than linux 5.4-rc4 headers -- Unable to build simple kernel module

Bug #1849348 reported by Cheyenne Wills on 2019-10-22
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Undecided
Unassigned

Bug Description

Cannot build a kernel module, errors in Linux headers using the current RC4 (also tried RC3, and daily) mainline kernel packages from http://kernel.ubuntu.com/~kernel-ppa/mainline

Am able to build against a 5.4-rc4 kernel level directly from upstream kernel git repo (on a different platform).

To recreate error:

Install linux headers, etc from current 5.4 RC. (used 5.4.0-050400rc4 dated 10/20 for this test)

--[/tmp/builderr/Makefile]--

EXTRA_CFLAGS +=

obj-m += conftest.o

-- [EOF] --

--[/tmp/builderr/conftest.c]--

#include <linux/module.h>
void conftest(void)
{

}
MODULE_LICENSE("GPL-2");

-- [EOF] --

Command:

make -C /lib/modules/5.4.0-050400rc4-generic/build M=/tmp/builderr/ V=2 &> make_err.log

make.log is attached.

Expected output (using above Makefile and conftest.c, performed a build on a system with 4.15.0-66 linux packages installed):

-- [expected output] --

make -C /lib/modules/4.15.0-66-generic/build/ M=/tmp/builderr
make: Entering directory '/usr/src/linux-headers-4.15.0-66-generic'
  CC [M] /tmp/builderr/conftest.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC /tmp/builderr/conftest.mod.o
  LD [M] /tmp/builderr/conftest.ko
make: Leaving directory '/usr/src/linux-headers-4.15.0-66-generic'

----

=========
lsb_release -rd
Description: Ubuntu 18.04.3 LTS
Release: 18.04

uname -a
Linux ubuntu_base 5.4.0-050400rc4-generic #201910202130 SMP Sun Oct 20 21:32:54 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

dpkg -l | grep "linux\-[a-z]*\-"
ii linux-headers-5.4.0-050400rc4 5.4.0-050400rc4.201910202130 all Header files related to Linux kernel version 5.4.0
ii linux-headers-5.4.0-050400rc4-generic 5.4.0-050400rc4.201910202130 amd64 Linux kernel headers for version 5.4.0 on 64 bit x86 SMP
ii linux-image-unsigned-5.4.0-050400rc4-generic 5.4.0-050400rc4.201910202130 amd64 Linux kernel image for version 5.4.0 on 64 bit x86 SMP
ri linux-libc-dev:amd64 4.15.0-65.74 amd64 Linux Kernel Headers for development
ii linux-modules-5.4.0-050400rc4-generic 5.4.0-050400rc4.201910202130 amd64 Linux kernel extra modules for version 5.4.0 on 64 bit x86 SMP

Cheyenne Wills (ccwills) wrote :

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1849348

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
tags: added: bionic

Unable to run apport-collect command since this is being reported for a mainline kernel.

If this isn't the "correct" location to report this error, please let me know.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Cheyenne Wills (ccwills) wrote :

I think I might have found the
"source" of the problem.

https://github.com/torvalds/linux/commit/40576e5e63ea5eeab814de7af83ad09dd64134ee

Replacing the gcc-7 version with gcc-8 seems to "fix" the problem

root@ubuntu_base:~/builderr# uname -a
Linux ubuntu_base 5.4.0-050400rc5-generic #201910271430 SMP Sun Oct 27 18:33:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu_base:~/builderr# gcc --version
gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@ubuntu_base:~/builderr# make -C /lib/modules/5.4.0-050400rc5-generic/build/ M=$PWD
make: Entering directory '/usr/src/linux-headers-5.4.0-050400rc5-generic'
  AR /root/builderr/built-in.a
  CC [M] /root/builderr/conftest.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC [M] /root/builderr/conftest.mod.o
  LD [M] /root/builderr/conftest.ko
make: Leaving directory '/usr/src/linux-headers-5.4.0-050400rc5-generic'

Cheyenne Wills (ccwills) wrote :

I've determined what is going on.

The linux headers from http://kernel.ubuntu.com/~kernel-ppa/mainline are built with a gcc 9 version. This causes CONFIG_CC_HAS_ASM_INLINE to be set to true.

However the gcc level that is installed by default on ubuntu 18.04.3 is still gcc 7.4. This level doesn't meet the criteria for supporting CONFIG_CC_HAS_ASM_INLINE, so the building with the linux headers will fail.

I manually set the CONFIG_CC_HAS_ASM_INLINE statements false in the linux 5.4 headers (deleted the line in include/generated/autoconf.h and set CONFIG_CC_HAS_ASM_INLINE=n in include/config/auto.conf).

With the above set, I was able to build using a gcc 7.4 compiler.

So.. either the dependency for the headers needs to include a compatible compiler level, or the headers need to be built to disable those features that are supplied by compilers higher then gcc 7.4.

Myna Mefirst (myna6p) wrote :

Folks, Just as an update, this is affecting anyone that wants to use VirtualBox with kernel 5.4 and 5.5, when it is just downloaded from the kernel repository.

You can see more activity at https://forums.virtualbox.org/viewtopic.php?f=7&t=96297. Virtualbox maintainers have also confirmed the above and closed the bug as it is not something they control. See https://www.virtualbox.org/ticket/19244 for their response.

I am not sure if there is a different place to post this to get other visibility, as the header of this report mentions an RC build, but this is happening in any released 5.4 kernel, as well as 5.5.

Thanks.

Updated title to indicate that it's more then just the rc level of the kernel headers

summary: - linux 5.4-rc4 Unable to build simple kernel module
+ Greater than linux 5.4-rc4 Unable to build simple kernel module
summary: - Greater than linux 5.4-rc4 Unable to build simple kernel module
+ Greater than linux 5.4-rc4 headers -- Unable to build simple kernel
+ module
dacorsa (dacorsa) wrote :

@ Cheyenne Wills (ccwills)

Thanks i have switched to gcc8 and now works!

God bless you

:)

Myna Mefirst (myna6p) wrote :

Folks,
Thanks to @dacorsa and his post on the virtualbox forum, here is the "workaround" for the issue (this is to build the VirtualBox modules. different modules may be different)

1. Install gcc-8

sudo apt install gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8

if you now run

gcc --version

you will see that you have v8.

2. Next, issue the vboxconfig command:

sudo /sbin/vboxconfig

and voila. No need to recompile the kernel or anything. vbox started right after that. I am on kernel 5.5.0

Cristian Molina (megatux) wrote :

kernel 5.4, gcc 8.4 still same error

Cristian Molina (megatux) wrote :

AFAIK this is an issue with kernels 5.3

Cristian Molina (megatux) wrote :

sorry kernels 5.4 ... Launchpad does not allow to edit/delete posts? unbelievable

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.