]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kbuild: soften modpost checks when doing cross builds
authorSam Ravnborg <sam@uranus.ravnborg.org>
Tue, 25 Mar 2008 02:40:08 +0000 (02:40 +0000)
committerChris Wright <chrisw@sous-sol.org>
Sat, 19 Apr 2008 01:53:18 +0000 (18:53 -0700)
upstream commit: 4ce6efed48d736e3384c39ff87bda723e1f8e041

The module alias support in the kernel have a consistency
check where it is checked that the size of a structure
in the kernel and on the build host are the same.
For cross builds this check does not make sense so detect
when we do cross builds and silently skip the check in these
situations.
This fixes a build bug for a wireless driver when cross building
for arm.

Acked-by: Michael Buesch <mb@bu3sch.de>
Tested-by: Gordon Farquharson <gordonfarquharson@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
[chrisw@sous-sol.org: backport to 2.6.24.4]
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Makefile
scripts/Makefile.modpost
scripts/mod/file2alias.c
scripts/mod/modpost.c
scripts/mod/modpost.h

index 254de79dbff5bf87d5a2f4b876079bc9d178b365..234ac6086986f5f1655cf0fd715a03788b62f211 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -189,7 +189,7 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 # Alternatively CROSS_COMPILE can be set in the environment.
 # Default value for CROSS_COMPILE is not to prefix executables
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
-
+export KBUILD_BUILDHOST := $(SUBARCH)
 ARCH           ?= $(SUBARCH)
 CROSS_COMPILE  ?=
 
index d988f5d21e3df12b50e31b9eac86bc21e82b867c..f6b332cc7cca12b220dc257239a26803a83d85fe 100644 (file)
@@ -53,6 +53,9 @@ modules   := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
 # Stop after building .o files if NOFINAL is set. Makes compile tests quicker
 _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
 
+ifneq ($(KBUILD_BUILDHOST),$(ARCH))
+        cross_build := 1
+endif
 
 # Step 2), invoke modpost
 #  Includes step 3,4
@@ -62,7 +65,8 @@ modpost = scripts/mod/modpost                    \
  $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile)   \
  $(if $(KBUILD_EXTMOD),-I $(modulesymfile))      \
  $(if $(KBUILD_EXTMOD),-o $(modulesymfile))      \
- $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
+ $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
+ $(if $(cross_build),-c)
 
 quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
       cmd_modpost = $(modpost) -s
index 9ddf944cce290b7d38fc2982b852bc93d4c50001..348d8687b7c9cad167c6d631ce9e5f1c2038bdf0 100644 (file)
@@ -51,11 +51,13 @@ do {                                                            \
                 sprintf(str + strlen(str), "*");                \
 } while(0)
 
+unsigned int cross_build = 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.
  * Also verify that the final entry in the table is all zeros.
+ * Ignore both checks if build host differ from target host and size differs.
  **/
 static void device_id_check(const char *modname, const char *device_id,
                            unsigned long size, unsigned long id_size,
@@ -64,6 +66,8 @@ static void device_id_check(const char *modname, const char *device_id,
        int i;
 
        if (size % id_size || size < id_size) {
+               if (cross_build != 0)
+                       return;
                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 "
index 93ac52adb4980b3d23a0b40acd6800e48f75b349..a99001102d15eed25de6f148146daf3e0ce4ad99 100644 (file)
@@ -1659,7 +1659,7 @@ int main(int argc, char **argv)
        int opt;
        int err;
 
-       while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) {
+       while ((opt = getopt(argc, argv, "i:I:cmso:aw")) != -1) {
                switch(opt) {
                        case 'i':
                                kernel_read = optarg;
@@ -1668,6 +1668,9 @@ int main(int argc, char **argv)
                                module_read = optarg;
                                external_module = 1;
                                break;
+               case 'c':
+                       cross_build = 1;
+                       break;
                        case 'm':
                                modversions = 1;
                                break;
index 0ffed17ec20ca2037be0d8bf1467477c912952e3..b50e3c90fa3e47dba06af1b20b85991fac1580b7 100644 (file)
@@ -130,6 +130,7 @@ struct elf_info {
 };
 
 /* file2alias.c */
+extern unsigned int cross_build;
 void handle_moddevtable(struct module *mod, struct elf_info *info,
                        Elf_Sym *sym, const char *symname);
 void add_moddevtable(struct buffer *buf, struct module *mod);