* Compilations with /dev/null as the input file are now cached.
-* ccache now knows how to contruct the object filename if no “-o” option is
+* ccache now knows how to contruct the object filename if no `-o` option is
given and the source filename does not include a `.` or ends with a `.`.
* Fixed a temporary file leak when depend mode is enabled and the compiler
* Added a new `--print-stats` command that prints statistics counters in
machine-parsable (tab-separated) format.
+* ccache no longer creates a missing output directory, thus mimicking the
+ compiler behavior for `-o out/obj.o` when “out” doesn’t exist.
+
ccache 3.6
----------
&& stat(output_obj, &st) == 0
&& !S_ISREG(st.st_mode)) {
cc_log("Not a regular file: %s", output_obj);
- stats_update(STATS_DEVICE);
+ stats_update(STATS_BADOUTPUTFILE);
result = false;
goto out;
}
+ char *output_dir = dirname(output_obj);
+ if (stat(output_dir, &st) != 0 || !S_ISDIR(st.st_mode)) {
+ cc_log("Directory does not exist: %s", output_dir);
+ stats_update(STATS_BADOUTPUTFILE);
+ result = false;
+ free(output_dir);
+ goto out;
+ }
+ free(output_dir);
+
// Some options shouldn't be passed to the real compiler when it compiles
// preprocessed code:
//
STATS_OBSOLETE_MAXFILES = 13,
STATS_OBSOLETE_MAXSIZE = 14,
STATS_SOURCELANG = 15,
- STATS_DEVICE = 16,
+ STATS_BADOUTPUTFILE = 16,
STATS_NOINPUT = 17,
STATS_MULTIPLE = 18,
STATS_CONFTEST = 19,
0
},
{
- STATS_DEVICE,
- "output_to_a_non_file",
- "output to a non-regular file",
+ STATS_BADOUTPUTFILE,
+ "bad_output_file",
+ "could not write to output file",
NULL,
0
},
expect_stat 'compiler produced stdout' 1
# -------------------------------------------------------------------------
- TEST "Output to a non-regular file"
+ TEST "Output to directory"
mkdir testd
$CCACHE_COMPILE -o testd -c test1.c >/dev/null 2>&1
rmdir testd >/dev/null 2>&1
- expect_stat 'output to a non-regular file' 1
+ expect_stat 'could not write to output file' 1
+
+ # -------------------------------------------------------------------------
+ TEST "Output to file in nonexistent directory"
+
+ mkdir out
+
+ $CCACHE_COMPILE -c test1.c -o out/foo.o
+ expect_stat 'could not write to output file' ""
+ expect_stat 'cache miss' 1
+
+ rm -rf out
+
+ $CCACHE_COMPILE -c test1.c -o out/foo.o 2>/dev/null
+ expect_stat 'could not write to output file' 1
+ expect_stat 'cache miss' 1
+ expect_file_missing out/foo.o
# -------------------------------------------------------------------------
TEST "No input file"