* 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
+ 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
produces standard error output.
if (output_is_precompiled_header) {
output_obj = format("%s.gch", input_file);
} else {
+ char extension = found_S_opt ? 's' : 'o';
output_obj = basename(input_file);
char *p = strrchr(output_obj, '.');
- if (!p || !p[1]) {
- cc_log("Badly formed object filename");
- stats_update(STATS_ARGS);
- result = false;
- goto out;
+ if (!p) {
+ reformat(&output_obj, "%s.%c", output_obj, extension);
+ } else if (!p[1]) {
+ reformat(&output_obj, "%s%c", output_obj, extension);
+ } else {
+ p[1] = extension;
+ p[2] = 0;
}
- p[1] = found_S_opt ? 's' : 'o';
- p[2] = 0;
}
}
$CCACHE_COMPILE -c -O2 2>/dev/null
expect_stat 'no input file' 1
+ # -------------------------------------------------------------------------
+ TEST "No file extension"
+
+ mkdir src
+ touch src/foo
+
+ $CCACHE_COMPILE -x c -c src/foo
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.o
+ rm foo.o
+
+ $CCACHE_COMPILE -x c -c src/foo
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.o
+ rm foo.o
+
+ rm -rf src
+
+ # -------------------------------------------------------------------------
+ TEST "Source file ending with dot"
+
+ mkdir src
+ touch src/foo.
+
+ $CCACHE_COMPILE -x c -c src/foo.
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.o
+ rm foo.o
+
+ $CCACHE_COMPILE -x c -c src/foo.
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.o
+ rm foo.o
+
+ rm -rf src
+
+ # -------------------------------------------------------------------------
+ TEST "Multiple file extensions"
+
+ mkdir src
+ touch src/foo.c.c
+
+ $CCACHE_COMPILE -c src/foo.c.c
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.c.o
+ rm foo.c.o
+
+ $CCACHE_COMPILE -c src/foo.c.c
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+ expect_file_exists foo.c.o
+ rm foo.c.o
+
+ rm -rf src
+
# -------------------------------------------------------------------------
TEST "LANG"