Skip to contentSkip to conversation

linux-2.4.6-pre6: numerous dep_{bool,tristate} $CONFIG_ARCH_xxx bugs

DISCUSSION Adam J. Richter 4 participants 9 messages Jun 30, 2001

Subsystems (9)
Arm (32-bit) MIPS s390 SuperH +5 more subsystems
lore
Share & tools
lore
#0 lore raw
Quoted 9 lines
Quoted 1 line

= Keith Owens

= Alan Cox

Quoted 2 lines

I'd rather that we fixed dep_* so that undefined symbols were treated as 'n', just like the makefiles treat undefined symbols.

That isnt a simple change. dep_tristate is used both to express 'need this' and also 'conflicts with'. Those are ambiguous. You'd need to extend the syntax say by adding ${FOO:N} syntax

I do not understand what you (Alan) mean by the "'conflicts with'"
usage. I do not believe there is any way to directly use dep_* to express that a "y" answer to some feature requires "n" or even "m" for another feature.

Regarding Jeff Garzik's suggestion to just "Define CONFIG_ARCH_xxx
in various arches where needed", the problem primarily arises from CONFIG_ variables from other architectures, so you're talking about adding the same set of lines for every architecture, and they are changes that would have to be maintained. That wouldn't be the end of the world, but it would be another instance of people doing work that computers can do for them.

Implementing Keith's suggestion will still require changes to
the Config.in files, to put quotation marks around things like $CONFIG_SPARC64. Otherwise, the shell will treat the undefined variable is if it were not provided, as opposed to turning it into an emptry string argument. I could put together a patch to do this if there is a consensus that it is the preferred solution.

In the meantime, I have implemented the following small kludge
in scripts/Configure that extracts all variables from arch/*/config.in and sets them all to "n" before reading in their default values. I only processed the variables in arch/*/config.in so that I could assume that the list of variables is small and because defaulting the variables to "n" makes it slightly harder to detect bugs where Config.in scripts look at the values of variables that have not yet been set. Because some platforms use variables that do not being with CONFIG_ARCH (e.g., CONFIG_SPARC64, CONFIG_X86), I could not just filter for CONFIG_ARCH_*. I could mail Linus a shell script to clean this up too if that were desired (a patch would be far too messy). Anyhow, the change seems to work, although I have been bumping into a lot of other build errors with linux-2.4.6-pre6, partly as a result of gcc-3.0 pickiness, so I have yet to see the build complete. It is a kludge, but at least it's a solution. I'm not particularly enamored of any one approach in this case; I just want it resolved in a way that is unlikely to lead to recurrence.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America

fax +1 408 261-6631 "Free Software For The Rest Of Us."

scripts/Configure +13 -0
@@ -48,6 +48,9 @@
 #
 # 24 January 1999, Michael Elizabeth Chastain, <[email protected]>
 # - Improve the exit message (Jeff Ronne).
+#
+# 29 June 2001, Adam J. Richter, <[email protected]>
+# - Default all CONFIG_ARCH_* and CONFIG_X86 to "n"
 
 #
 # Make sure we're really running bash.
@@ -531,6 +534,16 @@
 echo " * Automatically generated C config: don't edit" >> $CONFIG_H
 echo " */" >> $CONFIG_H
 echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
