Skip to contentSkip to conversation

tests/tcg: Do not use inttypes.h in multiarch/system/memory.c

PATCH Applied Ilya Leoshkevich 3 participants 6 messages Oct 10, 2024 – Dec 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/tcg: Do not use inttypes.h in multiarch/system/memory.c

make check-tcg fails on Fedora with the following error message:

alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...] qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error: inttypes.h: No such file or directory
17 | #include <inttypes.h>
| ^~~~~~~~~~~~
compilation terminated.

The reason is that Fedora has cross-compilers, but no cross-glibc headers. Fix by hardcoding the format specifiers and dropping the include.

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check memory instrumentation")
---
 tests/tcg/multiarch/system/memory.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
tests/tcg/multiarch/system/memory.c +4 -5
index 65a6038a241..7508f6b916d 100644
@@ -14,7 +14,6 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include <inttypes.h>
 #include <minilib.h>
 
 #ifndef CHECK_UNALIGNED
@@ -511,8 +510,8 @@ int main(void)
     int i;
     bool ok = true;
 
-    ml_printf("Test data start: 0x%"PRIxPTR"\n", &test_data[0]);
-    ml_printf("Test data end: 0x%"PRIxPTR"\n", &test_data[TEST_SIZE]);
+    ml_printf("Test data start: 0x%lx\n", (unsigned long)&test_data[0]);
+    ml_printf("Test data end: 0x%lx\n", (unsigned long)&test_data[TEST_SIZE]);
 
     /* Run through the unsigned tests first */
     for (i = 0; i < ARRAY_SIZE(init_ufns) && ok; i++) {
@@ -529,8 +528,8 @@ int main(void)
         ok = do_signed_reads(true);
     }
 
-    ml_printf("Test data read: %"PRId32"\n", test_read_count);
-    ml_printf("Test data write: %"PRId32"\n", test_write_count);
+    ml_printf("Test data read: %lu\n", (unsigned long)test_read_count);
+    ml_printf("Test data write: %lu\n", (unsigned long)test_write_count);
     ml_printf("Test complete: %s\n", ok ? "PASSED" : "FAILED");
     return ok ? 0 : -1;
 }
Signature · 1 line
2.46.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Ilya Leoshkevich

make check-tcg fails on Fedora with the following error message:

alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...] qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error: inttypes.h: No such file or directory
17 | #include <inttypes.h>
| ^~~~~~~~~~~~
compilation terminated.

The reason is that Fedora has cross-compilers, but no cross-glibc headers. Fix by hardcoding the format specifiers and dropping the include.

Quoted 6 lines

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check memory instrumentation")
Quoted 38 lines
---
  tests/tcg/multiarch/system/memory.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
tests/tcg/multiarch/system/memory.c +4 -5
index 65a6038a241..7508f6b916d 100644
@@ -14,7 +14,6 @@
 
  #include <stdint.h>
  #include <stdbool.h>
-#include <inttypes.h>
  #include <minilib.h>
 
  #ifndef CHECK_UNALIGNED
@@ -511,8 +510,8 @@ int main(void)
      int i;
      bool ok = true;
 
-    ml_printf("Test data start: 0x%"PRIxPTR"\n", &test_data[0]);
-    ml_printf("Test data end: 0x%"PRIxPTR"\n", &test_data[TEST_SIZE]);
+    ml_printf("Test data start: 0x%lx\n", (unsigned long)&test_data[0]);
+    ml_printf("Test data end: 0x%lx\n", (unsigned long)&test_data[TEST_SIZE]);
 
      /* Run through the unsigned tests first */
      for (i = 0; i < ARRAY_SIZE(init_ufns) && ok; i++) {
@@ -529,8 +528,8 @@ int main(void)
          ok = do_signed_reads(true);
      }
 
-    ml_printf("Test data read: %"PRId32"\n", test_read_count);
-    ml_printf("Test data write: %"PRId32"\n", test_write_count);
+    ml_printf("Test data read: %lu\n", (unsigned long)test_read_count);
+    ml_printf("Test data write: %lu\n", (unsigned long)test_write_count);
      ml_printf("Test complete: %s\n", ok ? "PASSED" : "FAILED");
      return ok ? 0 : -1;
  }
