xen: Deal with stdarg.h and -nostdinc
Quoted 7 lines · Keir Fraser
Quoted 4 lines · Christoph Egger
Quoted 2 lines
This stuff can be moderately fragile, and we've now had no actual bug reports about it in a long while.
Here is a full error message:
Quoted 8 lines
Ah, okay, actually I see our stdarg support is a bit inconsistent already. How about the attached alternative fix? A few notes about it:
Firstly, in
xen/stdarg.hI handle NetBSD the same as OpenBSD -- I go and grab/usr/include/stdarg.hdirectly. I don't know if that is really better than including the compiler intrinsics directly as you did. If you prefer we could do that instead, but whichever I think it makes sense to do the same for both BSD variants.
No, the assumption what works for one BSD works for all BSDs is wrong.
In the NetBSD case I get the error
that <machine/ansi.h> and <sys/featuretest.h> are not found. That way <stdarg.h> pulls in machine specific definitions on NetBSD.
Quoted 4 lines
Secondly, I wonder whether *BSD would be happier if we did not include -nostdinc on the command line? See
arch/x86/Rules.mkwhere SunOS is already special cased. I don't know whether that would work for BSD too.
It works for NetBSD at least.
Quoted 4 lines
Finally, rather than referencing a hardcoded
/usr/includepath or including gcc intrinsics inxen/stdarg.h, would *BSD prefer a -isystem command-line option to include the gcc headers in the search path? Then we could perhaps even get rid ofxen/stdarg.hcompletely.
NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Christoph
Quoted 115 lines
-- Keir
Quoted 113 lines
gcc -O2 -I/usr/include -I/usr/pkg/include -O2 -fomit-frame-pointer -m64
(quoted diff) +0
-10-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -DNDEBUG -nostdinc -fno-builtin -fno-common -Wredundant-decls -iwithprefix include -Werror -Wno-pointer-arith -pipe -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm-x86/mach-generic -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm-x86/ mach-default
(quoted diff) +0
-8-msoft-float -fno-stack-protector -fno-exceptions -mno-red-zone -fpic -fno-asynchronous-unwind-tables -DGCC_HAS_VISIBILITY_ATTRIBUTE -g -D__XEN__ -MMD -MF .xen.d -O2 -fomit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement -DNDEBUG -nostdinc -fno-builtin -fno-common -Wredundant-decls -iwithprefix include -Werror -Wno-pointer-arith -pipe -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm-x86/mach-generic -I/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm-x86/ mach-default
(quoted diff) +0
-3-msoft-float -fno-stack-protector -fno-exceptions -mno-red-zone -fpic -fno-asynchronous-unwind-tables -DGCC_HAS_VISIBILITY_ATTRIBUTE -g -D__XEN__ -MMD -MF .asm-offsets.s.d -S -o asm-offsets.s x86_64/asm-offsets.cIn file included from
/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/lib.h:
5,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm/system.h:4,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/spinlock.h:5,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/sched. h:7,from x86_64/asm-offsets.c:10:
/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/stdarg.h:4:22:
error:stdarg.h: No such file or directory
In file included from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm/system.h:4,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/spinlock.h:5,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/sched. h:7,from x86_64/asm-offsets.c:10:
/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/lib.h:
86:
error: expected declaration specifiers or '...' before 'va_list'/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/lib.h:
90:
error: expected declaration specifiers or '...' before 'va_list'/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/lib.h:
94:
error: expected declaration specifiers or '...' before 'va_list' In file included from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/acpi/acpi. h:61,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/xen/acpi.h:34,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/acpi/apei. h:8,
from/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/asm/fixmap.h:23,from x86_64/asm-offsets.c:12:
/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/include/acpi/acpiosxf.h:257:
error: expected declaration specifiers or '...' before 'va_list' gmake[3]: *** [asm-offsets.s] Error 1
gmake[3]: Leaving directory/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/arch/x86' gmake[2]: *** [/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen/xen] Error 2 gmake[2]: Leaving directory/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen' gmake[1]: *** [install] Error 2
gmake[1]: Leaving directory `/tmp/pkgsrc-obj/sysutils/xenkernel41/work.ixp/xen-4.1.0/xen'Quoted 21 lines
-- KeirQuoted 18 lines
Quoted 3 lines
Use the external header when we compile the tools. Adapt
libelf-loader.cwhich is compiled in the kernel and with the tools.(quoted diff) +1
-1-#include<stdarg.h> +#include "../../include/xen/stdarg.h"Firstly, is this correct for all uses of libelf-loader ? This file is compiled both for use inside Xen and for use on the host. In the latter case it /should/ use the system's
stdarg.h.Also, this kind of relative path should not be necessary. The relevant files should be on the include path.
So I think this should be fixed by arranging that your new
stdarg.his on the relevant include path, not by changing the .c file.Ian.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Quoted 7 lines · Christoph Egger
Quoted 4 lines
Finally, rather than referencing a hardcoded
/usr/includepath or including gcc intrinsics inxen/stdarg.h, would *BSD prefer a -isystem command-line option to include the gcc headers in the search path? Then we could perhaps even get rid ofxen/stdarg.hcompletely.NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Something like the attached patch? I don't know whether this would work for clang too -- cc'ing Tim who will know or can try it out.
I wouldn't backport this one to 4.1, but my first patch was a cleanup plus BSD-specific changes, so a variant on that would be suitable for 4.0/4.1, with (if it works) this new one in unstable.
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Christoph Egger
Quoted 3 lines · Keir Fraser
Secondly, I wonder whether *BSD would be happier if we did not include -nostdinc on the command line? See
arch/x86/Rules.mkwhere SunOS is already special cased. I don't know whether that would work for BSD too.It works for NetBSD at least.
Quoted 7 lines
Quoted 4 lines
Finally, rather than referencing a hardcoded
/usr/includepath or including gcc intrinsics inxen/stdarg.h, would *BSD prefer a -isystem command-line option to include the gcc headers in the search path? Then we could perhaps even get rid ofxen/stdarg.hcompletely.NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Building Xen with clang I had to remove the -nostdinc because I couldn't find a sensible way of automatically finding the clang include paths. It may be that I just wasn't looking in the right place.
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
Quoted 6 lines · Tim Deegan
Quoted 2 lines
NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Building Xen with clang I had to remove the -nostdinc because I couldn't find a sensible way of automatically finding the clang include paths. It may be that I just wasn't looking in the right place.
Well, keeping the -nostdinc -isystem line as CFLAGS-$(gcc) wouldn't be so bad really. I wasn't sure whether clang would have support for these gcc command line options for dumping spec.
-- Keir
Quoted 5 lines · Keir Fraser
Quoted 3 lines · Tim Deegan
Quoted 2 lines
NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Quoted 7 lines
Quoted 3 lines
Building Xen with clang I had to remove the -nostdinc because I couldn't find a sensible way of automatically finding the clang include paths. It may be that I just wasn't looking in the right place.
Well, keeping the -nostdinc -isystem line as CFLAGS-$(gcc) wouldn't be so bad really. I wasn't sure whether clang would have support for these gcc command line options for dumping spec.
My current clang seems happy enough with this, actually, though wierdly it reports /usr/lib/gcc/x86_64-linux-gnu/4.5.2/include, so lord knows what would happen on a machine with clang but not gcc installed.
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Xen Platform Team Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
Quoted 5 lines · Keir Fraser
Quoted 3 lines · Tim Deegan
Quoted 2 lines
NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Quoted 7 lines
Quoted 3 lines
Building Xen with clang I had to remove the -nostdinc because I couldn't find a sensible way of automatically finding the clang include paths. It may be that I just wasn't looking in the right place.
Well, keeping the -nostdinc -isystem line as CFLAGS-$(gcc) wouldn't be so bad really. I wasn't sure whether clang would have support for these gcc command line options for dumping spec.
$ clang -print-file-name=include /usr/bin/../lib/clang/2.8/include $ ls /usr/bin/../lib/clang/2.8/include/stdarg.h /usr/bin/../lib/clang/2.8/include/stdarg.h
... on recentish Debian at least.
Ian.
Quoted 10 lines · Keir Fraser
Quoted 7 lines · Christoph Egger
Quoted 4 lines
Finally, rather than referencing a hardcoded
/usr/includepath or including gcc intrinsics inxen/stdarg.h, would *BSD prefer a -isystem command-line option to include the gcc headers in the search path? Then we could perhaps even get rid ofxen/stdarg.hcompletely.NetBSD is about to add clang/llvm support. If -isystem works for both gcc and clang then this should be fine.
Quoted 6 lines
Something like the attached patch? I don't know whether this would work for clang too -- cc'ing Tim who will know or can try it out.
I wouldn't backport this one to 4.1, but my first patch was a cleanup plus BSD-specific changes, so a variant on that would be suitable for 4.0/4.1, with (if it works) this new one in unstable.
$ clang -print-file-name=include include $ gcc -print-file-name=include include $ gcc -print-file-name=a a $
I got two variants working:
a) use -nostdinc and map the stdarg usage to the gcc builtins
b) do not use -nostdinc on NetBSD
Both 0?-stdarg-fixes work with a minor
modification to match case a) or case b).
Christoph
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Quoted 7 lines · Christoph Egger
Quoted 6 lines
Something like the attached patch? I don't know whether this would work for clang too -- cc'ing Tim who will know or can try it out.
I wouldn't backport this one to 4.1, but my first patch was a cleanup plus BSD-specific changes, so a variant on that would be suitable for 4.0/4.1, with (if it works) this new one in unstable.
Quoted 6 lines
$ clang -print-file-name=include include $ gcc -print-file-name=include include $ gcc -print-file-name=a a
Well that's quite broken...
-- Keir
Quoted 11 lines · Christoph Egger
Quoted 6 lines
Something like the attached patch? I don't know whether this would work for clang too -- cc'ing Tim who will know or can try it out.
I wouldn't backport this one to 4.1, but my first patch was a cleanup plus BSD-specific changes, so a variant on that would be suitable for 4.0/4.1, with (if it works) this new one in unstable.
$ clang -print-file-name=include include $ gcc -print-file-name=include include
Hm, well, I don't care that much about this, my first patch was good enough. I've checked in a variant of it as c/s 23432. Please check it works okay for you. It's simple enough to be a candidate for 4.1.1 also.
-- Keir
Quoted 2 lines
$ gcc -print-file-name=a a
Quoted 9 lines · Keir Fraser
Quoted 7 lines · Christoph Egger
Quoted 6 lines
Something like the attached patch? I don't know whether this would work for clang too -- cc'ing Tim who will know or can try it out.
I wouldn't backport this one to 4.1, but my first patch was a cleanup plus BSD-specific changes, so a variant on that would be suitable for 4.0/4.1, with (if it works) this new one in unstable.
Quoted 8 lines
Quoted 4 lines
$ clang -print-file-name=include include $ gcc -print-file-name=include includeHm, well, I don't care that much about this, my first patch was good enough. I've checked in a variant of it as c/s 23432. Please check it works okay for you. It's simple enough to be a candidate for 4.1.1 also.
Yes, it works. Please apply for Xen 4.1.1, too.
Christoph
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632