From 509bf53588045e5f0f795b514c77197b480f0c56 Mon Sep 17 00:00:00 2001 From: "fu.lin" Date: Tue, 27 Apr 2021 17:02:51 +0800 Subject: [PATCH] build: fix static_assert build error The same as https://github.com/strace/strace/issues/138 Upstream patch: - https://github.com/strace/strace/commit/fded17c15bca4150165f899cc47f67bab963d9a7 - https://github.com/strace/strace/commit/592b915033de37322e19f3e6413de33317d272fe spec: disable check after building Signed-off-by: fu.lin --- ...atch => 0000-strace-fix-failed-tests.patch | 0 ...struct-io_cqring_offsets-compile-tim.patch | 44 +++++ ...-io_uring-Add-io_cqring_offset-flags.patch | 152 ++++++++++++++++ 0003-build-regenerate-build-deps.patch | 163 ++++++++++++++++++ strace.spec | 12 +- 5 files changed, 368 insertions(+), 3 deletions(-) rename huawei-strace-fix-failed-tests.patch => 0000-strace-fix-failed-tests.patch (100%) create mode 100644 0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch create mode 100644 0002-io_uring-Add-io_cqring_offset-flags.patch create mode 100644 0003-build-regenerate-build-deps.patch diff --git a/huawei-strace-fix-failed-tests.patch b/0000-strace-fix-failed-tests.patch similarity index 100% rename from huawei-strace-fix-failed-tests.patch rename to 0000-strace-fix-failed-tests.patch diff --git a/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch b/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch new file mode 100644 index 0000000..6fda806 --- /dev/null +++ b/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch @@ -0,0 +1,44 @@ +From ab13c63359d1e1fda50837eb8476e924edd4c573 Mon Sep 17 00:00:00 2001 +From: Chris Packham +Date: Mon, 15 Jun 2020 22:01:25 +1200 +Subject: [PATCH 1/3] io_uring: Remove struct io_cqring_offsets compile time + asserts + +The generated types/check-io_uring.c already checks the kernel's struct +io_cqring_offsets for compatibility with the strace definition so +there's no need for manual checks. + +* io_uring.c [HAVE_STRUCT_IO_CQRING_OFFSETS]: Remove static_asserts. +--- + io_uring.c | 15 --------------- + 1 file changed, 15 deletions(-) + +diff --git a/io_uring.c b/io_uring.c +index cd18345..cfeea82 100644 +--- a/io_uring.c ++++ b/io_uring.c +@@ -18,21 +18,6 @@ + #include "xlat/uring_enter_flags.h" + #include "xlat/uring_register_opcodes.h" + +-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS +-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV +-static_assert(offsetof(struct_io_cqring_offsets, resv) +- >= offsetof(struct io_cqring_offsets, resv), +- "struct io_cqring_offsets.resv offset mismatch" +- ", please update the decoder"); +-static_assert(sizeof_field(struct_io_cqring_offsets, resv) +- <= sizeof_field(struct io_cqring_offsets, resv), +- "struct io_cqring_offsets.resv size mismatch" +- ", please update the decoder"); +-# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */ +-static_assert(0, "struct io_cqring_offsets.resv is missing" +- ", please update the decoder"); +-# endif +-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */ + #ifdef HAVE_STRUCT_IO_URING_PARAMS + # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV + static_assert(offsetof(struct_io_uring_params, resv) +-- +2.27.0 + diff --git a/0002-io_uring-Add-io_cqring_offset-flags.patch b/0002-io_uring-Add-io_cqring_offset-flags.patch new file mode 100644 index 0000000..0c0c64d --- /dev/null +++ b/0002-io_uring-Add-io_cqring_offset-flags.patch @@ -0,0 +1,152 @@ +From cccd880f435ec5a3b8e417fce5f56116413eb02d Mon Sep 17 00:00:00 2001 +From: Chris Packham +Date: Mon, 15 Jun 2020 22:01:26 +1200 +Subject: [PATCH 2/3] io_uring: Add io_cqring_offset flags + +Add support for displaying struct io_cqring_offsets.flags introduced +by Linux kernel commits v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21. + +* types/io_uring.h (struct_io_cqring_offsets): Replace resv array +with flags, resv1, and resv2 fields. +* xlat/uring_cqring_flags.in: New file. +* configure.ac (AC_CHECK_MEMBERS): Check struct io_cqring_offsets.flags. +* io_uring.c: Include "xlat/uring_cqring_flags.h". +(SYS_FUNC(io_uring_setup)): Replace printing of the resv array +of struct io_cqring_offsets with flags, resv1, and resv2 fields. +* tests/io_uring_setup.c: Check it. + +Co-authored-by: Dmitry V. Levin +Resolves: https://github.com/strace/strace/issues/138 +--- + configure.ac | 1 + + io_uring.c | 11 +++++++---- + tests/io_uring_setup.c | 31 ++++++++++++++++++++++++++----- + types/io_uring.h | 4 +++- + xlat/uring_cqring_flags.in | 1 + + 5 files changed, 38 insertions(+), 10 deletions(-) + create mode 100644 xlat/uring_cqring_flags.in + +diff --git a/configure.ac b/configure.ac +index 7c4f929..958c097 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -475,6 +475,7 @@ AC_CHECK_HEADERS([linux/bpf.h], [ + + AC_CHECK_HEADERS([linux/io_uring.h], [ + AC_CHECK_MEMBERS(m4_normalize([ ++ struct io_cqring_offsets.flags, + struct io_uring_params.features, + struct io_uring_params.wq_fd, + struct io_uring_params.resv +diff --git a/io_uring.c b/io_uring.c +index cfeea82..2ffe163 100644 +--- a/io_uring.c ++++ b/io_uring.c +@@ -17,6 +17,7 @@ + #include "xlat/uring_setup_flags.h" + #include "xlat/uring_enter_flags.h" + #include "xlat/uring_register_opcodes.h" ++#include "xlat/uring_cqring_flags.h" + + #ifdef HAVE_STRUCT_IO_URING_PARAMS + # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV +@@ -88,10 +89,12 @@ SYS_FUNC(io_uring_setup) + PRINT_FIELD_U(", ", params.cq_off, ring_entries); + PRINT_FIELD_U(", ", params.cq_off, overflow); + PRINT_FIELD_U(", ", params.cq_off, cqes); +- if (!IS_ARRAY_ZERO(params.cq_off.resv)) { +- PRINT_FIELD_ARRAY(", ", params.cq_off, resv, tcp, +- print_xint64_array_member); +- } ++ PRINT_FIELD_FLAGS(", ", params.cq_off, flags, ++ uring_cqring_flags, "IORING_CQ_???"); ++ if (params.cq_off.resv1) ++ PRINT_FIELD_X(", ", params.cq_off, resv1); ++ if (params.cq_off.resv2) ++ PRINT_FIELD_X(", ", params.cq_off, resv2); + tprints("}"); + } + tprints("}"); +diff --git a/tests/io_uring_setup.c b/tests/io_uring_setup.c +index 317b0d7..a59e4a1 100644 +--- a/tests/io_uring_setup.c ++++ b/tests/io_uring_setup.c +@@ -27,6 +27,7 @@ + # include "xlat.h" + + # include "xlat/uring_setup_features.h" ++# include "xlat/uring_cqring_flags.h" + + # ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES + # ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD +@@ -144,20 +145,40 @@ main(void) + params->sq_off.resv2); + + printf("}, cq_off={head=%u, tail=%u, ring_mask=%u" +- ", ring_entries=%u, overflow=%u, cqes=%u", ++ ", ring_entries=%u, overflow=%u, cqes=%u, flags=", + params->cq_off.head, + params->cq_off.tail, + params->cq_off.ring_mask, + params->cq_off.ring_entries, + params->cq_off.overflow, + params->cq_off.cqes); +- if (params->cq_off.resv[0] || params->cq_off.resv[1]) { +- printf(", resv=[%#llx, %#llx]", ++#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS ++ printflags(uring_cqring_flags, ++ params->cq_off.flags, ++ "IORING_CQ_???"); ++ if (params->cq_off.resv1) ++ printf(", resv1=%#x", params->cq_off.resv1); ++ if (params->cq_off.resv2) ++ printf(", resv2=%#llx", + (unsigned long long) +- params->cq_off.resv[0], ++ params->cq_off.resv2); ++#else ++ union { ++ struct { ++ uint32_t flags; ++ uint32_t resv1; ++ } s; ++ uint64_t v; ++ } u = { .v = params->cq_off.resv[0] }; ++ printflags(uring_cqring_flags, u.s.flags, ++ "IORING_CQ_???"); ++ if (u.s.resv1) ++ printf(", resv1=%#x", u.s.resv1); ++ if (params->cq_off.resv[1]) ++ printf(", resv2=%#llx", + (unsigned long long) + params->cq_off.resv[1]); +- } ++#endif + + printf("}}) = %ld\n", rc); + } +diff --git a/types/io_uring.h b/types/io_uring.h +index 76f432c..2fe1c13 100644 +--- a/types/io_uring.h ++++ b/types/io_uring.h +@@ -31,7 +31,9 @@ typedef struct { + uint32_t ring_entries; + uint32_t overflow; + uint32_t cqes; +- uint64_t resv[2]; ++ /** Added by v5.8-rc1~190^2~22 */ uint32_t flags; ++ /** Added by v5.8-rc1~190^2~22 */ uint32_t resv1; ++ /** Added by v5.8-rc1~190^2~22 */ uint64_t resv2; + } struct_io_cqring_offsets; + + typedef struct { +diff --git a/xlat/uring_cqring_flags.in b/xlat/uring_cqring_flags.in +new file mode 100644 +index 0000000..c81fbc2 +--- /dev/null ++++ b/xlat/uring_cqring_flags.in +@@ -0,0 +1 @@ ++IORING_CQ_EVENTFD_DISABLED 1U +-- +2.27.0 + diff --git a/0003-build-regenerate-build-deps.patch b/0003-build-regenerate-build-deps.patch new file mode 100644 index 0000000..3405389 --- /dev/null +++ b/0003-build-regenerate-build-deps.patch @@ -0,0 +1,163 @@ +From 1fb2d37673c140853141459089fa6213bdaaac3a Mon Sep 17 00:00:00 2001 +From: "fu.lin" +Date: Tue, 27 Apr 2021 16:23:35 +0800 +Subject: [PATCH 3/3] build: regenerate build deps + +--- + config.h.in | 7 ++++-- + configure | 18 +++++++++++---- + types/check-io_uring.c | 6 ++--- + types/check-io_uring.m4 | 2 +- + xlat/uring_cqring_flags.h | 48 +++++++++++++++++++++++++++++++++++++++ + 5 files changed, 71 insertions(+), 10 deletions(-) + create mode 100644 xlat/uring_cqring_flags.h + +diff --git a/config.h.in b/config.h.in +index 4cd5c2b..f736603 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -1378,8 +1378,11 @@ + /* Define to 1 if the system has the type `struct io_cqring_offsets'. */ + #undef HAVE_STRUCT_IO_CQRING_OFFSETS + +-/* Define to 1 if `resv' is a member of `struct io_cqring_offsets'. */ +-#undef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV ++/* Define to 1 if `flags' is a member of `struct io_cqring_offsets'. */ ++#undef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS ++ ++/* Define to 1 if `resv2' is a member of `struct io_cqring_offsets'. */ ++#undef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2 + + /* Define to 1 if the system has the type `struct io_sqring_offsets'. */ + #undef HAVE_STRUCT_IO_SQRING_OFFSETS +diff --git a/configure b/configure +index a91d4a1..ba67b3d 100755 +--- a/configure ++++ b/configure +@@ -12307,7 +12307,17 @@ if test "x$ac_cv_header_linux_io_uring_h" = xyes; then : + #define HAVE_LINUX_IO_URING_H 1 + _ACEOF + +- ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include ++ ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "flags" "ac_cv_member_struct_io_cqring_offsets_flags" "#include ++" ++if test "x$ac_cv_member_struct_io_cqring_offsets_flags" = xyes; then : ++ ++cat >>confdefs.h <<_ACEOF ++#define HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS 1 ++_ACEOF ++ ++ ++fi ++ac_fn_c_check_member "$LINENO" "struct io_uring_params" "features" "ac_cv_member_struct_io_uring_params_features" "#include + " + if test "x$ac_cv_member_struct_io_uring_params_features" = xyes; then : + +@@ -13375,13 +13385,13 @@ cat >>confdefs.h <<_ACEOF + #define HAVE_STRUCT_IO_CQRING_OFFSETS 1 + _ACEOF + +-ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "resv" "ac_cv_member_struct_io_cqring_offsets_resv" "$ac_includes_default ++ac_fn_c_check_member "$LINENO" "struct io_cqring_offsets" "resv2" "ac_cv_member_struct_io_cqring_offsets_resv2" "$ac_includes_default + #include + " +-if test "x$ac_cv_member_struct_io_cqring_offsets_resv" = xyes; then : ++if test "x$ac_cv_member_struct_io_cqring_offsets_resv2" = xyes; then : + + cat >>confdefs.h <<_ACEOF +-#define HAVE_STRUCT_IO_CQRING_OFFSETS_RESV 1 ++#define HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2 1 + _ACEOF + + +diff --git a/types/check-io_uring.c b/types/check-io_uring.c +index dc21569..de18ebf 100644 +--- a/types/check-io_uring.c ++++ b/types/check-io_uring.c +@@ -14,13 +14,13 @@ static_assert(sizeof(struct io_sqring_offsets) <= offsetof(struct_io_sqring_offs + #endif /* HAVE_STRUCT_IO_SQRING_OFFSETS */ + + #ifdef HAVE_STRUCT_IO_CQRING_OFFSETS +-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV ++# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2 + static_assert(sizeof(struct io_cqring_offsets) == sizeof(struct_io_cqring_offsets), + "struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel"); + # else +-static_assert(sizeof(struct io_cqring_offsets) <= offsetof(struct_io_cqring_offsets, resv), ++static_assert(sizeof(struct io_cqring_offsets) <= offsetof(struct_io_cqring_offsets, resv2), + "struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel"); +-# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */ ++# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_RESV2 */ + #endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */ + + #ifdef HAVE_STRUCT_IO_URING_PARAMS +diff --git a/types/check-io_uring.m4 b/types/check-io_uring.m4 +index c38ad38..d70b845 100644 +--- a/types/check-io_uring.m4 ++++ b/types/check-io_uring.m4 +@@ -8,7 +8,7 @@ AC_CHECK_TYPES([struct io_sqring_offsets], + #include ]) + + AC_CHECK_TYPES([struct io_cqring_offsets], +-[AC_CHECK_MEMBERS([struct io_cqring_offsets.resv],,,[AC_INCLUDES_DEFAULT ++[AC_CHECK_MEMBERS([struct io_cqring_offsets.resv2],,,[AC_INCLUDES_DEFAULT + #include ])],,[AC_INCLUDES_DEFAULT + #include ]) + +diff --git a/xlat/uring_cqring_flags.h b/xlat/uring_cqring_flags.h +new file mode 100644 +index 0000000..0352749 +--- /dev/null ++++ b/xlat/uring_cqring_flags.h +@@ -0,0 +1,48 @@ ++/* Generated by ./xlat/gen.sh from ./xlat/uring_cqring_flags.in; do not edit. */ ++ ++#include "gcc_compat.h" ++#include "static_assert.h" ++ ++#if defined(IORING_CQ_EVENTFD_DISABLED) || (defined(HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) && HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) ++DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE ++static_assert((IORING_CQ_EVENTFD_DISABLED) == (1U), "IORING_CQ_EVENTFD_DISABLED != 1U"); ++DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE ++#else ++# define IORING_CQ_EVENTFD_DISABLED 1U ++#endif ++ ++#ifndef XLAT_MACROS_ONLY ++ ++# ifdef IN_MPERS ++ ++# error static const struct xlat uring_cqring_flags in mpers mode ++ ++# else ++ ++static const struct xlat_data uring_cqring_flags_xdata[] = { ++ XLAT(IORING_CQ_EVENTFD_DISABLED), ++ #define XLAT_VAL_0 ((unsigned) (IORING_CQ_EVENTFD_DISABLED)) ++ #define XLAT_STR_0 STRINGIFY(IORING_CQ_EVENTFD_DISABLED) ++}; ++static ++const struct xlat uring_cqring_flags[1] = { { ++ .data = uring_cqring_flags_xdata, ++ .size = ARRAY_SIZE(uring_cqring_flags_xdata), ++ .type = XT_NORMAL, ++ .flags_mask = 0 ++# ifdef XLAT_VAL_0 ++ | XLAT_VAL_0 ++# endif ++ , ++ .flags_strsz = 0 ++# ifdef XLAT_STR_0 ++ + sizeof(XLAT_STR_0) ++# endif ++ , ++} }; ++ ++# undef XLAT_STR_0 ++# undef XLAT_VAL_0 ++# endif /* !IN_MPERS */ ++ ++#endif /* !XLAT_MACROS_ONLY */ +-- +2.27.0 + diff --git a/strace.spec b/strace.spec index eb125f8..52fd820 100644 --- a/strace.spec +++ b/strace.spec @@ -3,9 +3,9 @@ Summary: Tracks and displays system calls associated with a running process Name: strace Version: 5.6 -Release: 1 +Release: 2 # The test suite is GPLv2+, all the rest is LGPLv2.1+. -License: LGPL-2.1+ and GPL-2.0+ +License: LGPL-2.0+ and GPL-2.0 # Some distros require Group tag to be present, # some require Group tag to be absent, # some do not care about Group tag at all, @@ -24,7 +24,10 @@ BuildRequires: gcc gzip BuildRequires: pkgconfig(bluez) %endif -Patch9000: huawei-strace-fix-failed-tests.patch +Patch: 0000-strace-fix-failed-tests.patch +Patch: 0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch +Patch: 0002-io_uring-Add-io_cqring_offset-flags.patch +Patch: 0003-build-regenerate-build-deps.patch # Install elfutils-devel or libdw-devel to enable strace -k option. # Install binutils-devel to enable symbol demangling. @@ -101,6 +104,9 @@ echo 'END OF TEST SUITE INFORMATION' %{_mandir}/man1/* %changelog +* Wed Apr 28 2021 fu.lin - 5.6-2 +- build: fix build error when the strace is builded in the environment with io_uring feature kernel devel package + * Fri Apr 24 2020 shikemeng - 5.6-1 - Upgrade strace version to 5.6 -- Gitee