Skip to content

Commit 1c49668

Browse files
committed
libast build: fix circular dependency (re: 54a3e1c)
The generated depenency rules file for libast, arch/*/lib/mam/ast, currently shows a circular dependency: ast_std.h → regex.h → ast_wchar.h → stdio.h → ast_stdio.h → ast_std.h. As a result, ast_stdio.h is not correctly depending on ast_std.h. The mkdeps script indicates this with a comment under ast_stdio.h: note * FIXME: circular dependency: ast_std.h We have to break this depenency loop somewhere. The best place to break it is in ast_wchar.h, which is generated from features/wchar. It has a '#include <stdio.h>', loading Sfio's stdio compatibility interface as a hack to avoid the system's native wchar.h (on Linux in particular) from pulling in native system stdio.h stuff. We don't really need the dependency resolution for that #include. src/cmd/INIT/mkdeps.sh: - Add a feature to exclude individual #include directives from dependency resolution: when grepping for #include directives in the preinstalled AST headers, skip any line containing NODEP. src/lib/libast/features/wchar: - Add /* NODEP */ to the offending '#include <stdio.h>'.
1 parent 103f72e commit 1c49668

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cmd/INIT/mkdeps.sh

100755100644
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
########################################################################
22
# #
33
# This file is part of the ksh 93u+m package #
4-
# Copyright (c) 2024 Contributors to ksh 93u+m #
4+
# Copyright (c) 2024-2026 Contributors to ksh 93u+m #
55
# and is licensed under the #
66
# Eclipse Public License, Version 2.0 #
77
# #
@@ -20,6 +20,9 @@
2020
# dependency rules for a library. The 'bind' command in mamake(1) Mamfiles will
2121
# automatically include the generated dependencies in its current rule context.
2222
#
23+
# To exclude a #include from dependency resolution, add a comment with 'NODEP'.
24+
# This is (rarely) needed in cases of a circular dependency or optional header.
25+
#
2326
# Usage: mkdeps -lLIBRARYNAME [ -lDEPENDNECYNAME ... ] [ HEADER.h ... ]
2427
# The first -l option's argument is the short name of the library to be processed.
2528
# The second and further -l options indicate its library header dependencies.
@@ -56,7 +59,7 @@ error_out()
5659
grep_includes()
5760
{
5861
spc=' ' # space followed by tab
59-
sed -n "s|^[$spc]*#[$spc]*include[$spc]*<\([A-Za-z0-9_]*\)\.h>.*|\1|p" "$1"
62+
sed -n "/NODEP/!s|^[$spc]*#[$spc]*include[$spc]*<\([A-Za-z0-9_]*\)\.h>.*|\1|p" "$1"
6063
}
6164

6265
print_indent()

src/lib/libast/features/wchar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ run{
2020
cat <<!
2121
#ifndef _SFSTDIO_H
2222
#include <ast_common.h>
23-
#include <stdio.h>
23+
#include <stdio.h> /* NODEP */
2424
#endif
2525
!
2626
case ${_hdr_wchar},${_nxt_wchar} in

0 commit comments

Comments
 (0)