Skip to contentSkip to conversation

kbuild fixes

PATCH New Sam Ravnborg 3 participants 14 messages Jul 29, 2006 – Aug 1, 2006

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

cover kbuild fixes

Hi Linus.

Here is a number of small and smaller kbuild fixes for -rc2. Please add them before -rc3.
The list got larger than expected since I missed -rc1 with half a day.

Most noteworthy:

o fix build on ubuntu - breakage caused by -fno-stack-protector enabled on ubuntu
o fix building out-of-tree modules
o fix 'make headers_install' to work with a non-configured kernel
o added unifdef to the kernel tree. It is not a widely distributed tool author has acked this

Patches has been in -mm for a while with no bugs reported. Exception is the 'linguistic fixes' - but they did not cause any compile/boot issues ;-)

Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuld.git

diffstat + shortlog + full log below.

Sam

git diff --stat:

 .gitignore                                |    5 
 Documentation/kbuild/kconfig-language.txt |   12 
 Documentation/kbuild/makefiles.txt        |  184 +++--
 Documentation/kbuild/modules.txt          |  119 ++-
 Kbuild                                    |    2 
 Makefile                                  |    9 
 drivers/scsi/aic7xxx/aicasm/Makefile      |    2 
 scripts/Kbuild.include                    |   55 +-
 scripts/Makefile                          |    3 
 scripts/Makefile.build                    |    5 
 scripts/Makefile.headersinst              |    2 
 scripts/Makefile.modpost                  |    2 
 scripts/kconfig/confdata.c                |   10 
 scripts/mod/file2alias.c                  |   62 +-
 scripts/unifdef.c                         | 1005 +++++++++++++++++++++++++++++
 usr/Makefile                              |    2 
 16 files changed, 1269 insertions(+), 210 deletions(-)

git shortlog:

Dave Jones:
kbuild: fix typo in modpost

Jan Engelhardt:
kbuild: linguistic fixes for Documentation/kbuild/makefiles.txt
kconfig: linguistic fixes for Documentation/kbuild/kconfig-language.txt
kbuild: linguistic fixes for Documentation/kbuild/modules.txt

Matthew Wilcox:
kconfig: support DOS line endings

Olaf Hering:
remove RPM_BUILD_ROOT from asm-offsets.h

Qi Yong:
gitignore: gitignore quilt's files

Roman Zippel:
kconfig: correct oldconfig for unset choice options

Sam Ravnborg:
kbuild: hardcode value of YACC&LEX for aic7-triple-x
kbuild: version.h and new headers_* targets does not require a kernel config
kbuild: .gitignore utsrelease.h
kbuild: improve error from file2alias
kbuild: -fno-stack-protector is not good
kbuild: consistently decide when to rebuild a target
kbuild: always use $(CC) for $(call cc-version)
kbuild: add unifdef
kbuild: replace use of strlcpy with a dedicated implmentation in unifdef
kbuild: use in-kernel unifdef

git log:
commit b193a8c70628aecdbccac81f710cec2bf2dd3592

Author: Jan Engelhardt <[email protected]>
Date:   Thu Jul 27 22:14:29 2006 +0200

kbuild: linguistic fixes for Documentation/kbuild/modules.txt

I have done a look-through through Documentation/kbuild/ and my corrections (proposed) are attached.

Cc'ed are original author Michael (responsible for comitting changes to these files?), Sam (kbuild maintainer), Adrian (-trivial maintainer).

 Documentation/kbuild/modules.txt |  119 +++++++++++++++++++-------------------
 1 files changed, 60 insertions(+), 59 deletions(-)

commit 665cf3bbd09375ea7520083704ce8b8c1bcc54a9

Author: Jan Engelhardt <[email protected]>
Date:   Thu Jul 27 22:14:29 2006 +0200

kconfig: linguistic fixes for Documentation/kbuild/kconfig-language.txt

I have done a look-through through Documentation/kbuild/ and my corrections (proposed) are attached.

Cc'ed are original author Michael (responsible for comitting changes to these files?), Sam (kbuild maintainer), Adrian (-trivial maintainer).

 Documentation/kbuild/kconfig-language.txt |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

