summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-10-19 22:13:21 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-10-19 22:27:34 +0200
commitb53afeb556d55576ed3683fef6566361464393d5 (patch)
treeb2fd2c70426ed52050b9fef1cac2d653c558ee9f /src/core
parent567a1f3c940c881b0718d4b06a04bc2f7f6b5246 (diff)
downloadccache-b53afeb556d55576ed3683fef6566361464393d5.tar.gz
fix: Handle -MD/-MMD when compiling assembler file
When compiling an assembler file, -MD and -MMD don't produce any dependency file, so don't expect one. Also, make sure to fall back to running the real compiler in case an expected output file is missing instead of exiting with an error. Fixes #1189.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Result.cpp9
-rw-r--r--src/core/Result.hpp2
-rw-r--r--src/core/Statistics.cpp6
3 files changed, 11 insertions, 6 deletions
diff --git a/src/core/Result.cpp b/src/core/Result.cpp
index 079923eb..c1f84c64 100644
--- a/src/core/Result.cpp
+++ b/src/core/Result.cpp
@@ -242,14 +242,19 @@ Serializer::add_data(const FileType file_type, nonstd::span<const uint8_t> data)
m_file_entries.push_back(FileEntry{file_type, data});
}
-void
+bool
Serializer::add_file(const FileType file_type, const std::string& path)
{
m_serialized_size += 1 + 1 + 8; // marker + file_type + file_size
if (!should_store_raw_file(m_config, file_type)) {
- m_serialized_size += Stat::stat(path, Stat::OnError::throw_error).size();
+ auto st = Stat::stat(path);
+ if (!st) {
+ return false;
+ }
+ m_serialized_size += st.size();
}
m_file_entries.push_back(FileEntry{file_type, path});
+ return true;
}
uint32_t
diff --git a/src/core/Result.hpp b/src/core/Result.hpp
index 92301e16..3080f719 100644
--- a/src/core/Result.hpp
+++ b/src/core/Result.hpp
@@ -142,7 +142,7 @@ public:
void add_data(FileType file_type, nonstd::span<const uint8_t> data);
// Register a file path whose content should be included in the result.
- void add_file(FileType file_type, const std::string& path);
+ [[nodiscard]] bool add_file(FileType file_type, const std::string& path);
// core::Serializer
uint32_t serialized_size() const override;
diff --git a/src/core/Statistics.cpp b/src/core/Statistics.cpp
index 4952ce20..662b59ba 100644
--- a/src/core/Statistics.cpp
+++ b/src/core/Statistics.cpp
@@ -76,12 +76,12 @@ const StatisticsField k_statistics_fields[] = {
FIELD(cleanups_performed, nullptr),
FIELD(compile_failed, "Compilation failed", FLAG_UNCACHEABLE),
FIELD(compiler_check_failed, "Compiler check failed", FLAG_ERROR),
+ FIELD(compiler_produced_no_output,
+ "Compiler output file missing",
+ FLAG_UNCACHEABLE),
FIELD(compiler_produced_empty_output,
"Compiler produced empty output",
FLAG_UNCACHEABLE),
- FIELD(compiler_produced_no_output,
- "Compiler produced no output",
- FLAG_UNCACHEABLE),
FIELD(compiler_produced_stdout, "Compiler produced stdout", FLAG_UNCACHEABLE),
FIELD(could_not_find_compiler, "Could not find compiler", FLAG_ERROR),
FIELD(could_not_use_modules, "Could not use modules", FLAG_UNCACHEABLE),