Skip to contentSkip to conversation

scripts/kconfig/merge_config: don't redefine 'y' to 'm'

PATCH Superseded Anders Roxell 3 participants 6 messages Nov 2, 2018 – Nov 8, 2018

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/kconfig/merge_config: don't redefine 'y' to 'm'

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

---
 scripts/kconfig/merge_config.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +14 -1
index da66e7742282..902a60b45614 100755
@@ -32,6 +32,7 @@ usage() {
 	echo "  -m    only merge the fragments, do not execute the make command"
 	echo "  -n    use allnoconfig instead of alldefconfig"
 	echo "  -r    list redundant entries when merging fragments"
+	echo "  -y    make builtin have precedence over modules"
 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
 	echo
 	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +41,7 @@ usage() {
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
+BUILTIN=false
 OUTPUT=.
 CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
@@ -64,6 +66,11 @@ while true; do
 		shift
 		continue
 		;;
+	"-y")
+		BUILTIN=true
+		shift
+		continue
+		;;
 	"-O")
 		if [ -d $2 ];then
 			OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -122,7 +129,13 @@ for MERGE_FILE in $MERGE_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
 		PREV_VAL=$(grep -w $CFG $TMP_FILE)
 		NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-		if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+		if test "$BUILTIN" = "true" && echo $PREV_VAL |grep -Eq '^\w+=y' && echo $NEW_VAL |grep -Eq '^\w+=m' ; then
+			echo Value of $CFG is \'y\' and we don\'t want to redefine the fragment $MERGE_FILE:
+			echo Previous  value: $PREV_VAL
+			echo New value:       $NEW_VAL
+			echo Will use previous value.
+			echo
+		elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
 			echo Value of $CFG is redefined by fragment $MERGE_FILE:
 			echo Previous  value: $PREV_VAL
 			echo New value:       $NEW_VAL
Signature · 1 line
2.11.0
#1 lore raw

Hi Anders,

Quoted 10 lines · Anders Roxell

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

---

I think this patch makes sense.

Just in case, could you please provide me the context of the discussion?

Does the real problem exist in the kernel tree,
or for local fragment files?

Thanks.

Quoted 53 lines
 scripts/kconfig/merge_config.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +14 -2
index da66e7742282..902a60b45614 100755
@@ -32,6 +32,7 @@ usage() {
        echo "  -m    only merge the fragments, do not execute the make command"
        echo "  -n    use allnoconfig instead of alldefconfig"
        echo "  -r    list redundant entries when merging fragments"
+       echo "  -y    make builtin have precedence over modules"
        echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
        echo
        echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +41,7 @@ usage() {
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
+BUILTIN=false
 OUTPUT=.
 CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
@@ -64,6 +66,11 @@ while true; do
                shift
                continue
                ;;
+       "-y")
+               BUILTIN=true
+               shift
+               continue
+               ;;
        "-O")
                if [ -d $2 ];then
                        OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -122,7 +129,13 @@ for MERGE_FILE in $MERGE_LIST ; do
                grep -q -w $CFG $TMP_FILE || continue
                PREV_VAL=$(grep -w $CFG $TMP_FILE)
                NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-               if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+               if test "$BUILTIN" = "true" && echo $PREV_VAL |grep -Eq '^\w+=y' && echo $NEW_VAL |grep -Eq '^\w+=m' ; then
+                       echo Value of $CFG is \'y\' and we don\'t want to redefine the fragment $MERGE_FILE:
+                       echo Previous  value: $PREV_VAL
+                       echo New value:       $NEW_VAL
+                       echo Will use previous value.
+                       echo
+               elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
                        echo Value of $CFG is redefined by fragment $MERGE_FILE:
                        echo Previous  value: $PREV_VAL
                        echo New value:       $NEW_VAL
--

2.11.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 11 lines · Masahiro Yamada

Hi Anders,

Quoted 7 lines · Anders Roxell

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

Quoted 7 lines
Quoted 3 lines

---

I think this patch makes sense.

Just in case, could you please provide me the context of the discussion?

For instance we don't want to force X86 from DRM=y to DRM=m, when enabling selftest, that would surely break somebody's setup and you also don't want to force ARM64 from DRM=m to DRM=y, that seems unnecessary for a big subsystem like DRM.

Quoted 2 lines

Does the real problem exist in the kernel tree,

Not that I'm aware about.

Cheers,
Anders

