2008-12-02 21:52:30

by Jody McIntyre

[permalink] [raw]
Subject: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

1965aae3c98397aad957412413c07e97b1bd4e64 broke compilation on one of my
systems:

CC arch/x86/kernel/syscall_64.o
arch/x86/kernel/syscall_64.c:27: error: array index in initializer exceeds array bounds
arch/x86/kernel/syscall_64.c:27: error: (near initialization for ‘sys_call_table’)
arch/x86/kernel/syscall_64.c:27: warning: excess elements in array initializer
arch/x86/kernel/syscall_64.c:27: warning: (near initialization for ‘sys_call_table’)
make[1]: *** [arch/x86/kernel/syscall_64.o] Error 1
make: *** [arch/x86/kernel/syscall_64.o] Error 2

Reverting only the parts of the commit that change ASM_X86__UNISTD_64_H
to _ASM_X86_UNISTD_64_H fixes the problem. Patch below.

I have no idea what's going on here. Compiler bug?

root@vm1:~/linux-2.6# gcc --version
gcc (Ubuntu 4.3.2-1ubuntu11) 4.3.2

Signed-off-by: Jody McIntyre <[email protected]>
---
arch/um/sys-x86_64/syscall_table.c | 4 ++--
arch/x86/include/asm/unistd_64.h | 6 +++---
arch/x86/kernel/asm-offsets_64.c | 2 +-
arch/x86/kernel/syscall_64.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/um/sys-x86_64/syscall_table.c b/arch/um/sys-x86_64/syscall_table.c
index dd21d69..ef42ec0 100644
--- a/arch/um/sys-x86_64/syscall_table.c
+++ b/arch/um/sys-x86_64/syscall_table.c
@@ -41,12 +41,12 @@
#define stub_rt_sigreturn sys_rt_sigreturn

#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
-#undef _ASM_X86_UNISTD_64_H
+#undef ASM_X86__UNISTD_64_H
#include "../../x86/include/asm/unistd_64.h"

#undef __SYSCALL
#define __SYSCALL(nr, sym) [ nr ] = sym,
-#undef _ASM_X86_UNISTD_64_H
+#undef ASM_X86__UNISTD_64_H

typedef void (*sys_call_ptr_t)(void);

diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
index d2e415e..26a7432 100644
--- a/arch/x86/include/asm/unistd_64.h
+++ b/arch/x86/include/asm/unistd_64.h
@@ -1,5 +1,5 @@
-#ifndef _ASM_X86_UNISTD_64_H
-#define _ASM_X86_UNISTD_64_H
+#ifndef ASM_X86__UNISTD_64_H
+#define ASM_X86__UNISTD_64_H

#ifndef __SYSCALL
#define __SYSCALL(a, b)
@@ -690,4 +690,4 @@ __SYSCALL(__NR_inotify_init1, sys_inotify_init1)
#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
#endif /* __KERNEL__ */

-#endif /* _ASM_X86_UNISTD_64_H */
+#endif /* ASM_X86__UNISTD_64_H */
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index 7fcf63d..505543a 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -22,7 +22,7 @@

#define __NO_STUBS 1
#undef __SYSCALL
-#undef _ASM_X86_UNISTD_64_H
+#undef ASM_X86__UNISTD_64_H
#define __SYSCALL(nr, sym) [nr] = 1,
static char syscalls[] = {
#include <asm/unistd.h>
diff --git a/arch/x86/kernel/syscall_64.c b/arch/x86/kernel/syscall_64.c
index de87d60..3d1be4f 100644
--- a/arch/x86/kernel/syscall_64.c
+++ b/arch/x86/kernel/syscall_64.c
@@ -8,12 +8,12 @@
#define __NO_STUBS

#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
-#undef _ASM_X86_UNISTD_64_H
+#undef ASM_X86__UNISTD_64_H
#include <asm/unistd_64.h>

#undef __SYSCALL
#define __SYSCALL(nr, sym) [nr] = sym,
-#undef _ASM_X86_UNISTD_64_H
+#undef ASM_X86__UNISTD_64_H

typedef void (*sys_call_ptr_t)(void);


2008-12-03 18:00:46

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

Jody McIntyre wrote:
> 1965aae3c98397aad957412413c07e97b1bd4e64 broke compilation on one of my
> systems:
>
> CC arch/x86/kernel/syscall_64.o
> arch/x86/kernel/syscall_64.c:27: error: array index in initializer exceeds array bounds
> arch/x86/kernel/syscall_64.c:27: error: (near initialization for ‘sys_call_table’)
> arch/x86/kernel/syscall_64.c:27: warning: excess elements in array initializer
> arch/x86/kernel/syscall_64.c:27: warning: (near initialization for ‘sys_call_table’)
> make[1]: *** [arch/x86/kernel/syscall_64.o] Error 1
> make: *** [arch/x86/kernel/syscall_64.o] Error 2
>
> Reverting only the parts of the commit that change ASM_X86__UNISTD_64_H
> to _ASM_X86_UNISTD_64_H fixes the problem. Patch below.
>
> I have no idea what's going on here. Compiler bug?
>

Okay, this makes no sense whatsoever. Could you send me the following:

a. the .config you're using;
b. what kernel headers do you have in /usr/include
(if you installed the old ones with the broken header guards
with "make headers_install", then your development environment
is broken);
c. "make arch/x86/kernel/syscall_64.i".

-hpa

2008-12-03 19:53:29

by Jody McIntyre

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

On Wed, Dec 03, 2008 at 10:00:07AM -0800, H. Peter Anvin wrote:

> Okay, this makes no sense whatsoever.

Glad you agree :)

