diff mbox series

x86emul: Fix blowfish build in 64bit-clean environments

Message ID 20250328173637.892960-1-andrew.cooper3@citrix.com (mailing list archive)
State New
Headers show
Series x86emul: Fix blowfish build in 64bit-clean environments | expand

Commit Message

Andrew Cooper March 28, 2025, 5:36 p.m. UTC
In a 64bit-clean environment, blowfish fails:

  make[6]: Leaving directory
  '/builddir/build/BUILD/xen-4.19.1/tools/tests/x86_emulator'
  In file included from /usr/include/features.h:535,
                   from /usr/include/bits/libc-header-start.h:33,
                   from /usr/include/stdint.h:26,
                   from
  /usr/lib/gcc/x86_64-xenserver-linux/12/include/stdint.h:9,
                   from blowfish.c:18:
  /usr/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such
  file or directory
      7 | # include <gnu/stubs-32.h>
        |           ^~~~~~~~~~~~~~~~
  compilation terminated.
  make[6]: *** [testcase.mk:15: blowfish.bin] Error 1

because of lack of glibc-i386-devel or equivelent.  It's non-fatal, but
reduces the content in test_x86_emulator, which we do care about running.

Instead, convert all emulator testcases to being freestanding builds, resuing
the tools/firmware/include/ headers.

This in turn requires making firmware's stdint.h compatible with 64bit builds.
We now have compiler types for every standard type we use.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/firmware/include/stdint.h      | 27 ++++++++++-----------------
 tools/tests/x86_emulator/testcase.mk |  3 ++-
 2 files changed, 12 insertions(+), 18 deletions(-)

Comments

Jan Beulich March 31, 2025, 6:46 a.m. UTC | #1
On 28.03.2025 18:36, Andrew Cooper wrote:
> In a 64bit-clean environment, blowfish fails:
> 
>   make[6]: Leaving directory
>   '/builddir/build/BUILD/xen-4.19.1/tools/tests/x86_emulator'
>   In file included from /usr/include/features.h:535,
>                    from /usr/include/bits/libc-header-start.h:33,
>                    from /usr/include/stdint.h:26,
>                    from
>   /usr/lib/gcc/x86_64-xenserver-linux/12/include/stdint.h:9,
>                    from blowfish.c:18:
>   /usr/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such
>   file or directory
>       7 | # include <gnu/stubs-32.h>
>         |           ^~~~~~~~~~~~~~~~
>   compilation terminated.
>   make[6]: *** [testcase.mk:15: blowfish.bin] Error 1
> 
> because of lack of glibc-i386-devel or equivelent.  It's non-fatal, but
> reduces the content in test_x86_emulator, which we do care about running.
> 
> Instead, convert all emulator testcases to being freestanding builds, resuing
> the tools/firmware/include/ headers.
> 
> This in turn requires making firmware's stdint.h compatible with 64bit builds.
> We now have compiler types for every standard type we use.
> 
> Suggested-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/tools/firmware/include/stdint.h b/tools/firmware/include/stdint.h
index 16a0b6de19c2..5c41cb8bdafc 100644
--- a/tools/firmware/include/stdint.h
+++ b/tools/firmware/include/stdint.h
@@ -1,21 +1,14 @@ 
 #ifndef _STDINT_H_
 #define _STDINT_H_
 
-#if defined(__LP64__) || defined(__P64__)
-#error "32bit only header"
-#endif
-
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-
-typedef unsigned short uint16_t;
-typedef signed short int16_t;
-
-typedef unsigned int uint32_t;
-typedef signed int int32_t;
-
-typedef unsigned long long uint64_t;
-typedef signed long long int64_t;
+typedef __INT8_TYPE__        int8_t;
+typedef __UINT8_TYPE__      uint8_t;
+typedef __INT16_TYPE__      int16_t;
+typedef __UINT16_TYPE__    uint16_t;
+typedef __INT32_TYPE__      int32_t;
+typedef __UINT32_TYPE__    uint32_t;
+typedef __INT64_TYPE__      int64_t;
+typedef __UINT64_TYPE__    uint64_t;
 
 #define INT8_MIN        (-0x7f-1)
 #define INT16_MIN       (-0x7fff-1)
@@ -32,8 +25,8 @@  typedef signed long long int64_t;
 #define UINT32_MAX      0xffffffffu
 #define UINT64_MAX      0xffffffffffffffffull
 
-typedef uint32_t uintptr_t;
+typedef __UINTPTR_TYPE__  uintptr_t;
 
-#define UINTPTR_MAX     UINT32_MAX
+#define UINTPTR_MAX     __UINTPTR_MAX__
 
 #endif
diff --git a/tools/tests/x86_emulator/testcase.mk b/tools/tests/x86_emulator/testcase.mk
index 7875b95d7c97..e47fd0917b54 100644
--- a/tools/tests/x86_emulator/testcase.mk
+++ b/tools/tests/x86_emulator/testcase.mk
@@ -4,7 +4,8 @@  include $(XEN_ROOT)/tools/Rules.mk
 
 $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
 
-CFLAGS += -fno-builtin -fno-stack-protector -g0 $($(TESTCASE)-cflags)
+CFLAGS += -ffreestanding -nostdinc -I$(XEN_ROOT)/tools/firmware/include
+CFLAGS += -fno-stack-protector -g0 $($(TESTCASE)-cflags)
 
 LDFLAGS_DIRECT += $(shell { $(LD) -v --warn-rwx-segments; } >/dev/null 2>&1 && echo --no-warn-rwx-segments)