Subject: 2.4.26 doesn't compile? ("error: `__cmpxchg' previously defined here")

Hi,

I'm trying to compile 2.4.26 kernel but I get the following error in "make
modules" part:

[...]
make[3]: Entering directory `/usr/src/linux-2.4.26/drivers/char/drm'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes
-Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer
-pipe -mpreferred-stack-boundary=2 -march=i386 -DMODULE -DMODVERSIONS
-include /usr/src/linux-2.4.26/include/linux/modversions.h -nostdinc
-iwithprefix include -DKBUILD_BASENAME=gamma_drv -c -o gamma_drv.o
gamma_drv.c
In file included from gamma_drv.c:34:
drmP.h:180: error: redefinition of `__cmpxchg'
/usr/src/linux-2.4.26/include/asm/system.h:245: error: `__cmpxchg'
previously defined here
make[3]: *** [gamma_drv.o] Error 1
make[3]: Leaving directory `/usr/src/linux-2.4.26/drivers/char/drm'
make[2]: *** [_modsubdir_drm] Error 2
make[2]: Leaving directory `/usr/src/linux-2.4.26/drivers/char'
make[1]: *** [_modsubdir_char] Error 2
make[1]: Leaving directory `/usr/src/linux-2.4.26/drivers'
make: *** [_mod_drivers] Error 2

My machine:

mta-mad:~# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 1
model name : Intel(R) Celeron(R) CPU 1.80GHz
stepping : 3
cpu MHz : 1817.948
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 3630.69

mta-mad:~# gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.3 (Debian 20040401)
mta-mad:~#

I've attached the .config file which I'm using. The system is Debian
Unstable. I've compiled (older) kernels without problems.

I also tried to compile it using gcc-2.95 obtaining the same (bad) results
(I changed Makefile and replaced "gcc" by "gcc-2.95", which is the 2.95
binary in my system).

Any ideas?

Best regards,
-Rom?n


Attachments:
config_2.4.26.bz2 (8.44 kB)

2004-04-19 17:32:53

by Randy.Dunlap

[permalink] [raw]
Subject: Re: 2.4.26 doesn't compile? ("error: `__cmpxchg' previously defined here")

On Mon, 19 Apr 2004 10:16:28 +0200 (CEST) Rom?n Medina wrote:

| Hi,
|
| I'm trying to compile 2.4.26 kernel but I get the following error in "make
| modules" part:
|
| [...]
| make[3]: Entering directory `/usr/src/linux-2.4.26/drivers/char/drm'
| gcc -D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes
| -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer
| -pipe -mpreferred-stack-boundary=2 -march=i386 -DMODULE -DMODVERSIONS
| -include /usr/src/linux-2.4.26/include/linux/modversions.h -nostdinc
| -iwithprefix include -DKBUILD_BASENAME=gamma_drv -c -o gamma_drv.o
| gamma_drv.c
| In file included from gamma_drv.c:34:
| drmP.h:180: error: redefinition of `__cmpxchg'
| /usr/src/linux-2.4.26/include/asm/system.h:245: error: `__cmpxchg'
| previously defined here
| make[3]: *** [gamma_drv.o] Error 1
| make[3]: Leaving directory `/usr/src/linux-2.4.26/drivers/char/drm'
| make[2]: *** [_modsubdir_drm] Error 2
| make[2]: Leaving directory `/usr/src/linux-2.4.26/drivers/char'
| make[1]: *** [_modsubdir_char] Error 2
| make[1]: Leaving directory `/usr/src/linux-2.4.26/drivers'
| make: *** [_mod_drivers] Error 2
|
| My machine:
|
| mta-mad:~# cat /proc/cpuinfo
| processor : 0
| vendor_id : GenuineIntel
| cpu family : 15
| model : 1
| model name : Intel(R) Celeron(R) CPU 1.80GHz
| stepping : 3
| cpu MHz : 1817.948
| cache size : 128 KB
| fdiv_bug : no
| hlt_bug : no
| f00f_bug : no
| coma_bug : no
| fpu : yes
| fpu_exception : yes
| cpuid level : 2
| wp : yes
| flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
| cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
| bogomips : 3630.69
|
| mta-mad:~# gcc -v
| Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
| Configured with: ../src/configure -v
| --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
| --mandir=/usr/share/man --infodir=/usr/share/info
| --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
| --with-system-zlib --enable-nls --without-included-gettext
| --enable-__cxa_atexit --enable-clocale=gnu --enable-debug
| --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
| Thread model: posix
| gcc version 3.3.3 (Debian 20040401)
| mta-mad:~#
|
| I've attached the .config file which I'm using. The system is Debian
| Unstable. I've compiled (older) kernels without problems.
|
| I also tried to compile it using gcc-2.95 obtaining the same (bad) results
| (I changed Makefile and replaced "gcc" by "gcc-2.95", which is the 2.95
| binary in my system).
|
| Any ideas?

