Skip to contentSkip to conversation

tools/nolibc: Fix build of stdio.h due to header ordering

PATCH In review Mark Brown 2 participants 2 messages May 8, 2023

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 1/1 tools/nolibc: Fix build of stdio.h due to header ordering

When we added fd based file streams we created references to STx_FILENO in stdio.h but these constants are declared in unistd.h which is the last file included by the top level nolibc.h meaning those constants are not defined when we try to build stdio.h. This causes programs using nolibc.h to fail to build.

Reorder the headers to avoid this issue.

Fixes d449546c957f ("tools/nolibc: implement fd-based FILE streams")

---
Changes in v2:
- Rebase onto v6.4-rc1.
- This is now a fix for Linus' tree.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tools/include/nolibc/nolibc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/nolibc.h +1 -1
index 04739a6293c4..05a228a6ee78 100644
@@ -99,11 +99,11 @@
 #include "sys.h"
 #include "ctype.h"
 #include "signal.h"
+#include "unistd.h"
 #include "stdio.h"
 #include "stdlib.h"
 #include "string.h"
 #include "time.h"
-#include "unistd.h"
 #include "stackprotector.h"
 
 /* Used by programs to avoid std includes */

---
base-commit: ac9a78681b921877518763ba0e89202254349d1b
change-id: 20230413-nolibc-stdio-fix-fb42de39d099

Best regards,

Signature · 1 line
Mark Brown,,, <[email protected]>
maintainer
#1 lore raw
Quoted 6 lines · Mark Brown

When we added fd based file streams we created references to STx_FILENO in stdio.h but these constants are declared in unistd.h which is the last file included by the top level nolibc.h meaning those constants are not defined when we try to build stdio.h. This causes programs using nolibc.h to fail to build.

Quoted 6 lines

Reorder the headers to avoid this issue.

Fixes d449546c957f ("tools/nolibc: implement fd-based FILE streams")

---

Applied now to linux-kselftest fixes for 6.4-rc2

thanks,
-- Shuah