Skip to contentSkip to conversation

kconfig: Fixes to make localmodconfig

GIT PULL In review Steven Rostedt 3 participants 13 messages Oct 29, 2010 – Nov 25, 2010

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

Linus,

Please pull the latest for-linus tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-kconfig.git
for-linus

Steven Rostedt (3):
kconfig: Make localmodconfig handle environment variables
kconfig: Fix streamline_config to read multi line deps in Kconfig files
kconfig: Have streamline_config process menuconfigs too

hiromu (1):
kconfig: Fix missing declaration of variable $dir in streamline_config.pl

hiromu yagura (1):
kconfig: Fix variable name typo %prompts in streamline_config.pl

----

 scripts/kconfig/streamline_config.pl |   43 ++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 7 deletions(-)
#1 lore raw

PATCH 1/5 kconfig: Make localmodconfig handle environment variables

From: Steven Rostedt <[email protected]>

The commit 838a2e55e6a4e9e8a10451ed2ef0f7a08dabdb04
kbuild: migrate all arch to the kconfig mainmenu upgrade

Broke make localmodconfig. The reason was that it added a environment variable to the kconfig source, which the streamline_config.pl could not handle.

This patch changes streamline_config.pl to handle kconfig sources using environment variables in their names.

Cc Arnaud Lacombe <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Michal Marek <[email protected]>
---
 scripts/kconfig/streamline_config.pl |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
