x86/compat: fix compilation errors with clang 6
PATCH 1/1 x86/compat: fix compilation errors with clang 6
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.
---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
--- xen/include/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/Makefile +2 -2
@@ -35,8 +35,8 @@ cppflags-y := -include public/xen-compat.h -DXEN_GENERATING_COMPA cppflags-$(CONFIG_X86) += -m32 # 8-byte types are 4-byte aligned on x86_32 ... -prefix-$(CONFIG_X86) := \#pragma pack(4) -suffix-$(CONFIG_X86) := \#pragma pack() +prefix-$(CONFIG_X86) := \#pragma pack(push, 4) +suffix-$(CONFIG_X86) := \#pragma pack(pop) endif
Signature · 7 lines
2.15.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 13:38, <[email protected]> wrote:
Fix this by using pragma push/pop in order to store the current pragma value in the compiler stack and later restoring it.
For Linux this is fine all the way back to gcc 4.1 afaict, but what about other OSes using gcc? In 4.1, only config/linux.h and a few special config/i386/*.h define the necessary macro (HANDLE_PRAGMA_PACK_PUSH_POP).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 13:38, <[email protected]> wrote:
Fix this by using pragma push/pop in order to store the current pragma value in the compiler stack and later restoring it.
For Linux this is fine all the way back to gcc 4.1 afaict, but what about other OSes using gcc? In 4.1, only
config/linux.hand a few special config/i386/*.h define the necessary macro (HANDLE_PRAGMA_PACK_PUSH_POP).
OK, then I have the following version:
xen/include/Makefile +5 -0
@@ -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
Since ATM that's a clang only issue I guess we can leave it like that. I'm not aware of anyway to know whether the compiler supports pragma pack with psuh/pop.
Let me know if that's fine and I will send out a formal v2.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 14:54, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 13:38, <[email protected]> wrote:
Fix this by using pragma push/pop in order to store the current pragma value in the compiler stack and later restoring it.
For Linux this is fine all the way back to gcc 4.1 afaict, but what about other OSes using gcc? In 4.1, only
config/linux.hand a few special config/i386/*.h define the necessary macro (HANDLE_PRAGMA_PACK_PUSH_POP).OK, then I have the following version:
xen/include/Makefile +5
-1@@ -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
Quoted 5 lines
Since ATM that's a clang only issue I guess we can leave it like that. I'm not aware of anyway to know whether the compiler supports pragma pack with psuh/pop.
Let me know if that's fine and I will send out a formal v2.
Yes, that's fine indeed. Checking whether the construct is supported would involve a test compile, which I think we should bother doing only when we can't avoid this anymore.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel