crash: "UNREACHABLE executed at ObjectFile.cpp:52"
If you accidentally feed rustc --ls a non-object file (as I just did), you get this assertion failure:
Unknown Object File Type UNREACHABLE executed at ObjectFile.cpp:52! Aborted (core dumped)
You may also just get a plain segfault. For example, try an empty file :).
We probably need to sanity check libraries before handing them to llvm. Is there a way to get llvm to do the sanity check without tripping an assert?
Looks like we should call IdentifyFileType (for which I don't see a C wrapper) before doing whatever we're doing.
An empty file is now handled correctly (error "could not find metadata in empty.") But the original bug still holds (for example, with rustc --ls ~/rust/README.txt
Fixing this is blocked on the lack of a binding to LLVM's IdentifyFileType, but I also don't see a Rust library function that gets the size of a file (which is needed because IdentifyFileType takes a length), either. So if someone implements those two things, this should be pretty easy to fix.
Is is still problem? it shows me correct error message "could not find metadata in /home/sammy.kim/rust/src/README.txt" with rustc --ls ~/rust/src/README.txt
I get this when using --ls on an LLVM bitcode file.
Still broken for LLVM bitcode files, though it is line 57 now.
Not an issue with empty files. Steps to reproduce for llvm bitcode:
rustc --emit-llvm foo.rs
rustc --ls foo.bc
This appears to be fixed; rustc --ls foo.bc now prints "could not find metadata in foo.bc". Closing.