Skip to content

debugging Kconfig (and Kbuild) (via printf!)

Nathan Chancellor edited this page Jan 11, 2022 · 5 revisions

Kconfig

diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index a5fe72c504ff..b59db288da28 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
 
 # $(cc-option,<flag>)
 # Return y if the compiler supports <flag>, n otherwise
-cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o)
+cc-option = $(success,mkdir .tmp_$$$$; trap "rm -rf .tmp_$$$$" EXIT; $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_$$$$/tmp.o; echo $(CC) -Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null >> log.txt)
 
 # $(ld-option,<flag>)
 # Return y if the linker supports <flag>, n otherwise

Kbuild

v5.13 and newer:

diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
index 86ecd2ac874c..54374f416e52 100644
--- a/scripts/Makefile.compiler
+++ b/scripts/Makefile.compiler
@@ -23,7 +23,7 @@ try-run = $(shell set -e;             \
        TMP=$(TMPOUT)/tmp;              \
        mkdir -p $(TMPOUT);             \
        trap "rm -rf $(TMPOUT)" EXIT;   \
-       if ($(1)) >/dev/null 2>&1;      \
+       if ($(1)) >>/tmp/try-run.log 2>&1;      \
        then echo "$(2)";               \
        else echo "$(3)";               \
        fi)

v5.12 and earlier:

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0d6e11820791..4ba51ac61573 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -95,7 +95,7 @@ try-run = $(shell set -e;             \
        TMPO=$(TMPOUT)/tmp.o;           \
        mkdir -p $(TMPOUT);             \
        trap "rm -rf $(TMPOUT)" EXIT;   \
-       if ($(1)) >/dev/null 2>&1;      \
+       if ($(1)) >>/tmp/try-run.log 2>&1;      \
        then echo "$(2)";               \
        else echo "$(3)";               \
        fi)

Other tips

CLANG_FLAGS    += $(call cc-disable-warning,foo,)