+
+# Ensure all unselected architectures are set to "n" rather than being
+# undefined, so that dep_bool and dep_tristate properly detect their absense.
+# Really, CONFIG_X86 should be CONFIG_ARCH_X86.
+set +f
+for arch in CONFIG_X86 $(cat arch/*/config.in | tr '   $"' '\n\n\n' |
+              egrep ^CONFIG_ARCH_ | sort -u) ; do
+	define_bool "$arch" "n"
+done
+set -f
 
 DEFAULT=""
 if [ "$1" = "-d" ] ; then
#1 lore raw
Quoted 4 lines

I do not understand what you (Alan) mean by the "'conflicts with'"
usage. I do not believe there is any way to directly use dep_* to express that a "y" answer to some feature requires "n" or even "m" for another feature.

Uses for dep_tristate

#1

dep_tristate $FOO $BAR

to say 'FOO requires BAR and must be a similar setting'

#2
dep_tristate $FOO $BAR

to say 'FOO requires BAR and must be a similar setting _IF_CONFIGURED_'

Think about Plug and Play

A driver needs to be modular if PnP is modular, but with a non PnP kernel can be Yes even if PNP is off.

Alan

#2 lore raw
In reply to Adam J. Richter
Quoted 4 lines · Alan Cox

#2
dep_tristate $FOO $BAR

to say 'FOO requires BAR and must be a similar setting _IF_CONFIGURED_'

Err, how can $BAR be undefined? Configure sets all config variables which are answered with 'n' to 'n'.

Therefore, if you do:

bool 'PNP?' PNP

dep_tristate 'FOO?' FOO $PNP

and you answer 'n' to PNP, then FOO will be 'n'.

Can you extract an example where #2 is actually used?

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

#3 lore raw
Quoted 2 lines

Err, how can $BAR be undefined? Configure sets all config variables which are answered with 'n' to 'n'.

Welcome to the 'if' statement....

Quoted 3 lines

Can you extract an example where #2 is actually used?

From a first review I can't - but we need to verify that is the case completely

before we make the change.

#4 lore raw
In reply to Russell King
Quoted 2 lines · Russell King

Err, how can $BAR be undefined? Configure sets all config variables which are answered with 'n' to 'n'.

if [ "$CONFIG_xyz" = "y" ]; then
bool CONFIG_bar
fi

CONFIG_bar can be undefined, not 'n'. While that can cause problems, it is also valid config code. If I interpret AC's cryptic comments correctly, there may be code which assumes that undefined variables are just that, undefined. Setting all variables to 'n' initially by Adam's script will break such code.

This type of code treats undefined variables as "don't care", not as "forbidden". Is there any such code? I don't know for sure, but I am sure that a change of this magnitude does not belong in 2.4.

The problem Adam was trying to fix was

dep_bool CONFIG_bar $CONFIG_ARCH_foo

where if the arch is not foo then bar is incorrectly allowed because CONFIG_ARCH_foo is undefined. IMHO it is safe to assume that all arch dependent config settings are meant to be off if the arch is not selected, i.e. setting CONFIG_ARCH_foo=n for all arch except the current one is safe. Setting _all_ CONFIG_foo=n for all variables is not safe.

I still think this is the best approach, against 2.4.5-ac22.

Index: 5.54/arch/config.in

arch/config.in Sat, 30 Jun 2001 21:42:15 +1000 kaos (linux-2.4/D/e/15_config.in 644) renamed from arch/config.in Sat, 30 Jun 2001 21:43:30 +1000 kaos () +21 -0
@@ -0,0 +1,21 @@
+# Ensure that all arch settings are off except the one that is selected.  This
+# simplifies arch dependent driver selection.  Each architecture's specific
+# config variable must appear in this list.  All arch's must include this file
+# at the start of arch/*/config.in.
+
+define_bool CONFIG_ALPHA n
+define_bool CONFIG_ARCH_CRIS n
+define_bool CONFIG_ARCH_M68K n
+define_bool CONFIG_ARCH_S390 n
+define_bool CONFIG_ARCH_S390X n
+define_bool CONFIG_ARM n
+define_bool CONFIG_IA64 n
+define_bool CONFIG_MIPS n
+define_bool CONFIG_MIPS_64 n
+define_bool CONFIG_PARISC n
+define_bool CONFIG_PPC n
+define_bool CONFIG_SPARC32 n
+define_bool CONFIG_SPARC64 n
+define_bool CONFIG_SUPERH n
+define_bool CONFIG_USERMODE n
+define_bool CONFIG_X86 n

Index: 5.54/arch/parisc/config.in

arch/parisc/config.in Sat, 30 Jun 2001 21:27:43 +1000 kaos (linux-2.4/l/c/33_config.in 1.1.2.1 644) renamed from arch/parisc/config.in Sun, 22 Apr 2001 08:14:43 +1000 kaos (linux-2.4/l/c/33_config.in 1.1.2.1 644) +2 -0
@@ -3,6 +3,8 @@
 # see the Configure script.
 #
 
+source arch/config.in
+
 mainmenu_name "Linux Kernel Configuration"
 
 define_bool CONFIG_PARISC y

Index: 5.54/arch/s390/config.in

arch/s390/config.in Sat, 30 Jun 2001 21:27:50 +1000 kaos (linux-2.4/n/c/39_config.in 1.4 644) renamed from arch/s390/config.in Sun, 22 Apr 2001 08:14:43 +1000 kaos (linux-2.4/n/c/39_config.in 1.4 644) +2 -0
@@ -3,6 +3,8 @@
 # see Documentation/kbuild/config-language.txt.
 #
 
+source arch/config.in
+
 define_bool CONFIG_ISA n
 define_bool CONFIG_EISA n
 define_bool CONFIG_MCA n

Index: 5.54/arch/mips64/config.in

arch/mips64/config.in Sat, 30 Jun 2001 21:42:08 +1000 kaos (linux-2.4/p/c/34_config.in 1.2.1.1.1.2 644) renamed from arch/mips64/config.in Wed, 20 Jun 2001 13:07:10 +1000 kaos (linux-2.4/p/c/34_config.in 1.2.1.1.1.2 644) +5 -0
@@ -2,6 +2,11 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
+define_bool CONFIG_ARCH_MIPS64 y
+
 mainmenu_name "Linux Kernel Configuration"
 
 mainmenu_option next_comment

Index: 5.54/arch/ia64/config.in

arch/ia64/config.in Sat, 30 Jun 2001 21:29:08 +1000 kaos (linux-2.4/s/c/38_config.in 1.1.2.1.3.1.1.2 644) renamed from arch/ia64/config.in Sun, 22 Apr 2001 07:25:55 +1000 kaos (linux-2.4/s/c/38_config.in 1.1.2.1.3.1.1.2 644) +2 -0
@@ -1,3 +1,5 @@
+source arch/config.in
+
 mainmenu_name "Kernel configuration of Linux for IA-64 machines"
 
 mainmenu_option next_comment

Index: 5.54/arch/sh/config.in

arch/sh/config.in Sat, 30 Jun 2001 21:29:32 +1000 kaos (linux-2.4/t/c/42_config.in 1.1.1.1.1.1 644) renamed from arch/sh/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/t/c/42_config.in 1.1.1.1.1.1 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux/SuperH Kernel Configuration"
 
 define_bool CONFIG_SUPERH y

Index: 5.54/arch/arm/config.in

arch/arm/config.in Sat, 30 Jun 2001 21:28:43 +1000 kaos (linux-2.4/x/c/32_config.in 1.3.1.2.1.1 644) renamed from arch/arm/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/x/c/32_config.in 1.3.1.2.1.1 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux Kernel Configuration"
 
 define_bool CONFIG_ARM y

Index: 5.54/arch/sparc64/config.in

arch/sparc64/config.in Sat, 30 Jun 2001 21:29:37 +1000 kaos (linux-2.4/z/c/48_config.in 1.11.1.1 644) renamed from arch/sparc64/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/z/c/48_config.in 1.11.1.1 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see the Configure script.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux/UltraSPARC Kernel Configuration"
 
 mainmenu_option next_comment

Index: 5.54/arch/m68k/config.in

arch/m68k/config.in Sat, 30 Jun 2001 21:40:20 +1000 kaos (linux-2.4/E/c/5_config.in 1.1.1.4 644) renamed from arch/m68k/config.in Wed, 06 Jun 2001 11:47:52 +1000 kaos (linux-2.4/E/c/5_config.in 1.1.1.4 644) +3 -0
@@ -3,6 +3,9 @@
 # see Documentation/kbuild/config-language.txt.
 #
 
+source arch/config.in
+
+define_bool CONFIG_ARCH_M68K y
 define_bool CONFIG_UID16 y
 define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n

Index: 5.54/arch/ppc/config.in

arch/ppc/config.in Sat, 30 Jun 2001 21:29:25 +1000 kaos (linux-2.4/H/c/11_config.in 1.2.1.1.2.4.1.1 644) renamed from arch/ppc/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/H/c/11_config.in 1.2.1.1.2.4.1.1 644) +3 -0
@@ -3,6 +3,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 define_bool CONFIG_UID16 n
 define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y