commit e2dbd0d4c86f364640429718ce20fbe9aafe979e

Author: Jan Engelhardt <[email protected]>
Date:   Thu Jul 27 22:14:29 2006 +0200

kbuild: linguistic fixes for Documentation/kbuild/makefiles.txt

I have done a look-through through Documentation/kbuild/ and my corrections (proposed) are attached.

Cc'ed are original author Michael (responsible for comitting changes to these files?), Sam (kbuild maintainer), Adrian (-trivial maintainer).

 Documentation/kbuild/makefiles.txt |  184 ++++++++++++++++++------------------
 1 files changed, 94 insertions(+), 90 deletions(-)

commit 5dd5cc7558046806ef29e4057bbb309b1b248634

Author: Olaf Hering <[email protected]>
Date:   Tue Jul 25 18:42:26 2006 -0700

remove RPM_BUILD_ROOT from asm-offsets.h

No file in rpm binary package should have the RPM_BUILD_ROOT string in it. To simplify building of external modules, our kernel-source package contains some temp files from the Kbuild system. asm/asm-offsets.h is one of the files that contains the absolute path if make O=$O is used.

* This file was generated by /var/tmp/kernel-source-2.6.14_rc4-build/usr/src/linux-2.6.14-rc4-2/Kbuild

Remove the $RPM_BUILD_ROOT string in the shipped tempfile.

 Kbuild |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

commit 81ec74898bbc68bd0818cb86faa7016ae9e68445

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 23 20:47:50 2006 +0200

kbuild: use in-kernel unifdef

Let headers_install use in-kernel unifdef

 Makefile                     |    4 ++--
 scripts/Makefile             |    3 +++
 scripts/Makefile.headersinst |    2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

commit 070ab8cc933596133db55816818c477729f007dd

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 23 20:41:30 2006 +0200

kbuild: replace use of strlcpy with a dedicated implmentation in unifdef

 scripts/unifdef.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

commit b70bca202c920feebc618aaee473bfd14003a46e

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 23 20:39:59 2006 +0200

kbuild: add unifdef

This patch contains a raw copy of unifdef.c
Next patch will modify it and add infrastructure to use it Adding unifdef to the kernel is acked by the author.

The reason to add unifdef as part of the kernel source is that it is not yet a common utility on most distributions.

 scripts/unifdef.c |  998 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 998 insertions(+), 0 deletions(-)

commit ecbe2c133024f9a852e9852197cc77c2884e64bb

Author: Qi Yong <[email protected]>
Date:   Mon Jul 17 13:37:06 2006 +0800

gitignore: gitignore quilt's files

gitignore: ignore quilt's files.

 .gitignore |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

commit 045cfddb5f89722259c90fb742e201d289d94092

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 23 19:49:45 2006 +0200

kbuild: always use $(CC) for $(call cc-version)

The possibility to specify an optional parameter did not work out as expected and it was not used - so remove the possibility.

 scripts/Kbuild.include |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

commit 0b5d8d55caf9a844401cf5b3f534a50d9aa105af

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 23 19:37:44 2006 +0200

kbuild: consistently decide when to rebuild a target

Consistently decide when to rebuild a target across all of if_changed, if_changed_dep, if_changed_rule.
PHONY targets are now treated alike (ignored) for all targets

While add it make Kbuild.include almost readable by factoring out a few bits to some common variables and reuse this in Makefile.build.

 scripts/Kbuild.include |   52 ++++++++++++++++++++++++++++--------------------
 scripts/Makefile.build |    5 +++--
 usr/Makefile           |    2 ++
 3 files changed, 35 insertions(+), 24 deletions(-)

commit 24c56d80c676a79c161821fc928f903ff0f03241

Author: Matthew Wilcox <[email protected]>
Date:   Thu Jul 13 12:54:07 2006 -0600

kconfig: support DOS line endings

Kconfig doesn't currently handle config files with DOS line endings. While these are, of course, an abomination, etc, etc, it can be handy to not have to convert them first. It's also a tiny patch and even adds support for lines ending in just \r or even \n\r.

 scripts/kconfig/confdata.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

commit a014a91bb01be9cce0d2dc292a8488fb81b0cd3b