Sure, build for more than CONFIG_M386=y.
I.e., build for a Pentium III etc. and it should work.

--
~Randy

Subject: Re: 2.4.26 doesn't compile? ("error: `__cmpxchg' previously defined here")

On Mon, 19 Apr 2004 10:27:10 -0700, you wrote:

>| make[3]: Entering directory `/usr/src/linux-2.4.26/drivers/char/drm'
>| gcc -D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes
>| -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer
>| -pipe -mpreferred-stack-boundary=2 -march=i386 -DMODULE -DMODVERSIONS
>| -include /usr/src/linux-2.4.26/include/linux/modversions.h -nostdinc
>| -iwithprefix include -DKBUILD_BASENAME=gamma_drv -c -o gamma_drv.o
>| gamma_drv.c
>| In file included from gamma_drv.c:34:
>| drmP.h:180: error: redefinition of `__cmpxchg'
>| /usr/src/linux-2.4.26/include/asm/system.h:245: error: `__cmpxchg'
>| previously defined here
>| make[3]: *** [gamma_drv.o] Error 1
>| make[3]: Leaving directory `/usr/src/linux-2.4.26/drivers/char/drm'
>| make[2]: *** [_modsubdir_drm] Error 2
>| make[2]: Leaving directory `/usr/src/linux-2.4.26/drivers/char'
>| make[1]: *** [_modsubdir_char] Error 2
>| make[1]: Leaving directory `/usr/src/linux-2.4.26/drivers'
>| make: *** [_mod_drivers] Error 2
>|
>| Any ideas?
>
>Sure, build for more than CONFIG_M386=y.
>I.e., build for a Pentium III etc. and it should work.

Thanks a lot, Randy. It worked :-) But I'm wondering why the same
config compiled perfectly on 2.4.25 and backwards. Which changes
affect this issue?

Saludos,
--Roman

--
PGP Fingerprint:
09BB EFCD 21ED 4E79 25FB 29E1 E47F 8A7D EAD5 6742
[Key ID: 0xEAD56742. Available at KeyServ]

2004-04-19 20:02:28

by Randy.Dunlap

[permalink] [raw]
Subject: Re: 2.4.26 doesn't compile? ("error: `__cmpxchg' previously defined here")

On Mon, 19 Apr 2004 21:09:19 +0200 Roman Medina wrote:

