Index: lld/test/ELF/lto/emit-llvm_assertion_failure.ll =================================================================== --- /dev/null +++ lld/test/ELF/lto/emit-llvm_assertion_failure.ll @@ -0,0 +1,14 @@ +; Make sure that if --plugin-opt=emit-llvm is enabled and the output +; is /dev/null, it should not cause a assertion failure in bitcode writer. + +; REQUIRES: x86 + +; RUN: opt -module-hash -module-summary %s -o %t.o +; RUN: ld.lld --plugin-opt=emit-llvm -mllvm -bitcode-flush-threshold=0 -o /dev/null %t.o + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @main() { + ret void +} Index: llvm/lib/Support/raw_ostream.cpp =================================================================== --- llvm/lib/Support/raw_ostream.cpp +++ llvm/lib/Support/raw_ostream.cpp @@ -914,8 +914,9 @@ if (EC) return; - // Do not support non-seekable files. - if (!supportsSeeking()) + sys::fs::file_status Status; + EC = status(get_fd(), Status); + if (EC || Status.type() != sys::fs::file_type::regular_file) EC = std::make_error_code(std::errc::invalid_argument); }