Re: Linux 2.4.3-ac12

junio
2001-04-22T06:08:25Z

>>>>> "MM" == Manuel McLure <manuel@mclure.org> writes:

MM> Something's wrong with this - it won't build with RH 7.1 kgcc
MM> (egcs-2.91.66):
...
MM> rwsem.o(.text+0x2ed): undefined reference to `__builtin_expect'
MM> /usr/src/linux-2.4.3-ac12/lib/lib.a(rwsem.o): In function
MM> `rwsem_up_write_wake':rwsem.o(.text+0x3c6): undefined reference to
MM> `__builtin_expect'
MM> make: *** [vmlinux] Error 1
MM> Sat Apr 21 20:35:37 PDT 2001

MM> ac12 builds OK with the standard RH 7.1 gcc (2.96), ac11 built fine with
MM> both the standard gcc and kgcc.

You need the following patch on i386. I am not attaching any
diff for other architectures , since I do not know which version
of gcc on other architectures started implementing this feature.

If gcc 2.96 uniformly implements it, I'd rather move this
backward compatibility definition of __builtin_expect from
include/asm-$(arch)/compiler.h to include/asm-generic/
somewhere.

--- 2.4.3-ac12/include/asm-i386/compiler.h Sat Apr 21 22:56:03 2001
+++ 2.4.3-ac12/include/asm-i386/compiler.h Sat Apr 21 22:56:43 2001
@@ -0,0 +1,13 @@
+#ifndef __I386_COMPILER_H
+#define __I386_COMPILER_H 1
+
+/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
+ a mechanism by which the user can annotate likely branch directions and
+ expect the blocks to be reordered appropriately. Define __builtin_expect
+ to nothing for earlier compilers. */
+
+#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
+#define __builtin_expect(x, expected_value) (x)
+#endif
+
+#endif /* __I386_COMPILER_H */

--- 2.4.3-ac12/include/asm-i386/semaphore.h Sat Apr 21 22:55:38 2001
+++ 2.4.3-ac12/include/asm-i386/semaphore.h Sat Apr 21 22:55:57 2001
@@ -38,6 +38,7 @@

#include <asm/system.h>
#include <asm/atomic.h>
+#include <asm/compiler.h>
#include <linux/wait.h>
#include <linux/rwsem.h>