scripts/kconfig/streamline_config.pl +11 -1
index c70a27d..cc10bcf 100644
@@ -137,7 +137,17 @@ sub read_kconfig {
     my $config;
     my @kconfigs;
 
-    open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig";
+    my $source = "$ksource/$kconfig";
+    my $last_source = "";
+
+    # Check for any environment variables used
+    while ($source =~ /\$(\w+)/ && $last_source ne $source) {
+	my $env = $1;
+	$last_source = $source;
+	$source =~ s/\$$env/$ENV{$env}/;
+    }
+
+    open(KIN, "$source") || die "Can't open $kconfig";
     while (<KIN>) {
 	chomp;
 
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Hi,

Quoted 9 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

The commit 838a2e55e6a4e9e8a10451ed2ef0f7a08dabdb04
 kbuild: migrate all arch to the kconfig mainmenu upgrade

Broke make localmodconfig. The reason was that it added a environment variable to the kconfig source, which the streamline_config.pl could not handle.

Technically, it is _not_ an environment variable; it is a kconfig symbol's name. In this particular case, both name collide and the kconfig symbol happens to get its default value from the environment. The real fixes, from my point of view, would be to have a perl binding of the kconfig backend and get rid of read_kconfig(). That said, your patch is broken if a symbol happen not to match an environment variable (both in name and value).

Btw, two questions:
- who has authority on kconfig ? Michal or you ? MAINTAINERS say
"Roman Zippel", but AFAIK, this is no longer valid.
- what is the delay someone in CC: is given the time to answer a
patch ? I see that this one particularly is already in Linus' tree.

Thanks,
- Arnaud

Quoted 39 lines

This patch changes streamline_config.pl to handle kconfig sources using environment variables in their names.

Cc Arnaud Lacombe <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Michal Marek <[email protected]>

---
 scripts/kconfig/streamline_config.pl |   12 +++++++++++-

 1 files changed, 11 insertions(+), 1 deletions(-)
scripts/kconfig/streamline_config.pl +11 -2
index c70a27d..cc10bcf 100644
@@ -137,7 +137,17 @@ sub read_kconfig {
     my $config;
     my @kconfigs;
 
-    open(KIN, "$ksource/$kconfig") || die "Can't open $kconfig";
+    my $source = "$ksource/$kconfig";
+    my $last_source = "";
+
+    # Check for any environment variables used
+    while ($source =~ /\$(\w+)/ && $last_source ne $source) {
+       my $env = $1;
+       $last_source = $source;
+       $source =~ s/\$$env/$ENV{$env}/;
+    }
+
+    open(KIN, "$source") || die "Can't open $kconfig";
     while (<KIN>) {
        chomp;
 
--

1.7.1

#3 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Quoted 9 lines · Arnaud Lacombe

Hi,

Technically, it is _not_ an environment variable; it is a kconfig symbol's name. In this particular case, both name collide and the kconfig symbol happens to get its default value from the environment. The real fixes, from my point of view, would be to have a perl binding of the kconfig backend and get rid of read_kconfig(). That said, your patch is broken if a symbol happen not to match an environment variable (both in name and value).

That sounds like a proper fix. Unfortunately, I don't have the time to work on this now, and although this fix works by coincidence, it never-the-less works, as suppose to just having localmodconfig crash.

But you are right. After KS and Plumbers, I'll work on doing something like that. That can probably solve some of the other issues I'm having (still keeping too many modules enabled).

Quoted 4 lines

Btw, two questions:
- who has authority on kconfig ? Michal or you ? MAINTAINERS say
"Roman Zippel", but AFAIK, this is no longer valid.

Michal is in charge of the build system. I just wrote streamline_config.pl, and have been maintaining it on my own. If I ever need to touch anything outside of that script, I always ask for Michal's Acked-by.

Quoted 2 lines

- what is the delay someone in CC: is given the time to answer a
patch ? I see that this one particularly is already in Linus' tree.

Well, again, I consider myself the maintainer of streamline_config.pl, and as long as my changes don't affect anything else, I don't ask for forgiveness ;-)

I probably should rename my subject (and my git tree) to s/kconfig/localmodconfig/. But then again, having the kconfig: name gets the attention of people like yourself to tell me what you told me.

-- Steve

#4 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Hi,

Quoted 11 lines · Steven Rostedt
Quoted 9 lines · Arnaud Lacombe

Hi,

Technically, it is _not_ an environment variable; it is a kconfig symbol's name. In this particular case, both name collide and the kconfig symbol happens to get its default value from the environment. The real fixes, from my point of view, would be to have a perl binding of the kconfig backend and get rid of read_kconfig(). That said, your patch is broken if a symbol happen not to match an environment variable (both in name and value).

Quoted 4 lines

That sounds like a proper fix. Unfortunately, I don't have the time to work on this now, and although this fix works by coincidence, it never-the-less works, as suppose to just having localmodconfig crash.

yes, sure.

Quoted 4 lines

But you are right. After KS and Plumbers, I'll work on doing something like that. That can probably solve some of the other issues I'm having (still keeping too many modules enabled).

I have some work in progress in this area: cleanup, better split between the kconfig backend and frontend, and eventually a perl binding. That would all be an interesting goal for .38 :-)

Currently I got the parser working within perl, but I'm not really really sure of what I can currently do with it and how the whole thing interface to one another :)

- Arnaud

#5 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Quoted 6 lines · Arnaud Lacombe

Hi,

Quoted 4 lines

But you are right. After KS and Plumbers, I'll work on doing something like that. That can probably solve some of the other issues I'm having (still keeping too many modules enabled).

Quoted 7 lines

I have some work in progress in this area: cleanup, better split between the kconfig backend and frontend, and eventually a perl binding. That would all be an interesting goal for .38 :-)

Currently I got the parser working within perl, but I'm not really really sure of what I can currently do with it and how the whole thing interface to one another :)

Let me know what you got, I would really like localmodconfig to have this back end. It should really help get a minimal config as well.

-- Steve

#6 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Quoted 11 lines · Steven Rostedt
Quoted 10 lines · Arnaud Lacombe

Hi,

Quoted 4 lines

But you are right. After KS and Plumbers, I'll work on doing something like that. That can probably solve some of the other issues I'm having (still keeping too many modules enabled).

I have some work in progress in this area: cleanup, better split between the kconfig backend and frontend, and eventually a perl binding. That would all be an interesting goal for .38 :-)

Quoted 6 lines
Quoted 3 lines

Currently I got the parser working within perl, but I'm not really really sure of what I can currently do with it and how the whole thing interface to one another :)

Let me know what you got, I would really like localmodconfig to have this back end. It should really help get a minimal config as well.

