Commit 7840fea2 authored by Michal Marek's avatar Michal Marek Committed by Linus Torvalds

kbuild: Fix computing srcversion for modules

Recent change to fixdep:

    commit b7bd1821
    Author: Michal Marek <mmarek@suse.cz>
    Date:   Thu Feb 17 15:13:54 2011 +0100

    fixdep: Do not record dependency on the source file itself

changed the format of the *.cmd files without realizing that it is also
used by modpost. Put the path to the source file to the file back, in a
special variable, so that modpost sees all source files when calculating
srcversion for modules.
Reported-and-tested-by: default avatarHenrik Rydberg <rydberg@euromail.se>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e8444a3e
...@@ -309,6 +309,11 @@ static void do_config_file(const char *filename) ...@@ -309,6 +309,11 @@ static void do_config_file(const char *filename)
close(fd); close(fd);
} }
/*
* Important: The below generated source_foo.o and deps_foo.o variable
* assignments are parsed not only by make, but also by the rather simple
* parser in scripts/mod/sumversion.c.
*/
static void parse_dep_file(void *map, size_t len) static void parse_dep_file(void *map, size_t len)
{ {
char *m = map; char *m = map;
...@@ -323,7 +328,6 @@ static void parse_dep_file(void *map, size_t len) ...@@ -323,7 +328,6 @@ static void parse_dep_file(void *map, size_t len)
exit(1); exit(1);
} }
memcpy(s, m, p-m); s[p-m] = 0; memcpy(s, m, p-m); s[p-m] = 0;
printf("deps_%s := \\\n", target);
m = p+1; m = p+1;
clear_config(); clear_config();
...@@ -343,12 +347,15 @@ static void parse_dep_file(void *map, size_t len) ...@@ -343,12 +347,15 @@ static void parse_dep_file(void *map, size_t len)
strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "arch/um/include/uml-config.h") &&
strrcmp(s, ".ver")) { strrcmp(s, ".ver")) {
/* /*
* Do not output the first dependency (the * Do not list the source file as dependency, so that
* source file), so that kbuild is not confused * kbuild is not confused if a .c file is rewritten
* if a .c file is rewritten into .S or vice * into .S or vice versa. Storing it in source_* is
* versa. * needed for modpost to compute srcversions.
*/ */
if (!first) if (first) {
printf("source_%s := %s\n\n", target, s);
printf("deps_%s := \\\n", target);
} else
printf(" %s \\\n", s); printf(" %s \\\n", s);
do_config_file(s); do_config_file(s);
} }
......
...@@ -300,8 +300,8 @@ static int is_static_library(const char *objfile) ...@@ -300,8 +300,8 @@ static int is_static_library(const char *objfile)
return 0; return 0;
} }
/* We have dir/file.o. Open dir/.file.o.cmd, look for deps_ line to /* We have dir/file.o. Open dir/.file.o.cmd, look for source_ and deps_ line
* figure out source file. */ * to figure out source files. */
static int parse_source_files(const char *objfile, struct md4_ctx *md) static int parse_source_files(const char *objfile, struct md4_ctx *md)
{ {
char *cmd, *file, *line, *dir; char *cmd, *file, *line, *dir;
...@@ -340,6 +340,21 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) ...@@ -340,6 +340,21 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
*/ */
while ((line = get_next_line(&pos, file, flen)) != NULL) { while ((line = get_next_line(&pos, file, flen)) != NULL) {
char* p = line; char* p = line;
if (strncmp(line, "source_", sizeof("source_")-1) == 0) {
p = strrchr(line, ' ');
if (!p) {
warn("malformed line: %s\n", line);
goto out_file;
}
p++;
if (!parse_file(p, md)) {
warn("could not open %s: %s\n",
p, strerror(errno));
goto out_file;
}
continue;
}
if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) { if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
check_files = 1; check_files = 1;
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment