kernel compile problem due to gcc bug
Koornstra, Reinoud
koornstra at hp.com
Fri Nov 4 22:37:12 UTC 2011
HI Everyone,
I have trouble compiling kernels myself using version 10.4 (LTS)
LD .tmp_vmlinux1
kernel/built-in.o(.text+0x2e9c): In function `get_update_sysctl_factor':
: undefined reference to `____ilog2_NaN'
Looking into it further, this happened to more people using the 4.4 gcc compiler.
My compiler version:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
It seems due to the Due to a bug in the handling of the __builtin_constant_p builtin in GCC 4.4 versions.
The function get_update_sysctl_factor is found in kernel/sched.c
static int get_update_sysctl_factor(void)
{
unsigned int cpus = min_t(int, num_online_cpus(), 8);
unsigned int factor;
switch (sysctl_sched_tunable_scaling) {
case SCHED_TUNABLESCALING_NONE:
factor = 1;
break;
case SCHED_TUNABLESCALING_LINEAR:
factor = cpus;
break;
case SCHED_TUNABLESCALING_LOG:
default:
factor = 1 + ilog2(cpus);
break;
}
Changing this to:
static int get_update_sysctl_factor(void)
{
unsigned int cpus = min_t(int, num_online_cpus(), 8);
unsigned int factor;
switch (sysctl_sched_tunable_scaling) {
case SCHED_TUNABLESCALING_NONE:
factor = 1;
break;
case SCHED_TUNABLESCALING_LINEAR:
factor = cpus;
break;
case SCHED_TUNABLESCALING_LOG:
default:
factor = __ilog2_u32(cpus) + 1;
break;
}
Works, but it's a workaround for the problem in gcc.
Did anybody encounter this as well in version 10.04?
Thanks,
Reinoud.
More information about the kernel-team
mailing list