#2 lore raw
Quoted 19 lines · Paolo Bonzini
Quoted 18 lines · Ilya Leoshkevich

make check-tcg fails on Fedora with the following error message:

     alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...] qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error:
inttypes.h: No such file or directory
        17 | #include <inttypes.h>
           |          ^~~~~~~~~~~~
     compilation terminated.

The reason is that Fedora has cross-compilers, but no cross-glibc headers. Fix by hardcoding the format specifiers and dropping the include.

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Quoted 5 lines
Quoted 3 lines
Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check memory

instrumentation")

[...]

Thanks for the review!

Could someone please pick this one and also [1] up?
Both patches are aimed at improving the situation with the test builds.

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

#3 lore raw
Quoted 28 lines · Ilya Leoshkevich
Quoted 24 lines · Paolo Bonzini
Quoted 14 lines · Ilya Leoshkevich

make check-tcg fails on Fedora with the following error message:

     alpha-linux-gnu-gcc [...]
qemu/tests/tcg/multiarch/system/memory.c -o memory [...]
     qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error:
inttypes.h: No such file or directory
        17 | #include <inttypes.h>
           |          ^~~~~~~~~~~~
     compilation terminated.

The reason is that Fedora has cross-compilers, but no cross-glibc headers. Fix by hardcoding the format specifiers and dropping the include.

Quoted 7 lines

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check memory

instrumentation")

[...]

Quoted 7 lines

Thanks for the review!

Could someone please pick this one and also [1] up?
Both patches are aimed at improving the situation with the test builds.

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

Queued, thanks.

r~

#4 lore raw
Quoted 40 lines · Richard Henderson
Quoted 39 lines · Ilya Leoshkevich
Quoted 23 lines · Paolo Bonzini
Quoted 22 lines · Ilya Leoshkevich

make check-tcg fails on Fedora with the following error message:

      alpha-linux-gnu-gcc [...] qemu/tests/tcg/multiarch/system/memory.c -o memory [...] qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal error:
inttypes.h: No such file or directory
         17 | #include <inttypes.h>
            |          ^~~~~~~~~~~~
      compilation terminated.

The reason is that Fedora has cross-compilers, but no cross- glibc
headers. Fix by hardcoding the format specifiers and dropping the
include.

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Quoted 6 lines
Quoted 4 lines
Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check

memory
instrumentation")

[...]

Thanks for the review!

Could someone please pick this one and also [1] up? Both patches are aimed at improving the situation with the test builds.

Quoted 6 lines
Quoted 2 lines

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

Queued, thanks.

r~

Hi Richard,

I noticed that this patch doesn't seem to be in master yet. Could it be that it was overlooked, or is there some issue with it that I missed?

Best regards,
Ilya

#5 lore raw
Quoted 44 lines · Ilya Leoshkevich
Quoted 43 lines · Richard Henderson
Quoted 41 lines · Ilya Leoshkevich
Quoted 23 lines · Paolo Bonzini
Quoted 22 lines · Ilya Leoshkevich

make check-tcg fails on Fedora with the following error message:

      alpha-linux-gnu-gcc [...]
qemu/tests/tcg/multiarch/system/memory.c -o memory [...]
      qemu/tests/tcg/multiarch/system/memory.c:17:10: fatal
error:
inttypes.h: No such file or directory
         17 | #include <inttypes.h>
            |          ^~~~~~~~~~~~
      compilation terminated.

The reason is that Fedora has cross-compilers, but no cross- glibc
headers. Fix by hardcoding the format specifiers and dropping the
include.

An alternative fix would be to introduce a configure check for inttypes.h. But this would make it impossible to use Fedora cross-compilers for softmmu tests, which used to work so far.

Quoted 6 lines
Quoted 4 lines
Fixes ecbcc9ead2f8 ("tests/tcg: add a system test to check

memory
instrumentation")

[...]

Thanks for the review!

Could someone please pick this one and also [1] up? Both patches are aimed at improving the situation with the test builds.

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 8 lines
Quoted 3 lines

Queued, thanks.

r~

Hi Richard,

I noticed that this patch doesn't seem to be in master yet. Could it be that it was overlooked, or is there some issue with it that I missed?

Sorry, I'm not sure what happened. I must have made some mistake with destructive branch pushing somewhere. I've queued it again. :-}

r~