2003-09-08 16:55:22

by Ricky Beam

[permalink] [raw]
Subject: [BK PATCH] build: config vs. everything else

I've long wondered why make {anything}config followed by building anything
else would rebuild a number of mostly unrelated things in scripts. So,
I dug into it (oh, what an ugly web...)

The Story:
The rules for config (and %config) depend on "scripts" which will build
basically everything in scripts. However, there are two problems with this.
First, *config only NEEDS fixdep. Second, the complete build environment is
not setup at config time, so the compiler settings are not consistant. To
illustrate the point, compare scripts/.empty.o.cmd after a "make config" and
"make image" (zImage, whatever)

The "bk send" is attached. Below is the diff. Excuse the "@/bin/true"...
It's the fastest way to get make to shutup.

--Ricky

--- 1.425/Makefile Tue Sep 2 15:13:35 2003
+++ 1.426/Makefile Fri Sep 5 22:25:25 2003
@@ -259,12 +259,13 @@

# Helpers built in scripts/

-scripts/docproc scripts/fixdep scripts/split-include : scripts ;
+scripts/docproc scripts/split-include : scripts ;

-.PHONY: scripts
+.PHONY: scripts scripts/fixdep
scripts:
$(Q)$(MAKE) $(build)=scripts
-
+scripts/fixdep:
+ $(Q)$(MAKE) $(build)=scripts fixdep

# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -342,8 +343,8 @@

# If .config is newer than include/linux/autoconf.h, someone tinkered
# with it and forgot to run make oldconfig
-include/linux/autoconf.h: scripts/fixdep .config
- $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
+include/linux/autoconf.h: .config
+ $(Q)$(MAKE) -f $(TOPDIR)/Makefile silentoldconfig

endif


--- 1.34/scripts/Makefile Tue Mar 18 13:19:44 2003
+++ 1.35/scripts/Makefile Fri Sep 5 22:25:25 2003
@@ -22,6 +22,9 @@
# fixdep is needed to compile other host programs
$(addprefix $(obj)/,$(filter-out fixdep,$(always)) $(subdir-y)): $(obj)/fixdep

+fixdep: $(obj)/fixdep
+ @/bin/true
+
# dependencies on generated files need to be listed explicitly

$(obj)/modpost.o $(obj)/file2alias.o: $(obj)/elfconfig.h
@@ -33,3 +36,4 @@
$(call if_changed,elfconfig)

targets += elfconfig.h
+

--- 1.9/scripts/kconfig/Makefile Sun Aug 31 19:13:49 2003
+++ 1.10/scripts/kconfig/Makefile Fri Sep 5 22:25:25 2003
@@ -21,7 +21,7 @@
$< -o arch/$(ARCH)/Kconfig

silentoldconfig: $(obj)/conf
- $< -s arch/$(ARCH)/Kconfig
+ $(Q)$< -s arch/$(ARCH)/Kconfig

.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig


