Package: pgstat
Version: 1.4.0-2
Severity: important
Tags: patch, ftbfs
User: [email protected]
Usertags: hurd-amd64
X-Debbugs-Cc: [email protected]

pgstat fails to build from source on hurd-amd64 because pgstat.c uses
getopt() and optind without including the POSIX header that declares them.

The relevant compiler errors are:

  pgstat.c:601:15: error: implicit declaration of function ‘getopt’
  pgstat.c:776:7: error: ‘optind’ undeclared

pgstat.c only includes <sys/ioctl.h> before the PostgreSQL frontend
headers. On GNU/Hurd the POSIX getopt/optind declarations are not
transitively pulled in, so they are undeclared.

Upstream has already fixed this by including <unistd.h>:

https://github.com/gleu/pgstats/commit/4cab84a976865614aa3d14306f97398f40289f38

Please cherry-pick the pgstat.c part of that upstream commit. The minimal
backport is included below.

I verified the backport on native GNU/Hurd amd64 running Debian sid:
dpkg-buildpackage exited 0, autopkgtest exited 0, and its pgstat test
passed.

Toolchain stamp:
- gnumach 1.8+git20260224-up-amd64
- hurd 1:0.9.git20260527-3+b1
- libc0.3 2.42-17
- binutils 2.46.90.20260712-1
- gcc 4:15.2.0-5+b1

--- pgstat-unistd.patch ---
Description: Include <unistd.h> for getopt on GNU/Hurd
Origin: upstream,
https://github.com/gleu/pgstats/commit/4cab84a976865614aa3d14306f97398f40289f38
Applied-Upstream: commit:4cab84a976865614aa3d14306f97398f40289f38
Last-Update: 2026-07-26

--- a/pgstat.c
+++ b/pgstat.c
@@ -14,6 +14,7 @@
  * System headers
  */
 #include <sys/ioctl.h>
+#include <unistd.h>


 /*

Assisted-by: hurd-collab agent (automated portability triage/fix)
Signed-off-by: Federico Bonino <[email protected]>

Reply via email to