guix_mirror_bot pushed a commit to branch master
in repository guix.

commit 788b0339d4e05e2b5ab67c60f2a1f81e446cf3f7
Author: Maxim Cournoyer <ma...@guixotic.coop>
AuthorDate: Mon Jul 21 00:25:52 2025 +0900

    gnu: opendht: Fix build with GCC 14.
    
    * gnu/packages/patches/opendht-nanosleep.patch: New patch.
    * gnu/local.mk (dist_patch_DATA): Register it.
    * gnu/packages/networking.scm (opendht) [source]: Apply it.
    
    Change-Id: I14589dba3a99ae51bb522ffdbe2a1390c74aa75a
---
 gnu/local.mk                                 |  1 +
 gnu/packages/networking.scm                  |  3 +-
 gnu/packages/patches/opendht-nanosleep.patch | 61 ++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index c8cc45aec0..f1a9e940c6 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1977,6 +1977,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/openboardview-use-system-mpc.patch      \
   %D%/packages/patches/openbox-add-fix-for-glib2-exposed-segfault.patch \
   %D%/packages/patches/openbox-python3.patch                   \
+  %D%/packages/patches/opendht-nanosleep.patch                 \
   %D%/packages/patches/openexr-2-gcc-14.patch                  \
   %D%/packages/patches/openfst-for-vosk-fix-unique-ptr.patch   \
   %D%/packages/patches/openjdk-currency-time-bomb.patch                \
diff --git a/gnu/packages/networking.scm b/gnu/packages/networking.scm
index f6e72709a9..9dc4b24cd0 100644
--- a/gnu/packages/networking.scm
+++ b/gnu/packages/networking.scm
@@ -3961,7 +3961,8 @@ and targeted primarily for asynchronous processing of 
HTTP-requests.")
                 (file-name (git-file-name name version))
                 (sha256
                  (base32
-                  "069y4mgygjsfp5szfbqr7l30g7fbcqqj62h11byyq9k24rl7ilsq"))))
+                  "069y4mgygjsfp5szfbqr7l30g7fbcqqj62h11byyq9k24rl7ilsq"))
+                (patches (search-patches "opendht-nanosleep.patch"))))
       (outputs '("out" "python" "tools" "debug"))
       (build-system gnu-build-system)
       (arguments
diff --git a/gnu/packages/patches/opendht-nanosleep.patch 
b/gnu/packages/patches/opendht-nanosleep.patch
new file mode 100644
index 0000000000..42b1b24c34
--- /dev/null
+++ b/gnu/packages/patches/opendht-nanosleep.patch
@@ -0,0 +1,61 @@
+Upstream-status: merged with commit ccec6c2f6770484278b25c3335d4bd8882bc4c87
+
+diff --git a/configure.ac b/configure.ac
+index b54d5b49..584b0179 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -83,6 +83,7 @@ case "${host_os}" in
+     ;;
+   linux*)
+     SYS=linux
++    CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L"
+     ;;
+   darwin*)
+     SYS=darwin
+diff --git a/src/compat/msvc/unistd.h b/src/compat/msvc/unistd.h
+index d43d4796..abcc1c61 100644
+--- a/src/compat/msvc/unistd.h
++++ b/src/compat/msvc/unistd.h
+@@ -50,4 +50,6 @@
+ typedef int mode_t;
+ #include <BaseTsd.h>
+ 
++#define nanosleep(x) Sleep((x) / 1000000)
++
+ #endif
+diff --git a/tools/dhtcnode.c b/tools/dhtcnode.c
+index cdb04714..f78a7f7f 100644
+--- a/tools/dhtcnode.c
++++ b/tools/dhtcnode.c
+@@ -24,12 +24,17 @@
+ #include <stdlib.h>
+ #include <stdatomic.h>
+ #include <inttypes.h>
++#include <time.h>
+ 
+ #include <getopt.h>
+ #include <readline/readline.h>
+ #include <readline/history.h>
+ #include <arpa/inet.h>
+ 
++#ifdef _WIN32
++#include <windows.h>
++#endif
++
+ struct op_context {
+     dht_runner* runner;
+     atomic_bool stop;
+@@ -287,7 +292,12 @@ int main(int argc, char **argv)
+ 
+     // Wait until shutdown callback is called
+     while (!atomic_load(&ctx.stop)) {
+-        usleep(10000);
++#ifdef _WIN32
++        Sleep(10);              // 10ms
++#else
++        struct timespec ts = {0, 10000000}; // 10ms
++        nanosleep(&ts, NULL);
++#endif
+     }
+     dht_runner_delete(runner);
+     return EXIT_SUCCESS;

Reply via email to