Skip to contentSkip to conversation

kconfig: change .config format to use =n instead of "is not set"

PATCH In review Masahiro Yamada 3 participants 7 messages Feb 26, 2022 – Mar 5, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: change .config format to use =n instead of "is not set"

The .config file uses "# CONFIG_FOO is not set" form to represent disabled options. In the old days, it was useful because the .config was directly included from Makefiles. For example, you can use "ifdef CONFIG_FOO" in Makefiles to check if the option is enabled.

Commit c955ccafc38e ("kconfig: fix .config dependencies") introduced include/config/auto.conf, which mirrors the .config, but trims down all disabled options.

Since then, include/config/auto.conf defines CONFIG options during the build. The .config is used just for storing the user's configuration. I do not see a strong reason to use a particular pattern of comment for disabled options.

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input. You do not need to update arch/*/configs/*_defconfig files for now. "git bisect" should be able to cross the commit in both ways without any issue.

A problem may occur if you parse the .config for the "# ... is not set" patterns.

I adjusted streamline_config.pl, merge_config.sh, scripts/kconfig/tests/.

---

 scripts/kconfig/confdata.c                    | 15 +++++----------
 scripts/kconfig/merge_config.sh               | 19 +++++++++++--------
 scripts/kconfig/streamline_config.pl          |  2 +-
 .../tests/choice/alldef_expected_config       |  6 +++---
 .../tests/choice/allmod_expected_config       |  4 ++--
 .../tests/choice/allno_expected_config        |  6 +++---
 .../tests/choice/allyes_expected_config       |  8 ++++----
 scripts/kconfig/tests/choice/oldask1_config   |  2 +-
 .../tests/inter_choice/expected_config        |  2 +-
 .../kconfig/tests/new_choice_with_dep/config  |  2 +-
 .../tests/no_write_if_dep_unmet/__init__.py   |  7 +++----
 .../no_write_if_dep_unmet/expected_config     |  2 +-
 12 files changed, 36 insertions(+), 39 deletions(-)
scripts/kconfig/confdata.c +5 -10
index c4340c90e172..00f93c03aa57 100644
@@ -658,9 +658,7 @@ static char *escape_string_value(const char *in)
 	return out;
 }
 
-enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
-
-static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
+static void __print_symbol(FILE *fp, struct symbol *sym, bool output_n,
 			   bool escape_string)
 {
 	const char *val;
@@ -672,11 +670,8 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 	val = sym_get_string_value(sym);
 
 	if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) &&
-	    output_n != OUTPUT_N && *val == 'n') {
-		if (output_n == OUTPUT_N_AS_UNSET)
-			fprintf(fp, "# %s%s is not set\n", CONFIG_, sym->name);
+	    !output_n && *val == 'n')
 		return;
-	}
 
 	if (sym->type == S_STRING && escape_string) {
 		escaped = escape_string_value(val);
@@ -690,17 +685,17 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 
 static void print_symbol_for_dotconfig(FILE *fp, struct symbol *sym)
 {
-	__print_symbol(fp, sym, OUTPUT_N_AS_UNSET, true);
+	__print_symbol(fp, sym, true, true);
 }
 
 static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
 {
-	__print_symbol(fp, sym, OUTPUT_N_NONE, false);
+	__print_symbol(fp, sym, false, false);
 }
 
 void print_symbol_for_listconfig(struct symbol *sym)
 {
-	__print_symbol(stdout, sym, OUTPUT_N, true);
+	print_symbol_for_dotconfig(stdout, sym);
 }
 
 static void print_symbol_for_c(FILE *fp, struct symbol *sym)
scripts/kconfig/merge_config.sh +11 -8
index e5b46980c22a..aac60de3b7c7 100755
@@ -110,8 +110,11 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
-SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
+SED_CONFIG_EXP="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
+
+# Disabled options were previously written as "# CONFIG_... is not set", but
+# now is "CONFIG_...=n". Convert the format before the merge steps.
+SED_CONVERT_NOT_SET="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1=n/"
 
 TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
 MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
@@ -120,7 +123,7 @@ echo "Using $INITFILE as base"
 
 trap clean_up EXIT
 
-cat $INITFILE > $TMP_FILE
+sed "$SED_CONVERT_NOT_SET" $INITFILE > $TMP_FILE
 
 # Merge files, printing warnings on overridden values
 for ORIG_MERGE_FILE in $MERGE_LIST ; do
@@ -129,8 +132,8 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
 		echo "The merge file '$ORIG_MERGE_FILE' does not exist.  Exit." >&2
 		exit 1
 	fi
-	cat $ORIG_MERGE_FILE > $MERGE_FILE
-	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
+	sed "$SED_CONVERT_NOT_SET" $ORIG_MERGE_FILE > $MERGE_FILE
+	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP" $MERGE_FILE)
 
 	for CFG in $CFG_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
@@ -155,9 +158,9 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
 			echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE:
 		fi
 		if [ "$BUILTIN_FLAG" = "false" ]; then
-			sed -i "/$CFG[ =]/d" $TMP_FILE
+			sed -i "/$CFG=/d" $TMP_FILE
 		else
-			sed -i "/$CFG[ =]/d" $MERGE_FILE
+			sed -i "/$CFG=/d" $MERGE_FILE
 		fi
 	done
 	cat $MERGE_FILE >> $TMP_FILE
@@ -191,7 +194,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
 
 
 # Check all specified config values took (might have missed-dependency issues)
-for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
+for CFG in $(sed -n -e "$SED_CONFIG_EXP" $TMP_FILE); do
 
 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG" || true)
scripts/kconfig/streamline_config.pl +1 -1
index 3387ad7508f7..0f20142764f2 100755
@@ -617,7 +617,7 @@ foreach my $line (@config_file) {
     $_ = $line;
 
     if (/CONFIG_IKCONFIG/) {
-	if (/# CONFIG_IKCONFIG is not set/) {
+	if (/# CONFIG_IKCONFIG is not set/ || /CONFIG_IKCONFIG=n/) {
 	    # enable IKCONFIG at least as a module
 	    print "CONFIG_IKCONFIG=m\n";
 	    # don't ask about PROC
scripts/kconfig/tests/choice/alldef_expected_config +3 -3
index 7a754bf4be94..75d98d488488 100644
@@ -1,5 +1,5 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
-# CONFIG_TRI_CHOICE1 is not set
+CONFIG_TRI_CHOICE0=n
+CONFIG_TRI_CHOICE1=n
scripts/kconfig/tests/choice/allmod_expected_config +2 -2
index f1f5dcdb7923..ed8ffcb18a3a 100644
@@ -1,7 +1,7 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_OPT_BOOL_CHOICE0 is not set
+CONFIG_OPT_BOOL_CHOICE0=n
 CONFIG_OPT_BOOL_CHOICE1=y
 CONFIG_TRI_CHOICE0=m
 CONFIG_TRI_CHOICE1=m
scripts/kconfig/tests/choice/allno_expected_config +3 -3
index b88ee7a43136..37b2749277dd 100644
@@ -1,5 +1,5 @@
-# CONFIG_MODULES is not set
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_MODULES=n
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
+CONFIG_TRI_CHOICE0=n
 CONFIG_TRI_CHOICE1=y
scripts/kconfig/tests/choice/allyes_expected_config +4 -4
index e5a062a1157c..a2b36c017ffb 100644
@@ -1,9 +1,9 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_OPT_BOOL_CHOICE0 is not set
+CONFIG_OPT_BOOL_CHOICE0=n
 CONFIG_OPT_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
+CONFIG_TRI_CHOICE0=n
 CONFIG_TRI_CHOICE1=y
-# CONFIG_OPT_TRI_CHOICE0 is not set
+CONFIG_OPT_TRI_CHOICE0=n
 CONFIG_OPT_TRI_CHOICE1=y
scripts/kconfig/tests/choice/oldask1_config +1 -1
index b67bfe3c641f..f0a4e5e9f2c1 100644
@@ -1,2 +1,2 @@
-# CONFIG_MODULES is not set
+CONFIG_MODULES=n
 CONFIG_OPT_BOOL_CHOICE0=y
scripts/kconfig/tests/inter_choice/expected_config +1 -1
index 5dceefb054e3..4cf72e16f300 100644
@@ -1,4 +1,4 @@
 CONFIG_MODULES=y
 CONFIG_CHOICE_VAL0=y
-# CONFIG_CHOIVE_VAL1 is not set
+CONFIG_CHOIVE_VAL1=n
 CONFIG_DUMMY=y
scripts/kconfig/tests/new_choice_with_dep/config +1 -1
index 47ef95d567fd..47599c856033 100644
@@ -1,3 +1,3 @@
 CONFIG_CHOICE_B=y
-# CONFIG_CHOICE_D is not set
+CONFIG_CHOICE_D=n
 CONFIG_CHOICE_E=y
scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py +3 -4
index ffd469d1f226..9ba7542d47d5 100644
@@ -2,14 +2,13 @@
 """
 Do not write choice values to .config if the dependency is unmet.
 
-"# CONFIG_... is not set" should not be written into the .config file
-for symbols with unmet dependency.
+=n should not be written into the .config file for symbols with unmet
+dependency.
 
 This was not working correctly for choice values because choice needs
 a bit different symbol computation.
 
-This checks that no unneeded "# COFIG_... is not set" is contained in
-the .config file.
+This checks that no unneeded =n is contained in the .config file.
 
 Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59
 """
scripts/kconfig/tests/no_write_if_dep_unmet/expected_config +1 -1
index 473228810c35..9d057fad723c 100644
@@ -2,4 +2,4 @@
 # Automatically generated file; DO NOT EDIT.
 # Main menu
 #
-# CONFIG_A is not set
+CONFIG_A=n
Signature · 1 line
2.32.0
#1 lore raw
Quoted 15 lines · Masahiro Yamada

The .config file uses "# CONFIG_FOO is not set" form to represent disabled options. In the old days, it was useful because the .config was directly included from Makefiles. For example, you can use "ifdef CONFIG_FOO" in Makefiles to check if the option is enabled.

Commit c955ccafc38e ("kconfig: fix .config dependencies") introduced include/config/auto.conf, which mirrors the .config, but trims down all disabled options.

Since then, include/config/auto.conf defines CONFIG options during the build. The .config is used just for storing the user's configuration. I do not see a strong reason to use a particular pattern of comment for disabled options.

Quoted 8 lines

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input. You do not need to update arch/*/configs/*_defconfig files for now. "git bisect" should be able to cross the commit in both ways without any issue.

Good.

Lot of people use/used the notation CONFIG_FOO=n, so did I.

Thanks for keeping the "compatibility" with old usage "# CONFIG_FOO is not set".

Normally, I use git diff (or scripts/diffconfig in Git tree) to compare two kernel-configs, so seeing

-CONFIG_FOO=y
+CONFIG_FOO=n

...might be at first view unfamiliar/unusual.
With the old notation it was easier to see that Kconfig is unset.

Is this patch on top of kbuild-next Git?

( Untested )

- Sedat -

Quoted 263 lines

A problem may occur if you parse the .config for the "# ... is not set" patterns.

I adjusted streamline_config.pl, merge_config.sh, scripts/kconfig/tests/.

---

 scripts/kconfig/confdata.c                    | 15 +++++----------
 scripts/kconfig/merge_config.sh               | 19 +++++++++++--------
 scripts/kconfig/streamline_config.pl          |  2 +-
 .../tests/choice/alldef_expected_config       |  6 +++---
 .../tests/choice/allmod_expected_config       |  4 ++--
 .../tests/choice/allno_expected_config        |  6 +++---
 .../tests/choice/allyes_expected_config       |  8 ++++----
 scripts/kconfig/tests/choice/oldask1_config   |  2 +-
 .../tests/inter_choice/expected_config        |  2 +-
 .../kconfig/tests/new_choice_with_dep/config  |  2 +-
 .../tests/no_write_if_dep_unmet/__init__.py   |  7 +++----
 .../no_write_if_dep_unmet/expected_config     |  2 +-
 12 files changed, 36 insertions(+), 39 deletions(-)
scripts/kconfig/confdata.c +5 -10
index c4340c90e172..00f93c03aa57 100644
@@ -658,9 +658,7 @@ static char *escape_string_value(const char *in)
        return out;
 }
 
-enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };
-
-static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
+static void __print_symbol(FILE *fp, struct symbol *sym, bool output_n,
                           bool escape_string)
 {
        const char *val;
@@ -672,11 +670,8 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
        val = sym_get_string_value(sym);
 
        if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) &&
-           output_n != OUTPUT_N && *val == 'n') {
-               if (output_n == OUTPUT_N_AS_UNSET)
-                       fprintf(fp, "# %s%s is not set\n", CONFIG_, sym->name);
+           !output_n && *val == 'n')
                return;
-       }
 
        if (sym->type == S_STRING && escape_string) {
                escaped = escape_string_value(val);
@@ -690,17 +685,17 @@ static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
 
 static void print_symbol_for_dotconfig(FILE *fp, struct symbol *sym)
 {
-       __print_symbol(fp, sym, OUTPUT_N_AS_UNSET, true);
+       __print_symbol(fp, sym, true, true);
 }
 
 static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
 {
-       __print_symbol(fp, sym, OUTPUT_N_NONE, false);
+       __print_symbol(fp, sym, false, false);
 }
 
 void print_symbol_for_listconfig(struct symbol *sym)
 {
-       __print_symbol(stdout, sym, OUTPUT_N, true);
+       print_symbol_for_dotconfig(stdout, sym);
 }
 
 static void print_symbol_for_c(FILE *fp, struct symbol *sym)
scripts/kconfig/merge_config.sh +11 -8
index e5b46980c22a..aac60de3b7c7 100755
@@ -110,8 +110,11 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
-SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
+SED_CONFIG_EXP="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
+
+# Disabled options were previously written as "# CONFIG_... is not set", but
+# now is "CONFIG_...=n". Convert the format before the merge steps.
+SED_CONVERT_NOT_SET="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1=n/"
 
 TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
 MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX)
@@ -120,7 +123,7 @@ echo "Using $INITFILE as base"
 
 trap clean_up EXIT
 
-cat $INITFILE > $TMP_FILE
+sed "$SED_CONVERT_NOT_SET" $INITFILE > $TMP_FILE
 
 # Merge files, printing warnings on overridden values
 for ORIG_MERGE_FILE in $MERGE_LIST ; do
@@ -129,8 +132,8 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
                echo "The merge file '$ORIG_MERGE_FILE' does not exist.  Exit." >&2
                exit 1
        fi
-       cat $ORIG_MERGE_FILE > $MERGE_FILE
-       CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
+       sed "$SED_CONVERT_NOT_SET" $ORIG_MERGE_FILE > $MERGE_FILE
+       CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP" $MERGE_FILE)
 
        for CFG in $CFG_LIST ; do
                grep -q -w $CFG $TMP_FILE || continue
@@ -155,9 +158,9 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
                        echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE:
                fi
                if [ "$BUILTIN_FLAG" = "false" ]; then
-                       sed -i "/$CFG[ =]/d" $TMP_FILE
+                       sed -i "/$CFG=/d" $TMP_FILE
                else
-                       sed -i "/$CFG[ =]/d" $MERGE_FILE
+                       sed -i "/$CFG=/d" $MERGE_FILE
                fi
        done
        cat $MERGE_FILE >> $TMP_FILE
@@ -191,7 +194,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
 
 
 # Check all specified config values took (might have missed-dependency issues)
-for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
+for CFG in $(sed -n -e "$SED_CONFIG_EXP" $TMP_FILE); do
 
        REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
        ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG" || true)
scripts/kconfig/streamline_config.pl +1 -1
index 3387ad7508f7..0f20142764f2 100755
@@ -617,7 +617,7 @@ foreach my $line (@config_file) {
     $_ = $line;
 
     if (/CONFIG_IKCONFIG/) {
-       if (/# CONFIG_IKCONFIG is not set/) {
+       if (/# CONFIG_IKCONFIG is not set/ || /CONFIG_IKCONFIG=n/) {
            # enable IKCONFIG at least as a module
            print "CONFIG_IKCONFIG=m\n";
            # don't ask about PROC
scripts/kconfig/tests/choice/alldef_expected_config +3 -3
index 7a754bf4be94..75d98d488488 100644
@@ -1,5 +1,5 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
-# CONFIG_TRI_CHOICE1 is not set
+CONFIG_TRI_CHOICE0=n
+CONFIG_TRI_CHOICE1=n
scripts/kconfig/tests/choice/allmod_expected_config +2 -2
index f1f5dcdb7923..ed8ffcb18a3a 100644
@@ -1,7 +1,7 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_OPT_BOOL_CHOICE0 is not set
+CONFIG_OPT_BOOL_CHOICE0=n
 CONFIG_OPT_BOOL_CHOICE1=y
 CONFIG_TRI_CHOICE0=m
 CONFIG_TRI_CHOICE1=m
scripts/kconfig/tests/choice/allno_expected_config +3 -3
index b88ee7a43136..37b2749277dd 100644
@@ -1,5 +1,5 @@
-# CONFIG_MODULES is not set
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_MODULES=n
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
+CONFIG_TRI_CHOICE0=n
 CONFIG_TRI_CHOICE1=y
scripts/kconfig/tests/choice/allyes_expected_config +4 -4
index e5a062a1157c..a2b36c017ffb 100644
@@ -1,9 +1,9 @@
 CONFIG_MODULES=y
-# CONFIG_BOOL_CHOICE0 is not set
+CONFIG_BOOL_CHOICE0=n
 CONFIG_BOOL_CHOICE1=y
-# CONFIG_OPT_BOOL_CHOICE0 is not set
+CONFIG_OPT_BOOL_CHOICE0=n
 CONFIG_OPT_BOOL_CHOICE1=y
-# CONFIG_TRI_CHOICE0 is not set
+CONFIG_TRI_CHOICE0=n
 CONFIG_TRI_CHOICE1=y
-# CONFIG_OPT_TRI_CHOICE0 is not set
+CONFIG_OPT_TRI_CHOICE0=n
 CONFIG_OPT_TRI_CHOICE1=y
scripts/kconfig/tests/choice/oldask1_config +1 -1
index b67bfe3c641f..f0a4e5e9f2c1 100644
@@ -1,2 +1,2 @@
-# CONFIG_MODULES is not set
+CONFIG_MODULES=n
 CONFIG_OPT_BOOL_CHOICE0=y
scripts/kconfig/tests/inter_choice/expected_config +1 -1
index 5dceefb054e3..4cf72e16f300 100644
@@ -1,4 +1,4 @@
 CONFIG_MODULES=y
 CONFIG_CHOICE_VAL0=y
-# CONFIG_CHOIVE_VAL1 is not set
+CONFIG_CHOIVE_VAL1=n
 CONFIG_DUMMY=y
scripts/kconfig/tests/new_choice_with_dep/config +1 -1
index 47ef95d567fd..47599c856033 100644
@@ -1,3 +1,3 @@
 CONFIG_CHOICE_B=y
-# CONFIG_CHOICE_D is not set
+CONFIG_CHOICE_D=n
 CONFIG_CHOICE_E=y
scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py +3 -4
index ffd469d1f226..9ba7542d47d5 100644
@@ -2,14 +2,13 @@
 """
 Do not write choice values to .config if the dependency is unmet.
 
-"# CONFIG_... is not set" should not be written into the .config file
-for symbols with unmet dependency.
+=n should not be written into the .config file for symbols with unmet
+dependency.
 
 This was not working correctly for choice values because choice needs
 a bit different symbol computation.
 
-This checks that no unneeded "# COFIG_... is not set" is contained in
-the .config file.
+This checks that no unneeded =n is contained in the .config file.
 
 Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59
 """
scripts/kconfig/tests/no_write_if_dep_unmet/expected_config +1 -2
index 473228810c35..9d057fad723c 100644
@@ -2,4 +2,4 @@
 # Automatically generated file; DO NOT EDIT.
 # Main menu
 #
-# CONFIG_A is not set
+CONFIG_A=n
--

2.32.0

#2 lore raw
Quoted 38 lines · Sedat Dilek
Quoted 15 lines · Masahiro Yamada

The .config file uses "# CONFIG_FOO is not set" form to represent disabled options. In the old days, it was useful because the .config was directly included from Makefiles. For example, you can use "ifdef CONFIG_FOO" in Makefiles to check if the option is enabled.

Commit c955ccafc38e ("kconfig: fix .config dependencies") introduced include/config/auto.conf, which mirrors the .config, but trims down all disabled options.

Since then, include/config/auto.conf defines CONFIG options during the build. The .config is used just for storing the user's configuration. I do not see a strong reason to use a particular pattern of comment for disabled options.

Quoted 8 lines

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input. You do not need to update arch/*/configs/*_defconfig files for now. "git bisect" should be able to cross the commit in both ways without any issue.

Good.

Lot of people use/used the notation CONFIG_FOO=n, so did I.

Thanks for keeping the "compatibility" with old usage "# CONFIG_FOO is not set".

Normally, I use git diff (or scripts/diffconfig in Git tree) to compare two kernel-configs, so seeing

(quoted diff) +1 -1
-CONFIG_FOO=y
+CONFIG_FOO=n
Quoted 2 lines

...might be at first view unfamiliar/unusual.
With the old notation it was easier to see that Kconfig is unset.

I agree on this point.

"is not set" stands out much better than "=n", and our eyes are accustomed to this notation for 20 years.

However, real comments do not stand out since
we already (ab)use comments for disabled options.

This is related thread
https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/

Quoted 3 lines

Is this patch on top of kbuild-next Git?

Yes.

#3 lore raw
Quoted 45 lines · Masahiro Yamada
Quoted 38 lines · Sedat Dilek
Quoted 15 lines · Masahiro Yamada

The .config file uses "# CONFIG_FOO is not set" form to represent disabled options. In the old days, it was useful because the .config was directly included from Makefiles. For example, you can use "ifdef CONFIG_FOO" in Makefiles to check if the option is enabled.

Commit c955ccafc38e ("kconfig: fix .config dependencies") introduced include/config/auto.conf, which mirrors the .config, but trims down all disabled options.

Since then, include/config/auto.conf defines CONFIG options during the build. The .config is used just for storing the user's configuration. I do not see a strong reason to use a particular pattern of comment for disabled options.

Quoted 8 lines

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input. You do not need to update arch/*/configs/*_defconfig files for now. "git bisect" should be able to cross the commit in both ways without any issue.

Good.

Lot of people use/used the notation CONFIG_FOO=n, so did I.

Thanks for keeping the "compatibility" with old usage "# CONFIG_FOO is not set".

Normally, I use git diff (or scripts/diffconfig in Git tree) to compare two kernel-configs, so seeing

(quoted diff) +1 -1
-CONFIG_FOO=y
+CONFIG_FOO=n
Quoted 2 lines

...might be at first view unfamiliar/unusual.
With the old notation it was easier to see that Kconfig is unset.

I agree on this point.

Quoted 9 lines

"is not set" stands out much better than "=n", and our eyes are accustomed to this notation for 20 years.

However, real comments do not stand out since
we already (ab)use comments for disabled options.

This is related thread
https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/

Thanks for the link.

Quoted 5 lines
Quoted 3 lines

Is this patch on top of kbuild-next Git?

Yes.

Let me see if I will try kbuild-next with this patch on top of upcoming Linux v5.17-rc6.

- Sedat -

#4 lore raw
Quoted 60 lines · Sedat Dilek
Quoted 45 lines · Masahiro Yamada
Quoted 38 lines · Sedat Dilek
Quoted 15 lines · Masahiro Yamada

The .config file uses "# CONFIG_FOO is not set" form to represent disabled options. In the old days, it was useful because the .config was directly included from Makefiles. For example, you can use "ifdef CONFIG_FOO" in Makefiles to check if the option is enabled.

Commit c955ccafc38e ("kconfig: fix .config dependencies") introduced include/config/auto.conf, which mirrors the .config, but trims down all disabled options.

Since then, include/config/auto.conf defines CONFIG options during the build. The .config is used just for storing the user's configuration. I do not see a strong reason to use a particular pattern of comment for disabled options.

Quoted 8 lines

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input. You do not need to update arch/*/configs/*_defconfig files for now. "git bisect" should be able to cross the commit in both ways without any issue.

Good.

Lot of people use/used the notation CONFIG_FOO=n, so did I.

Thanks for keeping the "compatibility" with old usage "# CONFIG_FOO is not set".

Normally, I use git diff (or scripts/diffconfig in Git tree) to compare two kernel-configs, so seeing

(quoted diff) +1 -1
-CONFIG_FOO=y
+CONFIG_FOO=n
Quoted 2 lines

...might be at first view unfamiliar/unusual.
With the old notation it was easier to see that Kconfig is unset.

I agree on this point.

Quoted 9 lines

"is not set" stands out much better than "=n", and our eyes are accustomed to this notation for 20 years.

However, real comments do not stand out since
we already (ab)use comments for disabled options.

This is related thread
https://patchwork.kernel.org/project/linux-kbuild/patch/[email protected]/

Thanks for the link.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Is this patch on top of kbuild-next Git?

Yes.

Let me see if I will try kbuild-next with this patch on top of upcoming Linux v5.17-rc6.

I was not able to apply your patch on top of latest kbuild-next.git:

$ git log --oneline v5.17-rc6..
3a8276b1ae7e (HEAD -> for-5.17/kbuild-next-2022022) Merge branch
'for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
into for-5.17/kbuild-next-2022022
d4c858643263 kallsyms: ignore all local labels prefixed by '.L'
a7d4f58e99dd kconfig: fix missing '# end of' for empty menu
868653f421cd kconfig: add fflush() before ferror() check
5c8166419acf kbuild: replace $(if A,A,B) with $(or A,B)
f67695c9962e kbuild: Add environment variables for userprogs flags
a5575df58004 kbuild: unify cmd_copy and cmd_shipped
$ LC_ALL=C git apply --check --verbose
../20220226_masahiroy_kconfig_change_config_format_to_use_n_instead_of_is_not_set.mbx
Checking patch scripts/kconfig/confdata.c...
error: while searching for:
       return out;
}

enum output_n { OUTPUT_N, OUTPUT_N_AS_UNSET, OUTPUT_N_NONE };

static void __print_symbol(FILE *fp, struct symbol *sym, enum output_n output_n,
bool escape_string)

{
       const char *val;

error: patch failed: scripts/kconfig/confdata.c:658
error: scripts/kconfig/confdata.c: patch does not apply
Checking patch scripts/kconfig/merge_config.sh...
Checking patch scripts/kconfig/streamline_config.pl...
Checking patch scripts/kconfig/tests/choice/alldef_expected_config... Checking patch scripts/kconfig/tests/choice/allmod_expected_config... Checking patch scripts/kconfig/tests/choice/allno_expected_config... Checking patch scripts/kconfig/tests/choice/allyes_expected_config... Checking patch scripts/kconfig/tests/choice/oldask1_config... Checking patch scripts/kconfig/tests/inter_choice/expected_config... Checking patch scripts/kconfig/tests/new_choice_with_dep/config... Checking patch scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py... Checking patch scripts/kconfig/tests/no_write_if_dep_unmet/expected_config...

$ git log --oneline v5.17-rc6.. scripts/kconfig/confdata.c
a7d4f58e99dd kconfig: fix missing '# end of' for empty menu
868653f421cd kconfig: add fflush() before ferror() check

- Sedat -

Reviewed-by on v1 1/1
#5 lore raw
In reply to Masahiro Yamada
Quoted 2 lines · Masahiro Yamada

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

While I agree with the overall direction, I was wondering how this relates to string and int/hex options. It appears that they either have a value or are not written to the .config at all, for example, if the option is disabled via the depends on attribute. At first I thought this would be inconsistent (i.e., =n for bool and omitted for string), but it appears a disabled bool option is also omitted. Hopefully the fact that sometimes a false bool option is =n and sometimes it's omitted won't surprise anyone.

#6 lore raw
Quoted 6 lines · Boris Kolpackov
Quoted 2 lines · Masahiro Yamada

With this commit, Kconfig will output disable options in a more natural form, "CONFIG_FOO=n".

Quoted 8 lines

While I agree with the overall direction, I was wondering how this relates to string and int/hex options. It appears that they either have a value or are not written to the .config at all, for example, if the option is disabled via the depends on attribute. At first I thought this would be inconsistent (i.e., =n for bool and omitted for string), but it appears a disabled bool option is also omitted. Hopefully the fact that sometimes a false bool option is =n and sometimes it's omitted won't surprise anyone.

Options with unmet 'depends on' are all omitted in the .config It is consistent for all types.

Quoted 2 lines

--
Best Regards
Masahiro Yamada