kconfig: let 'shell' return enough output for deep path names
PATCH 1/1 kconfig: let 'shell' return enough output for deep path names
The 'shell' built-in only returns the first 256 bytes of the command's output. In some cases, 'shell' is used to return a path; by bumping up the buffer size to 4096 this lets us capture up to PATH_MAX.
The specific case where I ran into this was due to commit 1e860048c53e ("gcc-plugins: simplify GCC plugin-dev capability test"). After this change, we now use $(shell,$(CC) -print-file-name=plugin) to return a path; if the gcc path is particularly long, then the path ends up truncated at the 256 byte mark, which makes the HAVE_GCC_PLUGINS depends test always fail.
--- scripts/kconfig/preprocess.c | 2 +- scripts/kconfig/tests/preprocess/builtin_func/Kconfig | 3 +++ scripts/kconfig/tests/preprocess/builtin_func/expected_stdout | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
scripts/kconfig/preprocess.c +1 -1
@@ -141,7 +141,7 @@ static char *do_lineno(int argc, char *argv[])static char *do_shell (int argc,char *argv[]) {FILE *p; -char buf[256 ]; +char buf[4096 ];char *cmd;size_t nread;int i;
scripts/kconfig/tests/preprocess/builtin_func/Kconfig +3 -0
@@ -25,3 +25,6 @@ $(warning,$(shell,printf 'hello\nworld\n\n4\n\n\n')) # 'lineno' to the line number. $(warning,filename=$(filename)) $(warning,lineno=$(lineno)) + +# 'shell' can return more than 256 bytes of output +$(info,$(shell,printf 'hello%01024dworld\n' '0'))
scripts/kconfig/tests/preprocess/builtin_func/expected_stdout +1 -0
@@ -1 +1,2 @@ hello world 0 +hello0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000world
Signature · 1 line
2.20.1
Quoted 5 lines · Brenda Streiff
The 'shell' built-in only returns the first 256 bytes of the command's output. In some cases, 'shell' is used to return a path; by bumping up the buffer size to 4096 this lets us capture up to
PATH_MAX.
Quoted 8 lines
The specific case where I ran into this was due to commit
1e860048c53e("gcc-plugins: simplify GCC plugin-dev capability test"). After this change, we now use$(shell,$(CC) -print-file-name=plugin)to return a path; if the gcc path is particularly long, then the path ends up truncated at the 256 byte mark, which makes theHAVE_GCC_PLUGINSdepends test always fail.Signed-off-by Brenda Streiff <[email protected]>
Thanks, applied to linux-kbuild,
(but I dropped the change to tests)
Quoted 40 lines
--- scripts/kconfig/preprocess.c | 2 +- scripts/kconfig/tests/preprocess/builtin_func/Kconfig | 3 +++ scripts/kconfig/tests/preprocess/builtin_func/expected_stdout | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)scripts/kconfig/preprocess.c +1
-1@@ -141,7 +141,7 @@ static char *do_lineno(int argc, char *argv[])static char *do_shell (int argc,char *argv[]) {FILE *p; -char buf[256 ]; +char buf[4096 ];char *cmd;size_t nread;int i;scripts/kconfig/tests/preprocess/builtin_func/Kconfig +3
-0@@ -25,3 +25,6 @@ $(warning,$(shell,printf 'hello\nworld\n\n4\n\n\n')) # 'lineno' to the line number. $(warning,filename=$(filename)) $(warning,lineno=$(lineno)) + +# 'shell' can return more than 256 bytes of output +$(info,$(shell,printf 'hello%01024dworld\n' '0'))scripts/kconfig/tests/preprocess/builtin_func/expected_stdout +1
-1@@ -1 +1,2 @@ hello world 0 +hello0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000world --2.20.1
Signature · 2 lines
Best Regards Masahiro Yamada