Summary
In compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp, the function LLVMRustWriteOutputFile calls EC.clear() immediately after constructing the DWO output stream, before checking whether the file open succeeded. This makes the subsequent if (EC) check dead code.
Location
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp, line 484 (on current main at f428d12)
Bug
auto DOS = raw_fd_ostream(DwoPath, EC, sys::fs::OF_None);
EC.clear(); // BUG: clears error before checking it
if (EC) // DEAD CODE: EC is always clear here
ErrorInfo = EC.message();
EC.clear() unconditionally resets the std::error_code to success. The if (EC) on the next line will never be true. If the DWO output file cannot be opened (bad path, permission denied, full disk), the error is silently swallowed.
Compare with the correctly-checked primary output file 8 lines above:
auto OS = raw_fd_ostream(Path, EC, sys::fs::OF_None);
if (EC) // Correct: no EC.clear() before this
ErrorInfo = EC.message();
Impact
When -Csplit-debuginfo=unpacked is used and the DWO output path is invalid, rustc succeeds with no error but produces missing or corrupted .dwo split-DWARF debug info files.
Fix
Remove the EC.clear(); line. The error check pattern should match the primary output file path above it.
Summary
In
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp, the functionLLVMRustWriteOutputFilecallsEC.clear()immediately after constructing the DWO output stream, before checking whether the file open succeeded. This makes the subsequentif (EC)check dead code.Location
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp, line 484 (on current main at f428d12)Bug
EC.clear()unconditionally resets thestd::error_codeto success. Theif (EC)on the next line will never be true. If the DWO output file cannot be opened (bad path, permission denied, full disk), the error is silently swallowed.Compare with the correctly-checked primary output file 8 lines above:
Impact
When
-Csplit-debuginfo=unpackedis used and the DWO output path is invalid, rustc succeeds with no error but produces missing or corrupted.dwosplit-DWARF debug info files.Fix
Remove the
EC.clear();line. The error check pattern should match the primary output file path above it.