[PATCH] Fix compilation of the stable kernel for gcc-4.3.1

Sven Rebhan odinshorse at googlemail.com
Thu Oct 9 21:34:50 CEST 2008


Hello,

I tried to compile the current stable kernel
(a2ef813d2f439a3e9f377d33a2e5baad098afb7e)
and get the following errors:

kernel/built-in.o: In function `timespec_add_ns':
/mnt/data/Freerunner/Gentoo/rootinstall/usr/src/linux/include/linux/time.h:174:
undefined reference to `__aeabi_uldivmod'
/mnt/data/Freerunner/Gentoo/rootinstall/usr/src/linux/include/linux/time.h:179:
undefined reference to `__aeabi_uldivmod'
/mnt/data/Freerunner/Gentoo/rootinstall/usr/src/linux/include/linux/time.h:174:
undefined reference to `__aeabi_uldivmod'
/mnt/data/Freerunner/Gentoo/rootinstall/usr/src/linux/include/linux/time.h:179:
undefined reference to `__aeabi_uldivmod'

applying the following patch solved the problem:
--------
Prevent gcc-4.3 form "optimizing" the while loop into a costly modulo operation.
Patch found at http://lkml.org/lkml/2008/2/22/464.

--- include/linux/time.h        2008-10-09 19:47:23.000000000 +0200
+++ include/linux/time.h.new    2008-10-09 19:47:54.000000000 +0200
@@ -173,6 +173,10 @@
 {
        ns += a->tv_nsec;
        while(unlikely(ns >= NSEC_PER_SEC)) {
+               /* The following asm() prevents the compiler from
+               * optimising this loop into a modulo operation.  */
+               asm("" : "+r"(ns));
+
                ns -= NSEC_PER_SEC;
                a->tv_sec++;
        }
--------

The problem was dicussed at
http://www.spinics.net/lists/arm-kernel/msg48776.html earlier.

Best regards,

    Sven



More information about the openmoko-kernel mailing list