diff --git a/driver/main.c b/driver/main.c index 96997d437..d53e3ab4c 100644 --- a/driver/main.c +++ b/driver/main.c @@ -967,6 +967,15 @@ int main(int argc, char **argv) fclose(defines_file); defines_file = 0; + /* If we are planning on opening a dependencies file, then + open and truncate it here. The other phases of compilation + will append to the file, so this is necessray to make sure + it starts out empty. */ + if (depfile) { + FILE*fd = fopen(depfile, "w"); + fclose(fd); + } + if (source_count == 0 && !version_flag) { fprintf(stderr, "%s: no source files.\n\n%s\n", argv[0], HELP); return 1; diff --git a/ivlpp/main.c b/ivlpp/main.c index 5a3e3ee84..df9d1b811 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -363,7 +363,7 @@ int main(int argc, char*argv[]) } if(dep_path) { - depend_file = fopen(dep_path, "w"); + depend_file = fopen(dep_path, "a"); if (depend_file == 0) { perror(dep_path); exit(1); diff --git a/load_module.cc b/load_module.cc index 862d205be..e8606e628 100644 --- a/load_module.cc +++ b/load_module.cc @@ -73,6 +73,7 @@ bool load_module(const char*type) if(depend_file) { fprintf(depend_file, "%s\n", path); + fflush(depend_file); } if (ivlpp_string) {