Quoted 65 lines

or for local fragment files?

Thanks.

Quoted 51 lines
 scripts/kconfig/merge_config.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +14 -2
index da66e7742282..902a60b45614 100755
@@ -32,6 +32,7 @@ usage() {
        echo "  -m    only merge the fragments, do not execute the make command"
        echo "  -n    use allnoconfig instead of alldefconfig"
        echo "  -r    list redundant entries when merging fragments"
+       echo "  -y    make builtin have precedence over modules"
        echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
        echo
        echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +41,7 @@ usage() {
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
+BUILTIN=false
 OUTPUT=.
 CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
@@ -64,6 +66,11 @@ while true; do
                shift
                continue
                ;;
+       "-y")
+               BUILTIN=true
+               shift
+               continue
+               ;;
        "-O")
                if [ -d $2 ];then
                        OUTPUT=$(echo $2 | sed 's/\/*$//')
@@ -122,7 +129,13 @@ for MERGE_FILE in $MERGE_LIST ; do
                grep -q -w $CFG $TMP_FILE || continue
                PREV_VAL=$(grep -w $CFG $TMP_FILE)
                NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-               if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+               if test "$BUILTIN" = "true" && echo $PREV_VAL |grep -Eq '^\w+=y' && echo $NEW_VAL |grep -Eq '^\w+=m' ; then
+                       echo Value of $CFG is \'y\' and we don\'t want to redefine the fragment $MERGE_FILE:
+                       echo Previous  value: $PREV_VAL
+                       echo New value:       $NEW_VAL
+                       echo Will use previous value.
+                       echo
+               elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
                        echo Value of $CFG is redefined by fragment $MERGE_FILE:
                        echo Previous  value: $PREV_VAL
                        echo New value:       $NEW_VAL
--
Quoted 2 lines

2.11.0

--
Best Regards
Masahiro Yamada

#3 lore raw
Quoted 27 lines · Anders Roxell
Quoted 11 lines · Masahiro Yamada

Hi Anders,

Quoted 7 lines · Anders Roxell

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

Quoted 7 lines
Quoted 3 lines

---

I think this patch makes sense.

Just in case, could you please provide me the context of the discussion?

For instance we don't want to force X86 from DRM=y to DRM=m, when enabling selftest, that would surely break somebody's setup and you also don't want to force ARM64 from DRM=m to DRM=y, that seems unnecessary for a big subsystem like DRM.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Does the real problem exist in the kernel tree,

Not that I'm aware about.

Cheers,
Anders

Quoted 1 line

or for local fragment files?

This is really about ordering of fragment files and not "making a symbol 'less'", I think were Arnd's words.

So, doing something like:

$ make arm64-selftest.config drm.config

where arm64-selftest.config defines DRM=y and drm.config defines DRM=m, the result should be "DRM=y".

So the first step is to make merge_config.sh support it. A follow up step would be to integrate this into the kernel Makefile system if we determine this is the correct behavior, or to provide a parameter if we don't want to change the default behavior.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#4 lore raw
In reply to Anders Roxell
Quoted 8 lines · Anders Roxell

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

Thanks for the patch Anders!

Quoted 37 lines
---
 scripts/kconfig/merge_config.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +7 -0
index da66e7742282..902a60b45614 100755
@@ -32,6 +32,7 @@ usage() {
 	echo "  -m    only merge the fragments, do not execute the make command"
 	echo "  -n    use allnoconfig instead of alldefconfig"
 	echo "  -r    list redundant entries when merging fragments"
+	echo "  -y    make builtin have precedence over modules"
 	echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
 	echo
 	echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +41,7 @@ usage() {
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
+BUILTIN=false
 OUTPUT=.
 CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
@@ -64,6 +66,11 @@ while true; do
 		shift
 		continue
 		;;
+	"-y")
+		BUILTIN=true
+		shift
+		continue
+		;;
 	"-O")
 		if [ -d $2 ];then
 			OUTPUT=$(echo $2 | sed 's/\/*$//')

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 132

Quoted 5 lines
scripts/kconfig/merge_config.sh +1 -1
@@ -122,7 +129,13 @@ for MERGE_FILE in $MERGE_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
 		PREV_VAL=$(grep -w $CFG $TMP_FILE)
 		NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-		if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+		if test "$BUILTIN" = "true" && echo $PREV_VAL |grep -Eq '^\w+=y' && echo $NEW_VAL |grep -Eq '^\w+=m' ; then

