MTR_BEGIN("file", "file_put");
- put_file_in_cache(output_obj, cached_obj);
if (produce_dep_file) {
copy_file_to_cache(output_dep, cached_dep);
}
if (generating_coverage) {
- copy_file_to_cache(output_cov, cached_cov);
+ if (stat(output_cov, &st) == 0) {
+ copy_file_to_cache(output_cov, cached_cov);
+ } else {
+ // The .gcno file is missing. This is likely due to compiling with GCC 9+,
+ // which uses another name for the .gcno file when using -ftest-coverage
+ // or --coverage when -fprofile-dir=dir is given. The .gcno file is still
+ // placed next to the object file, not in the specified profile directory,
+ // though.
+ cc_log("%s is missing", output_cov);
+ stats_update(STATS_UNSUPPORTED_OPTION);
+ failed();
+ }
}
if (generating_stackusage) {
copy_file_to_cache(output_su, cached_su);
if (using_split_dwarf) {
copy_file_to_cache(output_dwo, cached_dwo);
}
+ put_file_in_cache(output_obj, cached_obj);
MTR_END("file", "file_put");
int compress_level,
bool via_tmp_file)
{
- int fd_out;
+ int fd_out = -1;
char *tmp_name = NULL;
gzFile gz_in = NULL;
gzFile gz_out = NULL;
int saved_errno = 0;
+ // Open source file.
+ int fd_in = open(src, O_RDONLY | O_BINARY);
+ if (fd_in == -1) {
+ saved_errno = errno;
+ cc_log("open error: %s", strerror(saved_errno));
+ goto error;
+ }
+
// Open destination file.
if (via_tmp_file) {
tmp_name = x_strdup(dest);
src, dest, compress_level > 0 ? "" : "un");
}
- // Open source file.
- int fd_in = open(src, O_RDONLY | O_BINARY);
- if (fd_in == -1) {
- saved_errno = errno;
- cc_log("open error: %s", strerror(saved_errno));
- goto error;
- }
-
gz_in = gzdopen(fd_in, "rb");
if (!gz_in) {
saved_errno = errno;
if (fd_out != -1) {
close(fd_out);
}
- if (via_tmp_file) {
+ if (via_tmp_file && tmp_name) {
tmp_unlink(tmp_name);
free(tmp_name);
}