x86/compat: fix compilation errors with clang 6
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 24 Jan 2018 17:01:33 +0000 (18:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 24 Jan 2018 17:01:33 +0000 (18:01 +0100)
The following errors are generated when compiling Xen with clang 6:

In file included from x86_64/asm-offsets.c:9:
In file included from /root/src/xen/xen/include/xen/sched.h:8:
In file included from /root/src/xen/xen/include/xen/shared.h:6:
In file included from /root/src/xen/xen/include/compat/arch-x86/../xen.h:9:
/root/src/xen/xen/include/compat/arch-x86/xen.h:10:10: error: the current #pragma pack aligment
      value is modified in the included file [-Werror,-Wpragma-pack]
#include "xen-x86_32.h"
         ^
/root/src/xen/xen/include/compat/arch-x86/xen-x86_32.h:40:9: note: previous '#pragma pack'
      directive that modifies alignment is here
#pragma pack()
        ^
In file included from x86_64/asm-offsets.c:9:
In file included from /root/src/xen/xen/include/xen/sched.h:8:
In file included from /root/src/xen/xen/include/xen/shared.h:6:
/root/src/xen/xen/include/compat/arch-x86/../xen.h:9:10: error: the current #pragma pack aligment
      value is modified in the included file [-Werror,-Wpragma-pack]
#include "arch-x86/xen.h"
         ^
/root/src/xen/xen/include/compat/arch-x86/xen.h:71:9: note: previous '#pragma pack' directive that
      modifies alignment is here
#pragma pack()
        ^
2 errors generated.

Fix this by using pragma push/pop in order to store the current pragma
value in the compiler stack and later restoring it when using clang.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/include/Makefile

index 1299b1962f3bc312bcb530c4ed02af53d527e36d..19066a33a0879d7d54189abe573dee801e4ae92e 100644 (file)
@@ -35,8 +35,13 @@ cppflags-y                := -include public/xen-compat.h -DXEN_GENERATING_COMPA
 cppflags-$(CONFIG_X86)    += -m32
 
 # 8-byte types are 4-byte aligned on x86_32 ...
+ifeq ($(clang),y)
+prefix-$(CONFIG_X86)      := \#pragma pack(push, 4)
+suffix-$(CONFIG_X86)      := \#pragma pack(pop)
+else
 prefix-$(CONFIG_X86)      := \#pragma pack(4)
 suffix-$(CONFIG_X86)      := \#pragma pack()
+endif
 
 endif