static char *
make_relative_path(char *path)
{
- char *relpath, *canon_path;
+ char *relpath, *canon_path, *path_suffix = NULL;
+ struct stat st;
- if (!base_dir || !str_startswith(path, base_dir)) {
+ if (str_eq(conf->base_dir, "") || !str_startswith(path, conf->base_dir)) {
return path;
}
return;
}
+ /* Check if the diagnostic file is there. */
+ if (output_dia && stat(cached_dia, &st) != 0) {
+ cc_log("Diagnostic file %s not in cache", cached_dia);
+ return;
+ }
+
+ /*
+ * Occasionally, e.g. on hard reset, our cache ends up as just filesystem
+ * meta-data with no content catch an easy case of this.
+ */
+ if (st.st_size == 0) {
+ cc_log("Invalid (empty) object file %s in cache", cached_obj);
+ x_unlink(cached_obj);
+ return;
+ }
+
/*
* (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by
* gcc.)
/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
- * Copyright (C) 2010, 2013 Joel Rosdahl
++ * Copyright (C) 2010, 2012-2013 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
{"-Xassembler", TAKES_ARG},
{"-Xclang", TAKES_ARG},
{"-Xlinker", TAKES_ARG},
- {"-Xpreprocessor", TOO_HARD_DIRECT | TAKES_ARG},
+ {"-Xpreprocessor", AFFECTS_CPP | TOO_HARD_DIRECT | TAKES_ARG},
+ {"-arch", TAKES_ARG},
{"-aux-info", TAKES_ARG},
{"-b", TAKES_ARG},
- {"-fbranch-probabilities", TOO_HARD},
- {"-fprofile-arcs", TOO_HARD},
- {"-fprofile-generate", TOO_HARD},
- {"-fprofile-use", TOO_HARD},
+ {"-fno-working-directory", AFFECTS_CPP},
{"-frepo", TOO_HARD},
- {"-ftest-coverage", TOO_HARD},
- {"-gsplit-dwarf", TOO_HARD},
+ {"-ftest-coverage", TOO_HARD}, /* generates a .gcno file at the same time */
+ {"-fworking-directory", AFFECTS_CPP},
++ {"-gsplit-dwarf", TOO_HARD}, /* generates a .dwo file at the same time */
{"-idirafter", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
{"-iframework", AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
{"-imacros", AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
TEST(sysroot_should_be_rewritten_if_basedir_is_used)
{
- extern char *base_dir;
extern char *current_working_dir;
- struct args *orig =
- args_init_from_string("cc --sysroot=/some/directory -c foo.c");
+ char *arg_string;
+ struct args *orig;
struct args *act_cpp = NULL, *act_cc = NULL;
- create_file("foo.c", "");
-
- CHECK(cc_process_args(orig, &act_cpp, &act_cc));
- CHECK_STR_EQ("--sysroot=/some/directory", act_cpp->argv[1]);
- args_free(act_cpp);
- args_free(act_cc);
- cc_reset();
- conf->base_dir = x_strdup("/some");
+ create_file("foo.c", "");
+ free(conf->base_dir);
++ conf->base_dir = x_strdup("/");
current_working_dir = get_cwd();
- base_dir = "/";
-
+ arg_string = format("cc --sysroot=%s/foo -c foo.c", current_working_dir);
+ orig = args_init_from_string(arg_string);
+
CHECK(cc_process_args(orig, &act_cpp, &act_cc));
- CHECK(str_startswith(act_cpp->argv[1], "--sysroot=../"));
+ CHECK(str_startswith(act_cpp->argv[1], "--sysroot=./foo"));
+
args_free(orig);
- base_dir = NULL;
- current_working_dir = NULL;
+ args_free(act_cpp);
+ args_free(act_cc);
}
TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
/*
- * Copyright (C) 2010-2012 Joel Rosdahl
- * Copyright (C) 2010, 2012-2013 Joel Rosdahl
++ * Copyright (C) 2010-2013 Joel Rosdahl
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free