ICE when target directory doesn’t exist for LLVM outputs #21335
Closed
Description
MAKE SURE TO NOT RUN THE COMMANDS IN DIRECTORY WITH ANYTHING NAMED target
OR test.rs
OTHERWISE YOU’LL LOSE DATA
llvm-bc (does not ICE anymore as reported below):
$ bash -c "rm -rf target/ && echo 'fn main(){}' > test.rs && RUST_BACKTRACE=1 rustc test.rs --out-dir=target/ --emit=llvm-bc"
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: IoError { kind: MismatchedFileTypeForOperation, desc: "couldn\'t copy path", detail: Some("the source path is not an existing file; from=target/test.0.bc; to=target/test.bc") }', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:746
stack backtrace:
1: 0x7f311266b000 - sys::backtrace::write::h7e8ba1fc274cc36epRt
2: 0x7f311268c9e0 - failure::on_fail::h823798930ebe140a64z
3: 0x7f31125fb7b0 - rt::unwind::begin_unwind_inner::ha4a8df6010104da6ZJz
4: 0x7f31125fc2e0 - rt::unwind::begin_unwind_fmt::hb2e27604ce994736wIz
5: 0x7f311268c840 - rust_begin_unwind
6: 0x7f31126d5390 - panicking::panic_fmt::h534fa48d94caaacevym
7: 0x7f3111605f40 - back::write::run_passes::unboxed_closure.37089
8: 0x7f31115fe350 - back::write::run_passes::h8ff6c36249e9879aIFc
9: 0x7f3112bcba20 - driver::phase_5_run_llvm_passes::h30b9e967ab9e3034PNa
10: 0x7f3112baad70 - driver::compile_input::h8ec974b2bd4afe59Aba
11: 0x7f3112c6c4d0 - run_compiler::h0e495a7c10e57aaae5b
12: 0x7f3112c6ac40 - thunk::F.Invoke<A, R>::invoke::h12226774702741163622
13: 0x7f3112c69ba0 - rt::unwind::try::try_fn::h67848939709837360
14: 0x7f31126f3b90 - rust_try_inner
15: 0x7f31126f3b80 - rust_try
16: 0x7f3112c69e50 - thunk::F.Invoke<A, R>::invoke::h15720675569063176780
17: 0x7f311267a680 - sys::thread::thread_start::h2ac456e96ea03cedcJw
18: 0x7f310caa3250 - start_thread
19: 0x7f31122ac219 - clone
20: 0x0 - <unknown>
llvm-ir:
$ bash -c "rm -rf target/ && echo 'fn main(){}' > test.rs && rustc test.rs --out-dir=target/ --emit=llvm-ir"
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/Support/raw_ostream.cpp:637: virtual size_t llvm::raw_fd_ostream::preferred_buffer_size() const: Assertion `FD >= 0 && "File not yet open!"' failed.
bash: line 1: 30752 Aborted (core dumped) rustc test.rs --out-dir=target/ --emit=llvm-ir
gdb backtrace (for the relevant thread):
#0 0x00007ffff7123a97 in raise () from /usr/lib/libc.so.6
#1 0x00007ffff7124e6a in abort () from /usr/lib/libc.so.6
#2 0x00007ffff711c8bd in __assert_fail_base () from /usr/lib/libc.so.6
#3 0x00007ffff711c972 in __assert_fail () from /usr/lib/libc.so.6
#4 0x00007ffff41d7d62 in llvm::raw_fd_ostream::preferred_buffer_size() const () from /usr/lib/librustc_llvm-4e7c5e5c.so
#5 0x00007ffff30593ec in GetBufferSize (this=0x7fffef7f1300) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/raw_ostream.h:114
#6 GetBufferSize (this=0x7fffef7f1300) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/rustllvm/PassWrapper.cpp:216
#7 setStream (Delete=false, Stream=..., this=0x7fffef7f1340) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/FormattedStream.h:111
#8 formatted_raw_ostream (Delete=false, Stream=..., this=0x7fffef7f1340) at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/FormattedStream.h:89
#9 LLVMRustPrintModule (PMR=0x7fffe800cf30, M=0x7fffe80038b0, path=0x7fffee823740 "target/test.0.ll") at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/rustllvm/PassWrapper.cpp:233
#10 0x00007ffff6529fa5 in back::write::optimize_and_codegen::unboxed_closure.37047 () from /usr/lib/librustc_trans-4e7c5e5c.so
#11 0x00007ffff653458c in back::write::execute_work_item::h0a51d25fc78535a1HXc () from /usr/lib/librustc_trans-4e7c5e5c.so
#12 0x00007ffff652b893 in back::write::run_passes::h8ff6c36249e9879aIFc () from /usr/lib/librustc_trans-4e7c5e5c.so
#13 0x00007ffff7af7b74 in driver::phase_5_run_llvm_passes::h30b9e967ab9e3034PNa () from /usr/lib/librustc_driver-4e7c5e5c.so
#14 0x00007ffff7ad8590 in driver::compile_input::h8ec974b2bd4afe59Aba () from /usr/lib/librustc_driver-4e7c5e5c.so
#15 0x00007ffff7b99abf in run_compiler::h0e495a7c10e57aaae5b () from /usr/lib/librustc_driver-4e7c5e5c.so
#16 0x00007ffff7b96e89 in thunk::F.Invoke$LT$A$C$$u{20}R$GT$::invoke::h12226774702741163622 () from /usr/lib/librustc_driver-4e7c5e5c.so
#17 0x00007ffff7b95c2f in rt::unwind::try::try_fn::h67848939709837360 () from /usr/lib/librustc_driver-4e7c5e5c.so
#18 0x00007ffff761fb99 in rust_try_inner () from /usr/lib/libstd-4e7c5e5c.so
#19 0x00007ffff761fb86 in rust_try () from /usr/lib/libstd-4e7c5e5c.so
#20 0x00007ffff7b96280 in thunk::F.Invoke$LT$A$C$$u{20}R$GT$::invoke::h15720675569063176780 () from /usr/lib/librustc_driver-4e7c5e5c.so
#21 0x00007ffff75a670f in sys::thread::thread_start::h2ac456e96ea03cedcJw () from /usr/lib/libstd-4e7c5e5c.so
#22 0x00007ffff19cf314 in start_thread () from /usr/lib/libpthread.so.0
#23 0x00007ffff71d824d in clone () from /usr/lib/libc.so.6
All other outputs fail predictably with an error from rustc:
error: could not write output: No such file or directory