kernel compile problem due to gcc bug

Koornstra, Reinoud koornstra at hp.com
Wed Nov 9 01:12:34 UTC 2011


> -----Original Message-----
> From: Andy Whitcroft [mailto:apw at canonical.com]
> Sent: Tuesday, November 08, 2011 2:00 AM
> To: Koornstra, Reinoud
> Cc: kernel-team at lists.ubuntu.com
> Subject: Re: kernel compile problem due to gcc bug
> 
> On Fri, Nov 04, 2011 at 10:37:12PM +0000, Koornstra, Reinoud wrote:
> > 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,
> 
> This code appears as above in the natty code base at least, and I don't recall
> us hitting the bug you encountered with the lts-backport of the
> natty kernel into lucid.   The compiler in my lucid chroots matches
> yours so I am confused why you are hitting it.  Which kernel source are you
> compiling here.

I was compiling linux 2.6.34.1
I noticed that I had CONFIG_RELOCATE enabled.
Deactivating that option made the problem go away ....
Hence, this option should be used with care.
Any ideas why this happens with this option enabled?
Thanks,

Reinoud.

> 
> -apw




More information about the kernel-team mailing list