Author: Roman Zippel <[email protected]>
Date:   Thu Jul 13 13:22:38 2006 +0200

kconfig: correct oldconfig for unset choice options

oldconfig currently ignores unset choice options and doesn't ask for them. Correct the SYMBOL_DEF_USER flag of the choice symbol to be only set if it's set for all values.

 scripts/kconfig/confdata.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

commit ca1b67b522896b8f59be6e5fd81f53987a94695f

Author: Sam Ravnborg <[email protected]>
Date:   Thu Jul 13 20:27:27 2006 +0200

kbuild: -fno-stack-protector is not good

Ubuntu gcc has hardcoded -fstack-protector - but does not understand -fno-stack-protector-all. So only try -fno-stack-protector.

 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

commit b1c34ea9a006ad0deb828921996f071d925d79de

Author: Dave Jones <[email protected]>
Date:   Thu Jul 13 00:44:15 2006 -0400

kbuild: fix typo in modpost

Reported by a Fedora user when they tried to build some out of tree module..

 scripts/Makefile.modpost |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

commit 48d2f630d921ba92cc5d5f75b97a2bf1092277eb

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 9 16:26:07 2006 +0200

kbuild: improve error from file2alias

The original errormessage was just plain unreadable.

Sample error message after this update (not for real - I provoked it):

FATAL: drivers/net/s2io: sizeof(struct pci_device_id)=33 is not a modulo of the size of section __mod_pci_device_table=160.
Fix definition of struct pci_device_id in mod_devicetable.h

Before a warning was generated - this is now a fatal error.

 scripts/mod/file2alias.c |   62 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 19 deletions(-)

commit 6ce316b37017dc83d1e3b16113c6a01750d3d554

Author: Sam Ravnborg <[email protected]>
Date:   Sun Jul 9 16:07:44 2006 +0200

kbuild: .gitignore utsrelease.h

 .gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

commit 3a029538f8135e3416ea9973f3e2d3ae61bbb153

Author: Sam Ravnborg <[email protected]>
Date:   Sat Jul 8 00:46:25 2006 +0200

kbuild: version.h and new headers_* targets does not require a kernel config

 Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

commit 073be037e1615993ed925a28c3f731756b668fdc

Author: Sam Ravnborg <[email protected]>
Date:   Sat Jul 8 00:27:49 2006 +0200

kbuild: hardcode value of YACC&LEX for aic7-triple-x

When we introduced -rR then aic7xxx no loger could pick up definition of YACC&LEX from make - so do it explicit now.

 drivers/scsi/aic7xxx/aicasm/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
#1 lore raw

PATCH 1/1 kbuild: hardcode value of YACC&LEX for aic7-triple-x

From: Sam Ravnborg <[email protected]>

When we introduced -rR then aic7xxx no loger could pick up definition of YACC&LEX from make - so do it explicit now.

---
 drivers/scsi/aic7xxx/aicasm/Makefile |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/scsi/aic7xxx/aicasm/Makefile +2 -0
index 8c91fda..b98c5c1 100644
@@ -14,6 +14,8 @@ LIBS=	-ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
 AICASM_CFLAGS:= -I/usr/include -I.
+LEX= flex
+YACC= bison
 YFLAGS= -d
 
 NOMAN=	noman
Signature · 1 line
1.4.1.rc2.gfc04
#2 lore raw

PATCH 1/1 kbuild: version.h and new headers_* targets does not require a kernel config

From: Sam Ravnborg <[email protected]>

---
 Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile +1 -0
index 7c010f3..60e09f2 100644
@@ -368,6 +368,7 @@ # of make so .config is not included in 
 
 no-dot-config-targets := clean mrproper distclean \
 			 cscope TAGS tags help %docs check% \
+			 include/linux/version.h headers_% \
 			 kernelrelease kernelversion
 
 config-targets := 0
Signature · 1 line
1.4.1.rc2.gfc04
#3 lore raw

PATCH 1/1 kbuild: .gitignore utsrelease.h

From: Sam Ravnborg <[email protected]>

---
 .gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
.gitignore +1 -0
index 27fd376..3f9bb5e 100644
@@ -30,6 +30,7 @@ include/config
 include/linux/autoconf.h
 include/linux/compile.h
 include/linux/version.h
