All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/compat: fix compilation errors with clang 6
@ 2018-01-23 12:38 Roger Pau Monne
  2018-01-23 13:34 ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monne @ 2018-01-23 12:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, Roger Pau Monne

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.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/include/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/include/Makefile b/xen/include/Makefile
index 1299b1962f..bdf8dd4372 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -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
 
-- 
2.15.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/compat: fix compilation errors with clang 6
  2018-01-23 12:38 [PATCH] x86/compat: fix compilation errors with clang 6 Roger Pau Monne
@ 2018-01-23 13:34 ` Jan Beulich
  2018-01-23 13:54   ` Roger Pau Monné
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2018-01-23 13:34 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	IanJackson, Tim Deegan, xen-devel

>>> On 23.01.18 at 13:38, <roger.pau@citrix.com> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/compat: fix compilation errors with clang 6
  2018-01-23 13:34 ` Jan Beulich
@ 2018-01-23 13:54   ` Roger Pau Monné
  2018-01-23 14:04     ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monné @ 2018-01-23 13:54 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	IanJackson, Tim Deegan, xen-devel

On Tue, Jan 23, 2018 at 06:34:44AM -0700, Jan Beulich wrote:
> >>> On 23.01.18 at 13:38, <roger.pau@citrix.com> 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).

OK, then I have the following version:

diff --git a/xen/include/Makefile b/xen/include/Makefile
index 1299b1962f..19066a33a0 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/compat: fix compilation errors with clang 6
  2018-01-23 13:54   ` Roger Pau Monné
@ 2018-01-23 14:04     ` Jan Beulich
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2018-01-23 14:04 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	IanJackson, Tim Deegan, xen-devel

>>> On 23.01.18 at 14:54, <roger.pau@citrix.com> wrote:
> On Tue, Jan 23, 2018 at 06:34:44AM -0700, Jan Beulich wrote:
>> >>> On 23.01.18 at 13:38, <roger.pau@citrix.com> 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).
> 
> OK, then I have the following version:
> 
> diff --git a/xen/include/Makefile b/xen/include/Makefile
> index 1299b1962f..19066a33a0 100644
> --- a/xen/include/Makefile
> +++ b/xen/include/Makefile
> @@ -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.

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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-23 14:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23 12:38 [PATCH] x86/compat: fix compilation errors with clang 6 Roger Pau Monne
2018-01-23 13:34 ` Jan Beulich
2018-01-23 13:54   ` Roger Pau Monné
2018-01-23 14:04     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.