From 16d5059c686a9da20b3ddbbd28141fe853656b95 Mon Sep 17 00:00:00 2001 From: zhanghongtao Date: Mon, 10 Oct 2022 19:56:51 +0800 Subject: [PATCH] configure add CONFIG_HAVE_ARC4RANDOM --- ...configure-add-CONFIG_HAVE_ARC4RANDOM.patch | 111 ++++++++++++++++++ spdk.spec | 6 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 0028-configure-add-CONFIG_HAVE_ARC4RANDOM.patch diff --git a/0028-configure-add-CONFIG_HAVE_ARC4RANDOM.patch b/0028-configure-add-CONFIG_HAVE_ARC4RANDOM.patch new file mode 100644 index 0000000..d791591 --- /dev/null +++ b/0028-configure-add-CONFIG_HAVE_ARC4RANDOM.patch @@ -0,0 +1,111 @@ +From 1fc649fe351919c60c7e1e5044bd6fb00ce59edd Mon Sep 17 00:00:00 2001 +From: Jim Harris +Date: Fri, 12 Aug 2022 05:00:25 +0000 +Subject: [PATCH] configure: add CONFIG_HAVE_ARC4RANDOM + +glibc 2.36 added arc4random(), which breaks +the SPDK iSCSI build since it always implements its +own arc4random() implementation on non-FreeBSD OS +(meaning always on Linux). + +So instead add a CONFIG_HAVE_ARC4RANDOM and remove +the explicit FreeBSD dependency - this will work on +FreeBSD as well as Linux with >= glibc 2.36. + +Also fix check_format.sh, so that it does not +enforce spdk/stdinc.h checks on code snippets in +the configure file. + +Fixes issue #2637. + +Reported-by: Karl Bonde Torp +Signed-off-by: Jim Harris +Change-Id: Iab9da8ae30d62a56869530846372ffddf7138eed +Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14028 +Community-CI: Mellanox Build Bot +Tested-by: SPDK CI Jenkins +Reviewed-by: Aleksey Marchuk +Reviewed-by: Changpeng Liu +Reviewed-by: Dong Yi + +Confilict: file CONFIG context is inconsistent +--- + CONFIG | 3 +++ + configure | 5 +++++ + lib/iscsi/iscsi.c | 5 ++--- + scripts/check_format.sh | 2 +- + 4 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/CONFIG b/CONFIG +index 214e59e..b8dde2e 100644 +--- a/CONFIG ++++ b/CONFIG +@@ -171,3 +171,6 @@ CONFIG_RAID5=n + + # Build with IDXD support + CONFIG_IDXD=n ++ ++# arc4random is available in stdlib.h ++CONFIG_HAVE_ARC4RANDOM=n +diff --git a/configure b/configure +index 01db27a..376019c 100755 +--- a/configure ++++ b/configure +@@ -750,6 +750,11 @@ if [[ "${CONFIG[TSAN]}" = "y" ]]; then + fi + fi + ++if echo -e '#include \nint main(void) { arc4random(); return 0; }\n' \ ++ | "${BUILD_CMD[@]}" - 2> /dev/null; then ++ CONFIG[HAVE_ARC4RANDOM]="y" ++fi ++ + if [[ "${CONFIG[OCF]}" = "y" ]]; then + # If OCF_PATH is a file, assume it is a library and use it to compile with + if [ -f ${CONFIG[OCF_PATH]} ]; then +diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c +index 4bca616..48e548a 100644 +--- a/lib/iscsi/iscsi.c ++++ b/lib/iscsi/iscsi.c +@@ -64,7 +64,6 @@ + + #ifdef __FreeBSD__ + #define HAVE_SRANDOMDEV 1 +-#define HAVE_ARC4RANDOM 1 + #endif + + struct spdk_iscsi_globals g_iscsi = { +@@ -99,7 +98,7 @@ srandomdev(void) + } + #endif /* HAVE_SRANDOMDEV */ + +-#ifndef HAVE_ARC4RANDOM ++#ifndef SPDK_CONFIG_HAVE_ARC4RANDOM + static int g_arc4random_initialized = 0; + + static uint32_t +@@ -117,7 +116,7 @@ arc4random(void) + r = (r1 << 16) | r2; + return r; + } +-#endif /* HAVE_ARC4RANDOM */ ++#endif /* SPDK_CONFIG_HAVE_ARC4RANDOM */ + + static void + gen_random(uint8_t *buf, size_t len) +diff --git a/scripts/check_format.sh b/scripts/check_format.sh +index b522115..8c242a7 100755 +--- a/scripts/check_format.sh ++++ b/scripts/check_format.sh +@@ -240,7 +240,7 @@ function check_posix_includes() { + local rc=0 + + echo -n "Checking for POSIX includes..." +- git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' > scripts/posix.log || true ++ git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' ':!configure' > scripts/posix.log || true + if [ -s scripts/posix.log ]; then + echo "POSIX includes detected. Please include spdk/stdinc.h instead." + cat scripts/posix.log +-- +2.33.0 + diff --git a/spdk.spec b/spdk.spec index f5ecf85..76fcf58 100644 --- a/spdk.spec +++ b/spdk.spec @@ -3,7 +3,7 @@ Name: spdk Version: 21.01.1 -Release: 5 +Release: 6 Summary: Set of libraries and utilities for high performance user-mode storage License: BSD and MIT URL: http://spdk.io @@ -35,6 +35,7 @@ Patch24: 0024-Add-CUSE-switch-for-nvme-ctrlr.patch Patch25: 0025-Adapt-for-ES3000-serial-vendor-special-opcode-in-CUS.patch Patch26: 0026-Fix-race-condition-in-continuous-setup-and-teardown-.patch Patch27: 0027-Change-log-level-in-poll-timeout.patch +Patch28: 0028-configure-add-CONFIG_HAVE_ARC4RANDOM.patch %define package_version %{version}-%{release} @@ -206,6 +207,9 @@ mv doc/output/html/ %{install_docdir} %changelog +* Mon Oct 10 2022 Hongtao Zhang - 21.01.1-6 +- configure add CONFIG_HAVE_ARC4RANDOM + * Tue May 24 2022 Weifeng Su - 21.01.1-5 - Add support for HSAK -- Gitee