ResultRetriever::on_entry_data assumes that a destination file has been
opened if the entry type is not stderr_output, but that’s incorrect
since on_entry_start doesn’t open a destination file if it’s /dev/null.
An assertion is triggered:
ccache: ResultRetriever.cpp:129: virtual void
ResultRetriever::on_entry_data(const uint8_t *, size_t): failed
assertion: (m_dest_file_type == FileType::stderr_output &&
!m_dest_fd) || (m_dest_file_type != FileType::stderr_output &&
m_dest_fd)
Fix this by letting on_entry_data handle the “destination file not
opened” case and correcting the assert.
Fixes #752.
void
ResultRetriever::on_entry_data(const uint8_t* data, size_t size)
{
- ASSERT((m_dest_file_type == FileType::stderr_output && !m_dest_fd)
- || (m_dest_file_type != FileType::stderr_output && m_dest_fd));
+ ASSERT(!(m_dest_file_type == FileType::stderr_output && m_dest_fd));
if (m_dest_file_type == FileType::stderr_output
|| (m_dest_file_type == FileType::dependency && !m_dest_path.empty())) {
m_dest_data.append(reinterpret_cast<const char*>(data), size);
- } else {
+ } else if (m_dest_fd) {
try {
Util::write_fd(*m_dest_fd, data, size);
} catch (Error& e) {
CCACHE_PREFIX=`pwd`/empty-object-prefix $CCACHE_COMPILE -c test_empty_obj.c
expect_stat 'compiler produced empty output' 1
+ # -------------------------------------------------------------------------
+ TEST "Output to /dev/null"
+
+ $CCACHE_COMPILE -c test1.c
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+
+ $CCACHE_COMPILE -c test1.c -o /dev/null
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+
# -------------------------------------------------------------------------
TEST "Caching stderr"