[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH] libacpi: Fix cross building x86 on arm



When Xen is compiled for x86 on an arm machine, libacpi build is failing
due to a wrong include path:
- arch-x86/xen.h includes xen.h
- xen.h includes arch-arm.h (as __i386__ and __x86_64__ are not defined
but arm ones are).

To workaround this for now, enforce defining __x86_64__ in mk_dsdt.c
when compiled for x86 to follow the right include path.

Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
The x86 header is including ../xen.h before the ifndef/define so that it
gets included back by xen.h. This is wrongly making the assumption that
we are using an x86 compiler which is not the case when building the
tools for x86 on an arm host.
This patch is not a good solution but the headers are doing some weird
stuff which are going back to 2008 in the git history and the commit
message do not include any valid reason.
---
---
 tools/libacpi/mk_dsdt.c           | 10 ++++++++++
 xen/include/public/arch-x86/xen.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index c5ba4c0b2fd3..ba5468f43c13 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -18,6 +18,16 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #if defined(CONFIG_X86)
+/*
+ * When building on non x86 host, arch-x86/xen.h will include xen.h which will
+ * try to include the arch xen.h (for example if built on arm, x86/xen.h will
+ * include xen.h which will include arch-arm.h).
+ * To prevent this effect, define x86 to have the proper sub arch included when
+ * the compiler does not define it.
+ */
+#if !(defined(__i386__) || defined(__x86_64__))
+#define __x86_64__
+#endif
 #include <xen/arch-x86/xen.h>
 #include <xen/hvm/hvm_info_table.h>
 #elif defined(CONFIG_ARM_64)
diff --git a/xen/include/public/arch-x86/xen.h 
b/xen/include/public/arch-x86/xen.h
index 58a1e87ee971..ea33a56eb6a0 100644
--- a/xen/include/public/arch-x86/xen.h
+++ b/xen/include/public/arch-x86/xen.h
@@ -24,6 +24,7 @@
  * Copyright (c) 2004-2006, K A Fraser
  */
 
+/* TODO: when cross building, this will include the wrong arch header */
 #include "../xen.h"
 
 #ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.