| On Mon, 19 Apr 2004 10:27:10 -0700, you wrote:
|
| >| make[3]: Entering directory `/usr/src/linux-2.4.26/drivers/char/drm'
| >| gcc -D__KERNEL__ -I/usr/src/linux-2.4.26/include -Wall -Wstrict-prototypes
| >| -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer
| >| -pipe -mpreferred-stack-boundary=2 -march=i386 -DMODULE -DMODVERSIONS
| >| -include /usr/src/linux-2.4.26/include/linux/modversions.h -nostdinc
| >| -iwithprefix include -DKBUILD_BASENAME=gamma_drv -c -o gamma_drv.o
| >| gamma_drv.c
| >| In file included from gamma_drv.c:34:
| >| drmP.h:180: error: redefinition of `__cmpxchg'
| >| /usr/src/linux-2.4.26/include/asm/system.h:245: error: `__cmpxchg'
| >| previously defined here
| >| make[3]: *** [gamma_drv.o] Error 1
| >| make[3]: Leaving directory `/usr/src/linux-2.4.26/drivers/char/drm'
| >| make[2]: *** [_modsubdir_drm] Error 2
| >| make[2]: Leaving directory `/usr/src/linux-2.4.26/drivers/char'
| >| make[1]: *** [_modsubdir_char] Error 2
| >| make[1]: Leaving directory `/usr/src/linux-2.4.26/drivers'
| >| make: *** [_mod_drivers] Error 2
| >|
| >| Any ideas?
| >
| >Sure, build for more than CONFIG_M386=y.
| >I.e., build for a Pentium III etc. and it should work.
|
| Thanks a lot, Randy. It worked :-) But I'm wondering why the same
| config compiled perfectly on 2.4.25 and backwards. Which changes
| affect this issue?

That would be this changeset:
http://linux.bkbits.net:8080/linux-2.4/diffs/include/asm-i386/[email protected]?nav=index.html|src/|src/include|src/include/asm-i386|hist/include/asm-i386/system.h


This patch (below) works for me with your original i386 .config file.

--
~Randy


// linux-2.4.26
// drmP.h doesn't need local cmpxchg() and __cmpxchg();


diffstat:=
drivers/char/drm/drmP.h | 34 ++--------------------------------
1 files changed, 2 insertions(+), 32 deletions(-)


diff -Naurp ./drivers/char/drm/drmP.h~cmpxchg_notlocal ./drivers/char/drm/drmP.h
--- ./drivers/char/drm/drmP.h~cmpxchg_notlocal 2004-04-19 11:07:10.000000000 -0700
+++ ./drivers/char/drm/drmP.h 2004-04-19 13:02:55.000000000 -0700
@@ -52,6 +52,7 @@
#include <linux/version.h>
#include <linux/sched.h>
#include <linux/smp_lock.h> /* For (un)lock_kernel */
+#include <linux/system.h> /* for cmpxchg() */
#include <linux/mm.h>
#include <linux/pagemap.h>
#if defined(__alpha__) || defined(__powerpc__)
@@ -174,38 +175,7 @@ __cmpxchg(volatile void *ptr, unsigned l
(unsigned long)_n_, sizeof(*(ptr))); \
})

-#elif __i386__
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
- unsigned long new, int size)
-{
- unsigned long prev;
- switch (size) {
- case 1:
- __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
- : "=a"(prev)
- : "q"(new), "m"(*__xg(ptr)), "0"(old)
- : "memory");
- return prev;
- case 2:
- __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
- : "=a"(prev)
- : "q"(new), "m"(*__xg(ptr)), "0"(old)
- : "memory");
- return prev;
- case 4:
- __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
- : "=a"(prev)
- : "q"(new), "m"(*__xg(ptr)), "0"(old)
- : "memory");
- return prev;
- }
- return old;
-}
-
-#define cmpxchg(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
- (unsigned long)(n),sizeof(*(ptr))))
-#endif /* i386 & alpha */
+#endif /* alpha */
#endif
#define __REALLY_HAVE_SG (__HAVE_SG)

2004-04-20 14:39:52

by Marcelo Tosatti

[permalink] [raw]
Subject: Re: 2.4.26 doesn't compile? ("error: `__cmpxchg' previously defined here")


Patch applied,

Thanks Randy!

On Mon, Apr 19, 2004 at 12:56:47PM -0700, Randy.Dunlap wrote:

> That would be this changeset:
> http://linux.bkbits.net:8080/linux-2.4/diffs/include/asm-i386/[email protected]?nav=index.html|src/|src/include|src/include/asm-i386|hist/include/asm-i386/system.h
>
>
> This patch (below) works for me with your original i386 .config file.