What information does localmodconfig need? A list of config options and their computed dependencies and a flag for each option if it has prompt, anything else? So a scripts/kconfig/conf --dump-kconfig that would produce such flat list should suffice, without the complexity of having to build a perl binding first (and would be usable from bash/awk/python scripts as well). What do you think?

Michal

#7 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Hi,

Quoted 7 lines · Michal Marek

What information does localmodconfig need? A list of config options and their computed dependencies and a flag for each option if it has prompt, anything else? So a scripts/kconfig/conf --dump-kconfig that would produce such flat list should suffice, without the complexity of having to build a perl binding first (and would be usable from bash/awk/python scripts as well). What do you think?

Just as a FYI, the output of zconfdump() does not respect the kconfig syntax. I've got some patches to fix that, but I've not been able to touch them since a few weeks now.

- Arnaud

#8 lore raw

Re: [PATCH 1/5] [PATCH 1/5] kconfig: Make localmodconfig handle environment variables

Quoted 10 lines · Arnaud Lacombe

Hi,

Quoted 7 lines · Michal Marek

What information does localmodconfig need? A list of config options and their computed dependencies and a flag for each option if it has prompt, anything else? So a scripts/kconfig/conf --dump-kconfig that would produce such flat list should suffice, without the complexity of having to build a perl binding first (and would be usable from bash/awk/python scripts as well). What do you think?

Quoted 3 lines

Just as a FYI, the output of zconfdump() does not respect the kconfig syntax. I've got some patches to fix that, but I've not been able to touch them since a few weeks now.

I'm not saying zconfdump() has to be used or that it has to follow the kconfig syntax (*), just that a pipe interface between the C kconfig and a Perl script might be easier to implement and use :-).

(*) Although using a subset of the kconfig syntax would be a good idea definitely.

Michal

#9 lore raw

PATCH 2/5 kconfig: Fix variable name typo %prompts in streamline_config.pl

In reply to Steven Rostedt

From: hiromu yagura <[email protected]>

When I added "use strict;" to streamline_config.pl, I saw the following warnings:

Quoted 1 line

Global symbol "%prompt" requires explicit package name at

scripts/kconfig/streamline_config.pl line 183.

Quoted 1 line

Global symbol "%prompt" requires explicit package name at

scripts/kconfig/streamline_config.pl line 368.

The declaration of %prompt was incorrect, and should have been %prompts.

Cc Toralf Foerster <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>

LKML-Reference: <1281845597.11566.5.camel@camp10-laptop>

---
 scripts/kconfig/streamline_config.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/kconfig/streamline_config.pl +2 -2
index cc10bcf..3c63aa9 100644
@@ -188,7 +188,7 @@ sub read_kconfig {
 	# configs without prompts must be selected
 	} elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
 	    # note if the config has a prompt