Index: 5.54/arch/mips/config.in

arch/mips/config.in Sat, 30 Jun 2001 21:29:13 +1000 kaos (linux-2.4/M/c/48_config.in 1.1.1.1.1.2 644) renamed from arch/mips/config.in Wed, 20 Jun 2001 13:07:10 +1000 kaos (linux-2.4/M/c/48_config.in 1.1.1.1.1.2 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 define_bool CONFIG_MIPS y
 define_bool CONFIG_SMP n
 

Index: 5.54/arch/sparc/config.in

arch/sparc/config.in Sat, 30 Jun 2001 21:29:35 +1000 kaos (linux-2.4/P/c/8_config.in 1.3.1.2.1.1 644) renamed from arch/sparc/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/P/c/8_config.in 1.3.1.2.1.1 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux/SPARC Kernel Configuration"
 
 define_bool CONFIG_UID16 y

Index: 5.54/arch/alpha/config.in

arch/alpha/config.in Sat, 30 Jun 2001 21:27:01 +1000 kaos (linux-2.4/R/c/33_config.in 1.1.1.1.1.5 644) renamed from arch/alpha/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/R/c/33_config.in 1.1.1.1.1.5 644) +2 -0
@@ -3,6 +3,8 @@
 # see Documentation/kbuild/config-language.txt.
 #
 
