Skip to content

Commit b7bd182

Browse files
committed
fixdep: Do not record dependency on the source file itself
The dependency is already expressed by the Makefiles, storing it in the .cmd file breaks build if a .c file is replaced by .S or vice versa, because the .cmd file contains foo/bar.o: foo/bar.c ... foo/bar.c ... : so the foo/bar.c -> foo/bar.o rule triggers even if there is no foo/bar.c anymore. Acked-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 0f54088 commit b7bd182

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

scripts/basic/fixdep.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ static void parse_dep_file(void *map, size_t len)
315315
char *end = m + len;
316316
char *p;
317317
char s[PATH_MAX];
318+
int first;
318319

319320
p = strchr(m, ':');
320321
if (!p) {
@@ -327,6 +328,7 @@ static void parse_dep_file(void *map, size_t len)
327328

328329
clear_config();
329330

331+
first = 1;
330332
while (m < end) {
331333
while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
332334
m++;
@@ -340,9 +342,17 @@ static void parse_dep_file(void *map, size_t len)
340342
if (strrcmp(s, "include/generated/autoconf.h") &&
341343
strrcmp(s, "arch/um/include/uml-config.h") &&
342344
strrcmp(s, ".ver")) {
343-
printf(" %s \\\n", s);
345+
/*
346+
* Do not output the first dependency (the
347+
* source file), so that kbuild is not confused
348+
* if a .c file is rewritten into .S or vice
349+
* versa.
350+
*/
351+
if (!first)
352+
printf(" %s \\\n", s);
344353
do_config_file(s);
345354
}
355+
first = 0;
346356
m = p + 1;
347357
}
348358
printf("\n%s: $(deps_%s)\n\n", target, target);

0 commit comments

Comments
 (0)