-	    $prompt{$config} = 1;
+	    $prompts{$config} = 1;
 
 	# Check for if statements
 	} elsif (/^if\s+(.*\S)\s*$/) {
@@ -373,7 +373,7 @@ while ($repeat) {
 	    parse_config_dep_select $depends{$config};
 	}
 
-	if (defined($prompt{$config}) || !defined($selects{$config})) {
+	if (defined($prompts{$config}) || !defined($selects{$config})) {
 	    next;
 	}
 
Signature · 1 line
1.7.1
#10 lore raw

PATCH 3/5 kconfig: Fix missing declaration of variable $dir in streamline_config.pl

In reply to Steven Rostedt

From: hiromu <[email protected]>

Quoted 3 lines · Américo Wang

BTW, I think we should add "use strict;" too.

Then I added "use strict;" to streamline_config.pl, I saw another warning.

Quoted 1 line

Global symbol "$dir" requires explicit package name at

scripts/kconfig/streamline_config.pl line 286.

Quoted 1 line

Global symbol "$dir" requires explicit package name at

scripts/kconfig/streamline_config.pl line 287.

Quoted 1 line

Global symbol "$dir" requires explicit package name at

scripts/kconfig/streamline_config.pl line 288.

Then I added "my $dir;" to line 285.

Cc Américo Wang <[email protected]>
Cc Toralf Foerster <[email protected]>
Cc KAMEZAWA Hiroyuki <[email protected]>
Cc YOSHIFUJI Hideaki <[email protected]>

LKML-Reference: <1282042158.7160.9.camel@hiromu-Macbook>

[ changed to just add my in front of $dir instead of new line ]

---
 scripts/kconfig/streamline_config.pl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/kconfig/streamline_config.pl +3 -1
index 3c63aa9..883748c 100644
@@ -42,6 +42,8 @@
 #    mv config_strip .config
 #    make oldconfig
 #
+use strict;
+
 my $config = ".config";
 
 my $uname = `uname -r`;
@@ -291,7 +293,7 @@ if (defined($lsmod_file)) {
     # see what modules are loaded on this system
     my $lsmod;
 
-    foreach $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
+    foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
 	if ( -x "$dir/lsmod" ) {
 	    $lsmod = "$dir/lsmod";
 	    last;
Signature · 1 line
1.7.1
#11 lore raw

PATCH 4/5 kconfig: Fix streamline_config to read multi line deps in Kconfig files

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

I noticed that some Kconfig files have multi line dependencies that continue with a backslash. Those dependencies on the next line will be missed by streamline_config.

For example:

config CS89x0

	tristate "CS89x0 support"
	depends on NET_ETHERNET && (ISA || EISA || MACH_IXDP2351 \
		|| ARCH_IXDP2X01 || MACH_MX31ADS)

The "|| ARCH_IXDP2X01 || MACH_MX31ADS)" will not be processed.

This patch adds code to handle this case.

---
 scripts/kconfig/streamline_config.pl |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
scripts/kconfig/streamline_config.pl +18 -1
index 883748c..ebba407 100644
@@ -125,7 +125,6 @@ my %selects;
 my %prompts;
 my %objects;
 my $var;
-my $cont = 0;
 my $iflevel = 0;
 my @ifdeps;
 
@@ -139,6 +138,9 @@ sub read_kconfig {
     my $config;
     my @kconfigs;
 
+    my $cont = 0;
+    my $line;
+
     my $source = "$ksource/$kconfig";
     my $last_source = "";
 
@@ -153,6 +155,19 @@ sub read_kconfig {
     while (<KIN>) {
 	chomp;
 
+	# Make sure that lines ending with \ continue
+	if ($cont) {
+	    $_ = $line . " " . $_;
+	}
+
+	if (s/\\$//) {
+	    $cont = 1;
+	    $line = $_;
+	    next;
+	}
+
+	$cont = 0;
+
 	# collect any Kconfig sources
 	if (/^source\s*"(.*)"/) {
 	    $kconfigs[$#kconfigs+1] = $1;
@@ -230,6 +245,8 @@ if ($kconfig) {
 # Read all Makefiles to map the configs to the objects
 foreach my $makefile (@makefiles) {
 
+    my $cont = 0;
+
     open(MIN,$makefile) || die "Can't open $makefile";
     while (<MIN>) {
 	my $objs;
Signature · 1 line
1.7.1
#12 lore raw

PATCH 5/5 kconfig: Have streamline_config process menuconfigs too

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Some menuconfigs in the Kconfig files have prompts and dependencies. Currently, streamline_config misses these, and this can cause streamline_config to keep modules enabled that should not be, and even worse, not enable those that should.

This patch makes streamline_config process menuconfigs just like it would process a config.

---
 scripts/kconfig/streamline_config.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
scripts/kconfig/streamline_config.pl +2 -2
index ebba407..fd81fc3 100644
@@ -174,9 +174,9 @@ sub read_kconfig {
 	}
 
 	# configs found
-	if (/^\s*config\s+(\S+)\s*$/) {
+	if (/^\s*(menu)?config\s+(\S+)\s*$/) {
 	    $state = "NEW";
-	    $config = $1;
+	    $config = $2;
 
 	    for (my $i = 0; $i < $iflevel; $i++) {
 		if ($i) {
Signature · 1 line
1.7.1