--- 1.9/scripts/kconfig/conf.c Fri Jun 6 10:51:38 2003
+++ 1.10/scripts/kconfig/conf.c Fri Sep 5 22:25:25 2003
@@ -532,7 +532,8 @@
}
break;
case ask_silent:
- if (stat(".config", &tmpstat)) {
+ name = ".config";
+ if (stat(name, &tmpstat)) {
printf("***\n"
"*** You have not yet configured your kernel!\n"
"***\n"
@@ -541,6 +542,8 @@
"***\n");
exit(1);
}
+ conf_read(name);
+ break;
case ask_all:
case ask_new:
conf_read(NULL);


Attachments:
build.patch (6.25 kB)
BK send patch

2003-09-08 18:19:40

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [BK PATCH] build: config vs. everything else

Hi Ricky, I like your patch, but have a few comments.

> The rules for config (and %config) depend on "scripts" which will build
> basically everything in scripts. However, there are two problems with this.
> First, *config only NEEDS fixdep.
Correct.

> Second, the complete build environment is
> not setup at config time, so the compiler settings are not consistant. To
> illustrate the point, compare scripts/.empty.o.cmd after a "make config" and
> "make image" (zImage, whatever)
Again correct, which is also why we see modpost being built so often.

A few comments to your patch:

> The "bk send" is attached. Below is the diff. Excuse the "@/bin/true"...
> It's the fastest way to get make to shutup.
@: is faster, and used by kbuld today.

> +scripts/fixdep:
> + $(Q)$(MAKE) $(build)=scripts fixdep
Try to avoid special targets when the full name is OK.
No need for the fixdep target in scripts/Makefile

> -include/linux/autoconf.h: scripts/fixdep .config
> - $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
> +include/linux/autoconf.h: .config
> + $(Q)$(MAKE) -f $(TOPDIR)/Makefile silentoldconfig

Nice. But notice that TOPDIR is obsolete, use srctree.

> +fixdep: $(obj)/fixdep
> + @/bin/true
As noted above, this shortcut target is not needed.

> targets += elfconfig.h
> +
Avoid random white space changes.

> --- 1.9/scripts/kconfig/Makefile Sun Aug 31 19:13:49 2003
> +++ 1.10/scripts/kconfig/Makefile Fri Sep 5 22:25:25 2003
> @@ -21,7 +21,7 @@
> $< -o arch/$(ARCH)/Kconfig
>
> silentoldconfig: $(obj)/conf
> - $< -s arch/$(ARCH)/Kconfig
> + $(Q)$< -s arch/$(ARCH)/Kconfig
Unrelated change.

> --- 1.9/scripts/kconfig/conf.c Fri Jun 6 10:51:38 2003
> +++ 1.10/scripts/kconfig/conf.c Fri Sep 5 22:25:25 2003
> @@ -532,7 +532,8 @@
> }
> break;
> case ask_silent:
> - if (stat(".config", &tmpstat)) {
> + name = ".config";
> + if (stat(name, &tmpstat)) {
> printf("***\n"
> "*** You have not yet configured your kernel!\n"
> "***\n"
> @@ -541,6 +542,8 @@
> "***\n");
> exit(1);
> }
> + conf_read(name);
> + break;

What is the purpose of this change?
If it fixes kconfig behaviour it should go separate to Roman Zippel.

I have modified your the patch according to my cooments:

===== Makefile 1.424 vs edited =====
--- 1.424/Makefile Mon Sep 1 01:14:39 2003
+++ edited/Makefile Mon Sep 8 20:09:54 2003
@@ -253,12 +253,14 @@

# Helpers built in scripts/

-scripts/docproc scripts/fixdep scripts/split-include : scripts ;
+scripts/docproc scripts/split-include : scripts ;

-.PHONY: scripts
+.PHONY: scripts scripts/fixdep
scripts:
$(Q)$(MAKE) $(build)=scripts

+scripts/fixdep:
+ $(Q)$(MAKE) $(build)=scripts $@

# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -336,8 +338,8 @@

# If .config is newer than include/linux/autoconf.h, someone tinkered
# with it and forgot to run make oldconfig
-include/linux/autoconf.h: scripts/fixdep .config
- $(Q)$(MAKE) $(build)=scripts/kconfig silentoldconfig
+include/linux/autoconf.h: .config
+ $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig

endif


2003-09-08 18:49:22

by Ricky Beam

[permalink] [raw]
Subject: Re: [BK PATCH] build: config vs. everything else

On Mon, 8 Sep 2003, Sam Ravnborg wrote:
>> The "bk send" is attached. Below is the diff. Excuse the "@/bin/true"...
>> It's the fastest way to get make to shutup.
>@: is faster, and used by kbuld today.

Noted.

>> +scripts/fixdep:
>> + $(Q)$(MAKE) $(build)=scripts fixdep
>Try to avoid special targets when the full name is OK.
>No need for the fixdep target in scripts/Makefile

I seem to recall doing it this way for some reason. But, the logic is the
same. Oh, now I remember... there has to be an explicit target to get
make to not say "already up to date."

>> targets += elfconfig.h
>> +
>Avoid random white space changes.

Then leave a blank line at the end of the file :-)

>> --- 1.9/scripts/kconfig/Makefile Sun Aug 31 19:13:49 2003
>> +++ 1.10/scripts/kconfig/Makefile Fri Sep 5 22:25:25 2003
>> @@ -21,7 +21,7 @@
>> $< -o arch/$(ARCH)/Kconfig
>>
>> silentoldconfig: $(obj)/conf
>> - $< -s arch/$(ARCH)/Kconfig
>> + $(Q)$< -s arch/$(ARCH)/Kconfig
>Unrelated change.

Strictly speaking...

>> --- 1.9/scripts/kconfig/conf.c Fri Jun 6 10:51:38 2003
>> +++ 1.10/scripts/kconfig/conf.c Fri Sep 5 22:25:25 2003
>> @@ -532,7 +532,8 @@
>> }
>> break;
>> case ask_silent:
>> - if (stat(".config", &tmpstat)) {
>> + name = ".config";
>> + if (stat(name, &tmpstat)) {
>> printf("***\n"
>> "*** You have not yet configured your kernel!\n"
>> "***\n"
>> @@ -541,6 +542,8 @@
>> "***\n");
>> exit(1);
>> }
>> + conf_read(name);
>> + break;
>
>What is the purpose of this change?
>If it fixes kconfig behaviour it should go separate to Roman Zippel.

"-s" (silent) should actually *be* silent. If conf_read() is called without
a config file, it isn't silent. (The use of 'name' is merely an optimization.)

--Ricky