Commit eed380f3f5933edb8f4c055ba34ae7908ed38565

Authored by Guenter Roeck
Committed by Rusty Russell
1 parent 3f2b9c9cdf

modpost: Optionally ignore secondary errors seen if a single module build fails

Commit ea4054a23 (modpost: handle huge numbers of modules) added
support for building a large number of modules.

Unfortunately, the commit changed the semantics of the makefile: Instead of
passing only existing object files to modpost, make now passes all expected
object files. If make was started with option -i, this results in a modpost
error if a single file failed to build.

Example with the current btrfs build falure on m68k:

fs/btrfs/btrfs.o: No such file or directory
make[1]: [__modpost] Error 1 (ignored)

This error is followed by lots of errors such as:

m68k-linux-gcc: error: arch/m68k/emu/nfcon.mod.c: No such file or directory
m68k-linux-gcc: fatal error: no input files
compilation terminated.
make[1]: [arch/m68k/emu/nfcon.mod.o] Error 1 (ignored)

This doesn't matter much for normal builds, but it is annoying for builds
started with "make -i" due to the large number of secondary errors.
Those errors unnececessarily clog any error log and make it difficult
to find the real errors in the build.

Fix the problem by adding a new parameter '-n' to modpost. If this parameter
is specified, modpost reports but ignores missing object files.

With this patch, error output from above problem is (with make -i):

m68k-linux-ld: cannot find fs/btrfs/ioctl.o: No such file or directory
make[2]: [fs/btrfs/btrfs.o] Error 1 (ignored)
...
fs/btrfs/btrfs.o: No such file or directory (ignored)

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael Marek <mmarek@suse.cz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Showing 2 changed files with 15 additions and 2 deletions Side-by-side Diff

scripts/Makefile.modpost
... ... @@ -79,9 +79,11 @@
79 79 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
80 80 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
81 81  
  82 +MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
  83 +
82 84 # We can go over command line length here, so be careful.
83 85 quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
84   - cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) -s -T -
  86 + cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) $(MODPOST_OPT) -s -T -
85 87  
86 88 PHONY += __modpost
87 89 __modpost: $(modules:.ko=.o) FORCE
scripts/mod/modpost.c
... ... @@ -17,6 +17,7 @@
17 17 #include <string.h>
18 18 #include <limits.h>
19 19 #include <stdbool.h>
  20 +#include <errno.h>
20 21 #include "modpost.h"
21 22 #include "../../include/generated/autoconf.h"
22 23 #include "../../include/linux/license.h"
... ... @@ -37,6 +38,8 @@
37 38 /* How a symbol is exported */
38 39 static int sec_mismatch_count = 0;
39 40 static int sec_mismatch_verbose = 1;
  41 +/* ignore missing files */
  42 +static int ignore_missing_files;
40 43  
41 44 enum export {
42 45 export_plain, export_unused, export_gpl,
... ... @@ -407,6 +410,11 @@
407 410  
408 411 hdr = grab_file(filename, &info->size);
409 412 if (!hdr) {
  413 + if (ignore_missing_files) {
  414 + fprintf(stderr, "%s: %s (ignored)\n", filename,
  415 + strerror(errno));
  416 + return 0;
  417 + }
410 418 perror(filename);
411 419 exit(1);
412 420 }
... ... @@ -2119,7 +2127,7 @@
2119 2127 struct ext_sym_list *extsym_iter;
2120 2128 struct ext_sym_list *extsym_start = NULL;
2121 2129  
2122   - while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) {
  2130 + while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) {
2123 2131 switch (opt) {
2124 2132 case 'i':
2125 2133 kernel_read = optarg;
... ... @@ -2138,6 +2146,9 @@
2138 2146 break;
2139 2147 case 'm':
2140 2148 modversions = 1;
  2149 + break;
  2150 + case 'n':
  2151 + ignore_missing_files = 1;
2141 2152 break;
2142 2153 case 'o':
2143 2154 dump_write = optarg;