+include/linux/utsrelease.h
 
 # stgit generated dirs
 patches-*
Signature · 1 line
1.4.1.rc2.gfc04
#4 lore raw

PATCH 1/1 kbuild: improve error from file2alias

From: Sam Ravnborg <[email protected]>

The original errormessage was just plain unreadable.

Sample error message after this update (not for real - I provoked it):

FATAL: drivers/net/s2io: sizeof(struct pci_device_id)=33 is not a modulo of the size of section __mod_pci_device_table=160.
Fix definition of struct pci_device_id in mod_devicetable.h

Before a warning was generated - this is now a fatal error.

---
 scripts/mod/file2alias.c |   62 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 19 deletions(-)
scripts/mod/file2alias.c +43 -19
index 37f67c2..4431292 100644
@@ -52,6 +52,23 @@ do {                                    
                 sprintf(str + strlen(str), "*");                \
 } while(0)
 
+/**
+ * Check that sizeof(device_id type) are consistent with size of section
+ * in .o file. If in-consistent then userspace and kernel does not agree
+ * on actual size which is a bug.
+ **/
+static void device_id_size_check(const char *modname, const char *device_id,
+				 unsigned long size, unsigned long id_size)
+{
+	if (size % id_size || size < id_size) {
+		fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
+		      "of the size of section __mod_%s_device_table=%lu.\n"
+		      "Fix definition of struct %s_device_id "
+		      "in mod_devicetable.h\n",
+		      modname, device_id, id_size, device_id, size, device_id);
+	}
+}
+
 /* USB is special because the bcdDevice can be matched against a numeric range */
 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
 static void do_usb_entry(struct usb_device_id *id,
@@ -152,10 +169,8 @@ static void do_usb_table(void *symval, u
 	unsigned int i;
 	const unsigned long id_size = sizeof(struct usb_device_id);
 
-	if (size % id_size || size < id_size) {
-		warn("%s ids %lu bad size "
-		     "(each on %lu)\n", mod->name, size, id_size);
-	}
+	device_id_size_check(mod->name, "usb", size, id_size);
+
 	/* Leave last one: it's the terminator. */
 	size -= id_size;
 
@@ -434,6 +449,7 @@ static inline int sym_is(const char *sym
 
 static void do_table(void *symval, unsigned long size,
 		     unsigned long id_size,
+		     const char *device_id,
 		     void *function,
 		     struct module *mod)
 {
@@ -441,10 +457,7 @@ static void do_table(void *symval, unsig
 	char alias[500];
 	int (*do_entry)(const char *, void *entry, char *alias) = function;
 
-	if (size % id_size || size < id_size) {
-		warn("%s ids %lu bad size "
-		     "(each on %lu)\n", mod->name, size, id_size);
-	}
+	device_id_size_check(mod->name, device_id, size, id_size);
 	/* Leave last one: it's the terminator. */
 	size -= id_size;
 
@@ -476,40 +489,51 @@ void handle_moddevtable(struct module *m
 		+ sym->st_value;
 
 	if (sym_is(symname, "__mod_pci_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct pci_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct pci_device_id), "pci",
 			 do_pci_entry, mod);
 	else if (sym_is(symname, "__mod_usb_device_table"))
 		/* special case to handle bcdDevice ranges */
 		do_usb_table(symval, sym->st_size, mod);
 	else if (sym_is(symname, "__mod_ieee1394_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct ieee1394_device_id), "ieee1394",
 			 do_ieee1394_entry, mod);
 	else if (sym_is(symname, "__mod_ccw_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct ccw_device_id), "ccw",
 			 do_ccw_entry, mod);
 	else if (sym_is(symname, "__mod_serio_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct serio_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct serio_device_id), "serio",
 			 do_serio_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct pnp_device_id), "pnp",
 			 do_pnp_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_card_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct pnp_card_device_id), "pnp_card",
 			 do_pnp_card_entry, mod);
 	else if (sym_is(symname, "__mod_pcmcia_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct pcmcia_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct pcmcia_device_id), "pcmcia",
 			 do_pcmcia_entry, mod);
         else if (sym_is(symname, "__mod_of_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct of_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct of_device_id), "of",
 			 do_of_entry, mod);
         else if (sym_is(symname, "__mod_vio_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct vio_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct vio_device_id), "vio",
 			 do_vio_entry, mod);
 	else if (sym_is(symname, "__mod_i2c_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct i2c_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct i2c_device_id), "i2c",
 			 do_i2c_entry, mod);
 	else if (sym_is(symname, "__mod_input_device_table"))
-		do_table(symval, sym->st_size, sizeof(struct input_device_id),
+		do_table(symval, sym->st_size,
+			 sizeof(struct input_device_id), "input",
 			 do_input_entry, mod);
 }
 
Signature · 1 line
1.4.1.rc2.gfc04
#5 lore raw

PATCH 1/1 kbuild: fix typo in modpost

From: Dave Jones <[email protected]>

Reported by a Fedora user when they tried to build some out of tree module..

---
 scripts/Makefile.modpost |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/Makefile.modpost +1 -1
index a495502..0a64688 100644
@@ -40,7 +40,7 @@ include scripts/Kbuild.include
 include scripts/Makefile.lib
 
 kernelsymfile := $(objtree)/Module.symvers
-modulesymfile := $(KBUILD_EXTMOD)/Modules.symvers
+modulesymfile := $(KBUILD_EXTMOD)/Module.symvers
 
 # Step 1), find all modules listed in $(MODVERDIR)/
 __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
Signature · 1 line
1.4.1.rc2.gfc04
#6 lore raw

PATCH 1/1 kbuild: -fno-stack-protector is not good

From: Sam Ravnborg <[email protected]>

Ubuntu gcc has hardcoded -fstack-protector - but does not understand -fno-stack-protector-all. So only try -fno-stack-protector.

---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index 60e09f2..07b8f34 100644
@@ -310,8 +310,8 @@ CPPFLAGS        := -D__KERNEL__ $(LINUXI
 CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                    -fno-strict-aliasing -fno-common
 # Force gcc to behave correct even for buggy distributions
-CFLAGS          += $(call cc-option, -fno-stack-protector-all \
-                                     -fno-stack-protector)
+CFLAGS          += $(call cc-option, -fno-stack-protector)
+
 AFLAGS          := -D__ASSEMBLY__
 
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
Signature · 1 line
1.4.1.rc2.gfc04
#7 lore raw

PATCH 1/1 kconfig: correct oldconfig for unset choice options

From: Roman Zippel <[email protected]>

oldconfig currently ignores unset choice options and doesn't ask for them. Correct the SYMBOL_DEF_USER flag of the choice symbol to be only set if it's set for all values.

---
 scripts/kconfig/confdata.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/kconfig/confdata.c +1 -1
index 2ee48c3..a69d8ac 100644
@@ -357,7 +357,7 @@ int conf_read(const char *name)
 		for (e = prop->expr; e; e = e->left.expr)
 			if (e->right.sym->visible != no)
 				flags &= e->right.sym->flags;
-		sym->flags |= flags & SYMBOL_DEF_USER;
+		sym->flags &= flags | ~SYMBOL_DEF_USER;
 	}
 
 	sym_change_count += conf_warnings || conf_unsaved;
Signature · 1 line
1.4.1.rc2.gfc04
#8 lore raw

PATCH 1/1 kconfig: support DOS line endings

From: Matthew Wilcox <[email protected]>

Kconfig doesn't currently handle config files with DOS line endings. While these are, of course, an abomination, etc, etc, it can be handy to not have to convert them first. It's also a tiny patch and even adds support for lines ending in just \r or even \n\r.

---
 scripts/kconfig/confdata.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c +6 -2
index a69d8ac..69f96b3 100644
@@ -193,8 +193,11 @@ load:
 				continue;
 			*p++ = 0;
 			p2 = strchr(p, '\n');
-			if (p2)
-				*p2 = 0;
+			if (p2) {
+				*p2-- = 0;
+				if (*p2 == '\r')
+					*p2 = 0;
+			}
 			if (def == S_DEF_USER) {
 				sym = sym_find(line + 7);
 				if (!sym) {
@@ -266,6 +269,7 @@ load:
 				;
 			}
 			break;
+		case '\r':
 		case '\n':
 			break;
 		default:
Signature · 1 line
1.4.1.rc2.gfc04
#9 lore raw

PATCH 1/1 kbuild: consistently decide when to rebuild a target

From: Sam Ravnborg <[email protected]>

Consistently decide when to rebuild a target across all of if_changed, if_changed_dep, if_changed_rule.
PHONY targets are now treated alike (ignored) for all targets

While add it make Kbuild.include almost readable by factoring out a few bits to some common variables and reuse this in Makefile.build.

---
 scripts/Kbuild.include |   52 ++++++++++++++++++++++++++++--------------------
 scripts/Makefile.build |    5 +++--
 usr/Makefile           |    2 ++
 3 files changed, 35 insertions(+), 24 deletions(-)
scripts/Kbuild.include +30 -22
index 2180c88..7a18353 100644
@@ -8,9 +8,13 @@ empty   :=
 space   := $(empty) $(empty)
 
 ###
+# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
+dot-target = $(dir $@).$(notdir $@)
+
+###
 # The temporary file to save gcc -MD generated dependencies must not
 # contain a comma
-depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
+depfile = $(subst $(comma),_,$(dot-target).d)
 
 ###
 # filename of target with directory and extension stripped
@@ -113,40 +117,44 @@ # See Documentation/kbuild/makefiles.txt
 ifneq ($(KBUILD_NOCMDDEP),1)
 # Check if both arguments has same arguments. Result in empty string if equal
 # User may override this check using make KBUILD_NOCMDDEP=1
-arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
+arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
+                    $(filter-out $(cmd_$@),   $(cmd_$(1))) )
 endif
 
 # echo command. Short version is $(quiet) equals quiet, otherwise full command
 echo-cmd = $(if $($(quiet)cmd_$(1)), \
 	echo '  $(call escsq,$($(quiet)cmd_$(1)))';)
 
+# >'< substitution is for echo to work,
+# >$< substitution to preserve $ when reloading .cmd file
+# note: when using inline perl scripts [perl -e '...$$t=1;...']
+# in $(cmd_xxx) double $$ your perl vars
 make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
 
-# function to only execute the passed command if necessary
-# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
-# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
+# Find any prerequisites that is newer than target or that does not exist.
+# PHONY targets skipped in both cases.
+any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
+
+# Execute command if command has changed or prerequisitei(s) are updated
 #
-if_changed = $(if $(strip $(filter-out $(PHONY),$?)          \
-		$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
-	@set -e; \
-	$(echo-cmd) $(cmd_$(1)); \
-	echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
+if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
+	@set -e;                                                             \
+	$(echo-cmd) $(cmd_$(1));                                             \
+	echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
 
 # execute the command and also postprocess generated .d dependencies
 # file
-if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?)  \
-		$(filter-out FORCE $(wildcard $^),$^)    \
-	$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),     \
-	@set -e; \
-	$(echo-cmd) $(cmd_$(1)); \
-	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
-	rm -f $(depfile); \
-	mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
+if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
+	@set -e;                                                             \
+	$(echo-cmd) $(cmd_$(1));                                             \
+	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
+	rm -f $(depfile);                                                    \
+	mv -f $(dot-target).tmp $(dot-target).cmd)
 
 # Usage: $(call if_changed_rule,foo)
 # will check if $(cmd_foo) changed, or any of the prequisites changed,
 # and if so will execute $(rule_foo)
-if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?)            \
-			$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
-			@set -e; \
-			$(rule_$(1)))
+if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
+	@set -e;                                                             \
+	$(rule_$(1)))
+
scripts/Makefile.build +3 -2
index 3cb445c..e2ad2dc 100644
@@ -191,9 +191,10 @@ define rule_cc_o_c
 	$(call echo-cmd,checksrc) $(cmd_checksrc)			  \
 	$(call echo-cmd,cc_o_c) $(cmd_cc_o_c);				  \
 	$(cmd_modversions)						  \
-	scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp;  \
+	scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
+	                                              $(dot-target).tmp;  \
 	rm -f $(depfile);						  \
-	mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
+	mv -f $(dot-target).tmp $(dot-target).cmd
 endef
 
 # Built-in and composite module parts
usr/Makefile +2 -0
index e938242..2c8f362 100644
@@ -3,6 +3,8 @@ # kbuild file for usr/ - including initr
 #
 
 klibcdirs:;
+PHONY += klibcdirs
+
 
 # Generate builtin.o based on initramfs_data.o
 obj-y := initramfs_data.o
Signature · 1 line
1.4.1.rc2.gfc04
#10 lore raw

Re: [PATCH] kbuild: hardcode value of YACC&LEX for aic7-triple-x

In reply to [email protected]
Quoted 6 lines · On Sat, Jul 29, 2006 at 09:19:33AM +0200, [email protected] wrote:

When we introduced -rR then aic7xxx no loger could pick up definition of YACC&LEX from make - so do it explicit now.

drivers/scsi/aic7xxx/aicasm/Makefile LIBS= -ldb · line 21

Quoted 8 lines
drivers/scsi/aic7xxx/aicasm/Makefile +2 -0
@@ -14,6 +14,8 @@ LIBS=	-ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
 AICASM_CFLAGS:= -I/usr/include -I.
+LEX= flex
+YACC= bison
 YFLAGS= -d
 
 NOMAN=	noman

SuSv3 lists "lex" and "yacc" as _the_ names. Is there any distro which doesn't install compat symlinks?

#11 lore raw

Re: [PATCH] kbuild: hardcode value of YACC&LEX for aic7-triple-x

Quoted 14 lines · Alexey Dobriyan
Quoted 13 lines · On Sat, Jul 29, 2006 at 09:19:33AM +0200, [email protected] wrote:

When we introduced -rR then aic7xxx no loger could pick up definition of YACC&LEX from make - so do it explicit now.

drivers/scsi/aic7xxx/aicasm/Makefile +2 -0
@@ -14,6 +14,8 @@ LIBS=	-ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
 AICASM_CFLAGS:= -I/usr/include -I.
+LEX= flex
+YACC= bison
 YFLAGS= -d
 
Quoted 4 lines

drivers/scsi/aic7xxx/aicasm/Makefile LIBS= -ldb · line 21

Quoted 1 line
drivers/scsi/aic7xxx/aicasm/Makefile +0 -0
 NOMAN=	noman

SuSv3 lists "lex" and "yacc" as _the_ names. Is there any distro which doesn't install compat symlinks?

Other places in kernel hardcode bison/flex so to be consistent aic7xxx does the same.

Sam

#12 lore raw

Re: [PATCH] kbuild: hardcode value of YACC&LEX for aic7-triple-x

Quoted 2 lines · Sam Ravnborg

Other places in kernel hardcode bison/flex so to be consistent aic7xxx does the same.

It would be better if this was centralized.

-hpa

#13 lore raw

Re: [PATCH] kbuild: hardcode value of YACC&LEX for aic7-triple-x

In reply to Alexey Dobriyan
Quoted 14 lines · Alexey Dobriyan
Quoted 13 lines · On Sat, Jul 29, 2006 at 09:19:33AM +0200, [email protected] wrote:

When we introduced -rR then aic7xxx no loger could pick up definition of YACC&LEX from make - so do it explicit now.

drivers/scsi/aic7xxx/aicasm/Makefile +2 -0
@@ -14,6 +14,8 @@ LIBS=	-ldb
 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
 # Override default kernel CFLAGS.  This is a userland app.
 AICASM_CFLAGS:= -I/usr/include -I.
+LEX= flex
+YACC= bison
 YFLAGS= -d
 
Quoted 5 lines

drivers/scsi/aic7xxx/aicasm/Makefile LIBS= -ldb · line 21

Quoted 1 line
drivers/scsi/aic7xxx/aicasm/Makefile +0 -0
 NOMAN=	noman

SuSv3 lists "lex" and "yacc" as _the_ names. Is there any distro which doesn't install compat symlinks?

At least on Red Hat/Fedora, "yacc" invokes BSD yacc, which produces worse code than bison.

-hpa