git: 62b958cb94ea - stable/13 - cross-build: Add comment missing from 9e5b0d9eac5b

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Tue, 25 Jan 2022 01:40:13 UTC
The branch stable/13 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=62b958cb94ea6e8b5549d902ffb95cb8bdeda262

commit 62b958cb94ea6e8b5549d902ffb95cb8bdeda262
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2021-12-15 19:45:31 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-01-24 23:59:44 +0000

    cross-build: Add comment missing from 9e5b0d9eac5b
    
    Whilst the commit message documented some of the details, I had intended
    to include this comment in the actual header, but failed to amend the
    commit properly.
    
    Fixes:          9e5b0d9eac5b ("cross-build: Fix bmake bootstrap with glibc 2.34")
    MFC after:      1 week
    
    (cherry picked from commit aee99ab4fe38bdc1dd1be88755d99ff4ee78ec09)
---
 tools/build/cross-build/include/linux/sys/wait.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/build/cross-build/include/linux/sys/wait.h b/tools/build/cross-build/include/linux/sys/wait.h
index 2721218a83d4..ca17bfae9b8a 100644
--- a/tools/build/cross-build/include/linux/sys/wait.h
+++ b/tools/build/cross-build/include/linux/sys/wait.h
@@ -27,5 +27,21 @@
 
 #pragma once
 
+/*
+ * glibc's sys/wait.h and stdlib.h both define various wait-related constants,
+ * depending on __USE_XOPEN(2K8) and if the other header has been included.
+ * Since they each probe the other's include guard to determine that, there is
+ * a window between a header defining its include guard and checking for the
+ * other's within which, if the other is included for the first time, they both
+ * believe the other has already defined the relevant macros etc, and so
+ * neither ends up doing so. This was not previously hit, and is still not hit
+ * when using glibc normally (though seems extremely fragile). However, as of
+ * glibc 2.34, signal.h, included by sys/wait, includes a new bits/sigstksz,
+ * which in turn includes unistd.h (when _SC_SIGSTKSZ_SOURCE is defined, which
+ * is implied by _GNU_SOURCE), which we wrap and include stdlib.h from,
+ * creating the exact aforementioned situation that breaks. Thus, forcefully
+ * include stdlib.h first whenever sys/wait.h is as a workaround, since that
+ * way round still works.
+ */
 #include <stdlib.h>
 #include_next <sys/wait.h>