> Could you send me the following:
>
> a. the .config you're using;

http://downloads.lustre.org/people/scjody/lkml/config_2008-12-03

> b. what kernel headers do you have in /usr/include
> (if you installed the old ones with the broken header guards
> with "make headers_install", then your development environment
> is broken);

I have never installed headers via "make headers_install". Anything
under /usr/include comes from my distribution (Ubuntu), and neither
header guard is found anywhere:

root@vm1:~/linux-2.6# grep -r ASM_X86__UNISTD_64_H /usr/include
root@vm1:~/linux-2.6# grep -r _ASM_X86_UNISTD_64_H /usr/include
root@vm1:~/linux-2.6#

/usr/include/linux/* and /usr/include/asm/* come from the linux-libc-dev
(2.6.27-9.19) package:

Package: linux-libc-dev
Priority: optional
Section: devel
Installed-Size: 3684
Maintainer: Ubuntu Kernel Team <[email protected]>
Architecture: amd64
Source: linux
Version: 2.6.27-9.19
Replaces: dvb-dev (<< 1.0.1-6), libc6-dev (<< 2.3.2.ds1-6), libc6.1-dev (<< 2.3.2.ds1-6), linux-kernel-headers
Provides: linux-kernel-headers
Conflicts: amd64-libs-dev (<= 1.1), dvb-dev (<< 1.0.1-6), libc6-dev (<< 2.3.2.ds1-6), libc6.1-dev (<< 2.3.2.ds1-6), linux-kernel-headers
Filename: pool/main/l/linux/linux-libc-dev_2.6.27-9.19_amd64.deb
Size: 653400
MD5sum: f2c4482176fe9e5219f7b18a258cbf86
SHA1: 1e6d329b13612438673a905152410cde8d0a7a53
SHA256: a294cb5f320c626a48f917a23b73a04e7d763ac3c2863ad16432dcd46cc0675c
Description: Linux Kernel Headers for development
This package provides headers from the Linux kernel. These headers
are used by the installed headers for GNU glibc and other system
libraries. They are NOT meant to be used to build third-party modules for
your kernel. Use linux-headers-* packages for that.
Bugs: mailto:[email protected]
Build-Essential: yes
Origin: Ubuntu
Task: ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, xubuntu-desktop, mobile-mobile

I'm confused as to why this matters - I didn't think the kernel build
used any external includes (except for helper utilities like "conf".)

> c. "make arch/x86/kernel/syscall_64.i".

http://downloads.lustre.org/people/scjody/lkml/syscall_64.i

Cheers,
Jody

>
> -hpa

2008-12-03 20:36:41

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

Jody McIntyre wrote:
>
> I'm confused as to why this matters - I didn't think the kernel build
> used any external includes (except for helper utilities like "conf".)
>

It *shouldn't* (except for UML), but it has been known to happen by
accident.

I was particularly suspicious because you said "one of my systems",
which implies other systems don't behave that way...

Now, the syscall_64.i you sent me is the working version, right? Could
you send me the non-working version, too?

-hpa

2008-12-03 21:23:37

by Jody McIntyre

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

On Wed, Dec 03, 2008 at 12:17:47PM -0800, H. Peter Anvin wrote:

> I was particularly suspicious because you said "one of my systems",
> which implies other systems don't behave that way...

I have one other system that can build this kernel, and one that gets
further. The differences are gcc version (all distro-supplied),
.config, and in one case X86_32 vs. X86_64.

> Now, the syscall_64.i you sent me is the working version, right? Could
> you send me the non-working version, too?

That's the non-working version. I just verified:

root@vm1:~/linux-2.6# make clean && make arch/x86/kernel/syscall_64.o
[...]
CC arch/x86/kernel/syscall_64.o
arch/x86/kernel/syscall_64.c:27: error: array index in initializer exceeds array bounds
arch/x86/kernel/syscall_64.c:27: error: (near initialization for ‘sys_call_table’)
arch/x86/kernel/syscall_64.c:27: warning: excess elements in array initializer
arch/x86/kernel/syscall_64.c:27: warning: (near initialization for ‘sys_call_table’)
make[1]: *** [arch/x86/kernel/syscall_64.o] Error 1
make: *** [arch/x86/kernel/syscall_64.o] Error 2
root@vm1:~/linux-2.6# make arch/x86/kernel/syscall_64.i
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CALL scripts/checksyscalls.sh
CPP arch/x86/kernel/syscall_64.i

The resulting .i file is identical (checked md5sum) to the one on the
http site: http://downloads.lustre.org/people/scjody/lkml/syscall_64.i

Cheers,
Jody

2008-12-04 14:34:19

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

On Tuesday 02 December 2008, Jody McIntyre wrote:
> 1965aae3c98397aad957412413c07e97b1bd4e64 broke compilation on one of my
> systems:
>
>   CC      arch/x86/kernel/syscall_64.o
> arch/x86/kernel/syscall_64.c:27: error: array index in initializer exceeds array bounds
> arch/x86/kernel/syscall_64.c:27: error: (near initialization for ‘sys_call_table’)
> arch/x86/kernel/syscall_64.c:27: warning: excess elements in array initializer
> arch/x86/kernel/syscall_64.c:27: warning: (near initialization for ‘sys_call_table’)
> make[1]: *** [arch/x86/kernel/syscall_64.o] Error 1
> make: *** [arch/x86/kernel/syscall_64.o] Error 2
>
> Reverting only the parts of the commit that change ASM_X86__UNISTD_64_H
> to _ASM_X86_UNISTD_64_H fixes the problem.  Patch below.
>
> I have no idea what's going on here.  Compiler bug?

Maybe you have stale header files in include/asm-x86/? That sometimes
happens if you git-checkout -f or git-reset --hard.

Arnd <><

2008-12-04 19:07:56

by Jody McIntyre

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

Hi Arnd,

On Thu, Dec 04, 2008 at 03:32:59PM +0100, Arnd Bergmann wrote:

> Maybe you have stale header files in include/asm-x86/? That sometimes
> happens if you git-checkout -f or git-reset --hard.

Your suggestion led me to the actual problem: the rsync command I was
running to get files to my build machine was missing --delete, which
meant the build machine's tree had all sorts of cruft.

With that change, I can successfully build the latest Linus kernel
without any patches. Sorry to have wasted everyone's time.

Jody (crawls back under rock)

> Arnd <><

2008-12-04 19:12:57

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH] Fix compile error in arch/x86/kernel/syscall_64.c

Arnd Bergmann wrote:
> On Tuesday 02 December 2008, Jody McIntyre wrote:
>> 1965aae3c98397aad957412413c07e97b1bd4e64 broke compilation on one of my
>> systems:
>>
>> CC arch/x86/kernel/syscall_64.o
>> arch/x86/kernel/syscall_64.c:27: error: array index in initializer exceeds array bounds
>> arch/x86/kernel/syscall_64.c:27: error: (near initialization for ‘sys_call_table’)
>> arch/x86/kernel/syscall_64.c:27: warning: excess elements in array initializer
>> arch/x86/kernel/syscall_64.c:27: warning: (near initialization for ‘sys_call_table’)
>> make[1]: *** [arch/x86/kernel/syscall_64.o] Error 1
>> make: *** [arch/x86/kernel/syscall_64.o] Error 2
>>
>> Reverting only the parts of the commit that change ASM_X86__UNISTD_64_H
>> to _ASM_X86_UNISTD_64_H fixes the problem. Patch below.
>>
>> I have no idea what's going on here. Compiler bug?
>
> Maybe you have stale header files in include/asm-x86/? That sometimes
> happens if you git-checkout -f or git-reset --hard.
>

"git cleanup" should be used to catch that classes of problems. I did
notice that the include file trace used include/asm not
arch/x86/include/asm, which to me implies something like this.

I just tried, and when I make a .i file on a clean tree I get:

# 10 "<full path>/arch/x86/include/asm/posix_types_64.h"

not

# 10 "include/asm/posix_types_64.h"

as the posted .i file has.

-hpa