I think we can avoid the rather lengthy/forky "echo | grep" mechanism with POSIX substring parameter expansion (should work in bash, dash, etc.).

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02

We can also be more consistent with the other tests in the script, consider:

		if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 133

Quoted 1 line
scripts/kconfig/merge_config.sh +1 -0
+			echo Value of $CFG is \'y\' and we don\'t want to redefine the fragment $MERGE_FILE:

I think we can drop the above and perhaps update the last line with...

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 136

Quoted 3 lines
scripts/kconfig/merge_config.sh +3 -0
+			echo Previous  value: $PREV_VAL
+			echo New value:       $NEW_VAL
+			echo Will use previous value.

echo "-y passed, will not demote y to m"

Or something along those lines.

Quoted 9 lines
scripts/kconfig/merge_config.sh +2 -0
+			echo
+		elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
 			echo Value of $CFG is redefined by fragment $MERGE_FILE:
 			echo Previous  value: $PREV_VAL
 			echo New value:       $NEW_VAL
Signature · 1 line
2.11.0
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#5 lore raw
Quoted 71 lines · Darren Hart
Quoted 8 lines · Anders Roxell

In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. Adding a switch to add precedence for builtin over modules, this will make the .config file the same

Thanks for the patch Anders!

Quoted 37 lines
---
 scripts/kconfig/merge_config.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +7 -0
index da66e7742282..902a60b45614 100755
@@ -32,6 +32,7 @@ usage() {
      echo "  -m    only merge the fragments, do not execute the make command"
      echo "  -n    use allnoconfig instead of alldefconfig"
      echo "  -r    list redundant entries when merging fragments"
+     echo "  -y    make builtin have precedence over modules"
      echo "  -O    dir to put generated output files.  Consider setting \$KCONFIG_CONFIG instead."
      echo
      echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
@@ -40,6 +41,7 @@ usage() {
 RUNMAKE=true
 ALLTARGET=alldefconfig
 WARNREDUN=false
+BUILTIN=false
 OUTPUT=.
 CONFIG_PREFIX=${CONFIG_-CONFIG_}
 
@@ -64,6 +66,11 @@ while true; do
              shift
              continue
              ;;
+     "-y")
+             BUILTIN=true
+             shift
+             continue
+             ;;
      "-O")
              if [ -d $2 ];then
                      OUTPUT=$(echo $2 | sed 's/\/*$//')

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 132

Quoted 5 lines
scripts/kconfig/merge_config.sh +1 -1
@@ -122,7 +129,13 @@ for MERGE_FILE in $MERGE_LIST ; do
              grep -q -w $CFG $TMP_FILE || continue
              PREV_VAL=$(grep -w $CFG $TMP_FILE)
              NEW_VAL=$(grep -w $CFG $MERGE_FILE)
-             if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+             if test "$BUILTIN" = "true" && echo $PREV_VAL |grep -Eq '^\w+=y' && echo $NEW_VAL |grep -Eq '^\w+=m' ; then

I think we can avoid the rather lengthy/forky "echo | grep" mechanism with POSIX substring parameter expansion (should work in bash, dash, etc.).

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02

We can also be more consistent with the other tests in the script, consider:

                if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 133

Quoted 1 line
scripts/kconfig/merge_config.sh +1 -0
+                     echo Value of $CFG is \'y\' and we don\'t want to redefine the fragment $MERGE_FILE:

I think we can drop the above and perhaps update the last line with...

Quoted 7 lines

scripts/kconfig/merge_config.sh for MERGE_FILE in $MERGE_LIST ; do · line 136

Quoted 3 lines
scripts/kconfig/merge_config.sh +3 -0
+                     echo Previous  value: $PREV_VAL
+                     echo New value:       $NEW_VAL
+                     echo Will use previous value.

echo "-y passed, will not demote y to m"

Or something along those lines.

Thank you for your input, I'll update and send a v2 shortly.

Cheers,
Anders

Quoted 14 lines
Quoted 10 lines
scripts/kconfig/merge_config.sh +2 -1
+                     echo
+             elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
                      echo Value of $CFG is redefined by fragment $MERGE_FILE:
                      echo Previous  value: $PREV_VAL
                      echo New value:       $NEW_VAL
--

2.11.0

--
Darren Hart
VMware Open Source Technology Center