+source arch/config.in
+
 define_bool CONFIG_ALPHA y
 define_bool CONFIG_UID16 n
 define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y

Index: 5.54/arch/i386/config.in

arch/i386/config.in Sat, 30 Jun 2001 21:28:59 +1000 kaos (linux-2.4/T/c/36_config.in 1.1.2.1.3.1.1.9 644) renamed from arch/i386/config.in Fri, 29 Jun 2001 11:31:04 +1000 kaos (linux-2.4/T/c/36_config.in 1.1.2.1.3.1.1.9 644) +3 -0
@@ -2,6 +2,9 @@
 # For a description of the syntax of this configuration file,
 # see Documentation/kbuild/config-language.txt.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux Kernel Configuration"
 
 define_bool CONFIG_X86 y

Index: 5.54/arch/cris/config.in

arch/cris/config.in Sat, 30 Jun 2001 21:40:14 +1000 kaos (linux-2.4/m/d/45_config.in 1.2.1.5 644) renamed from arch/cris/config.in Wed, 20 Jun 2001 13:07:10 +1000 kaos (linux-2.4/m/d/45_config.in 1.2.1.5 644) +4 -0
@@ -2,8 +2,12 @@
 # For a description of the syntax of this configuration file,
 # see the Configure script.
 #
+
+source arch/config.in
+
 mainmenu_name "Linux/CRIS Kernel Configuration"
 
+define_bool CONFIG_ARCH_CRIS y
 define_bool CONFIG_UID16 y
 define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
 define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n

Index: 5.54/arch/s390x/config.in

arch/s390x/config.in Sat, 30 Jun 2001 21:27:53 +1000 kaos (linux-2.4/q/d/3_config.in 1.3 644) renamed from arch/s390x/config.in Sun, 22 Apr 2001 08:14:43 +1000 kaos (linux-2.4/q/d/3_config.in 1.3 644) +2 -0
@@ -3,6 +3,8 @@
 # see Documentation/kbuild/config-language.txt.
 #
 
+source arch/config.in
+
 define_bool CONFIG_ISA n
 define_bool CONFIG_EISA n
 define_bool CONFIG_MCA n

Index: 5.54/arch/um/config.in

arch/um/config.in Sat, 30 Jun 2001 21:29:42 +1000 kaos (linux-2.4/U/d/26_config.in 1.4 644) renamed from arch/um/config.in Sat, 16 Jun 2001 09:05:21 +1000 kaos (linux-2.4/U/d/26_config.in 1.4 644) +2 -1
@@ -1,5 +1,6 @@
-define_bool CONFIG_USERMODE y
+source arch/config.in
 
+define_bool CONFIG_USERMODE y
 mainmenu_name "Linux/Usermode Kernel Configuration"
 
 define_bool CONFIG_ISA y
#5 lore raw
In reply to Russell King
Quoted 4 lines · Alan Cox
Quoted 2 lines

Err, how can $BAR be undefined? Configure sets all config variables which are answered with 'n' to 'n'.

Welcome to the 'if' statement....

Thank you, yes, but I believe we were talking about dep_* and not if statements?

Quoted 2 lines

From a first review I can't - but we need to verify that is the case completely before we make the change.

Indeed.

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

#7 lore raw
In reply to Russell King
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Err, how can $BAR be undefined? Configure sets all config variables which are answered with 'n' to 'n'.

Welcome to the 'if' statement....

Thank you, yes, but I believe we were talking about dep_* and not if statements?

No we are talking about Config.in scripts

if [ condition ]
bool 'foo' CONFIG_FOO

fi

dep_tristate ... $CONFIG_FOO

Quoted 1 line
#8 lore raw
In reply to Russell King
Quoted 5 lines · Keith Owens

CONFIG_bar can be undefined, not 'n'. While that can cause problems, it is also valid config code. If I interpret AC's cryptic comments correctly, there may be code which assumes that undefined variables are just that, undefined. Setting all variables to 'n' initially by Adam's script will break such code.

Agreed. The person who should know for sure how the configuration system
works is ESR.

Quoted 1 line

I still think this is the best approach, against 2.4.5-ac22.

One small concern - does it work properly with xconfig and menuconfig? I seem to remember that they re-evaluate choices, and I have this feeling that I've seen unselectable symbols caused by define_bool SYM n type stuff.

Note also that we in the ARM port currently have 43 such symbols in either Linus' or my tree, and there are getting on for 90 such symbols in existence throughout the ARM trees. (There are around 90 registered ARM machine types at the moment, each one has their own CONFIG symbol).

Your config.in file could get very large. ;)

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html