]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix build breaker on mingw-w64
authorSimon Marchi <simark@simark.ca>
Wed, 4 Dec 2024 20:29:52 +0000 (21:29 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 4 Dec 2024 20:29:52 +0000 (21:29 +0100)
The mingw-w64 build breaks currently:
...
    In file included from gdb/cli/cli-cmds.c:58:
    gdbsupport/eintr.h: In function ‘pid_t gdb::waitpid(pid_t, int*, int)’:
    gdbsupport/eintr.h:77:35: error: ‘::waitpid’ has not been declared; \
                                     did you mean ‘gdb::waitpid’?
       77 |   return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options);
          |                                   ^~~~~~~
          |                                   gdb::waitpid
    gdbsupport/eintr.h:75:1: note: ‘gdb::waitpid’ declared here
       75 | waitpid (pid_t pid, int *wstatus, int options)
          | ^~~~~~~
...

This is a regression since commit 658a03e9e85 ("[gdbsupport] Add
gdb::{waitpid,read,write,close}"), which moved the use of ::waitpid from
run_under_shell, where it was used conditionally:
...
 #if defined(CANT_FORK) || \
       (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK))
   ...
 #else
   ...
       int ret = gdb::handle_eintr (-1, ::waitpid, pid, &status, 0);
...
to gdb::waitpid, where it's used unconditionally:
...
inline pid_t
waitpid (pid_t pid, int *wstatus, int options)
{
  return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options);
}
...

Likewise for ::wait.

Guard these uses with HAVE_WAITPID and HAVE_WAIT.

Reproduced and tested by doing a mingw-w64 cross-build on x86_64-linux.

Reported-By: Simon Marchi <simark@simark.ca>
Co-Authored-By: Tom de Vries <tdevries@suse.de>
gdb/config.in
gdb/configure
gdb/configure.ac
gdbsupport/config.in
gdbsupport/configure
gdbsupport/configure.ac
gdbsupport/eintr.h

index 187b42ca29b77915d13c0da3f39e9f28da313bb3..db63aeaec75a69573d21ec5da102eb422e58e9e8 100644 (file)
 /* Define to 1 if you have the <vfork.h> header file. */
 #undef HAVE_VFORK_H
 
-/* Define to 1 if you have the `waitpid' function. */
-#undef HAVE_WAITPID
-
 /* Define to 1 if you have the <wait.h> header file. */
 #undef HAVE_WAIT_H
 
index 138c2a153b7b562a4c9a711dfe4899bd67cffc35..de750f4fafee64900fc1a6d4a1d8aed2ead73657 100755 (executable)
@@ -29924,7 +29924,6 @@ for ac_func in  \
   sigsetmask \
   ttrace \
   use_default_colors \
-  waitpid \
   wresize \
 
 do :
index d638b8f3c8e34b69ae8685e05955f92752efcfcb..230c0be79c7c51f64f748cfa5c446fc0d62b7520 100644 (file)
@@ -1389,7 +1389,6 @@ AC_CHECK_FUNCS([ \
   sigsetmask \
   ttrace \
   use_default_colors \
-  waitpid \
   wresize \
 ])
 
index 8467072752a6648c68091eefa830e68bb18f1255..0beacf22c057ca8c067c5fa1fd505e6e9d761e9d 100644 (file)
 /* Define to 1 if you have the <vfork.h> header file. */
 #undef HAVE_VFORK_H
 
+/* Define to 1 if you have the `wait' function. */
+#undef HAVE_WAIT
+
+/* Define to 1 if you have the `waitpid' function. */
+#undef HAVE_WAITPID
+
 /* Define to 1 if you have the <wait.h> header file. */
 #undef HAVE_WAIT_H
 
index 87980f6870f372d91565eadeb9cfc07d79c6b502..67a48c4730550e029a921f17d72056cf809e473f 100755 (executable)
@@ -13948,6 +13948,22 @@ else
 fi
 
 
+for ac_func in  \
+    waitpid \
+    wait
+
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
 # Check the return and argument types of ptrace.
 
 
index b30b4365f5320d937171fe988bc3480e0d073e5f..92e2a852111fdf53675a1cde626a4cc3f672716f 100644 (file)
@@ -56,6 +56,11 @@ AM_CONDITIONAL(SELFTEST, $enable_unittests)
 AM_CONDITIONAL(HAVE_PIPE_OR_PIPE2,
    [test x$ac_cv_func_pipe = xyes -o x$ac_cv_func_pipe2 = xyes ])
 
+AC_CHECK_FUNCS([ \
+    waitpid \
+    wait
+  ])
+
 # Check the return and argument types of ptrace.
 GDB_AC_PTRACE
 
index 3980e3f5ac1cb4b0807d9a7fa8f25bf4596b84e0..4cab8f9d48dee81a3d77a60a8632f9b1cf164195 100644 (file)
@@ -71,11 +71,13 @@ handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
   return ret;
 }
 
+#ifdef HAVE_WAITPID
 inline pid_t
 waitpid (pid_t pid, int *wstatus, int options)
 {
   return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options);
 }
+#endif /* HAVE_WAITPID */
 
 inline int
 open (const char *pathname, int flags)
@@ -83,11 +85,13 @@ open (const char *pathname, int flags)
   return gdb::handle_eintr (-1, ::open, pathname, flags);
 }
 
+#ifdef HAVE_WAIT
 inline pid_t
 wait (int *wstatus)
 {
   return gdb::handle_eintr (-1, ::wait, wstatus);
 }
+#endif /* HAVE_WAIT */
 
 inline int
 close (int fd)