Index: lld/ELF/LTO.cpp =================================================================== --- lld/ELF/LTO.cpp +++ lld/ELF/LTO.cpp @@ -62,6 +62,10 @@ // flush buffered data to reduce memory consumption. If this fails, open a file // stream that supports only write. static std::unique_ptr openLTOOutputFile(StringRef file) { + // Don't flush bitcode incrementally if the output is a special file. + // This handles things like '-o /dev/null' + if (!sys::fs::is_regular_file(file)) + return openFile(file); std::error_code ec; std::unique_ptr fs = std::make_unique(file, ec);