Skip to content
This repository has been archived by the owner on Jul 13, 2019. It is now read-only.

Crash trying to print value from external crate #51

Open
xasmx opened this issue Oct 11, 2015 · 1 comment
Open

Crash trying to print value from external crate #51

xasmx opened this issue Oct 11, 2015 · 1 comment

Comments

@xasmx
Copy link

xasmx commented Oct 11, 2015

Trying to print a value for a type defined in an external crate is crashing rusti:

$ cargo run -- -L testi/target/debug/
Running target/debug/rusti -L testi/target/debug/
rusti=> extern crate testi;
rusti=> use testi::Foo;
rusti=> Foo
LLVM ERROR: Program used external function '__ZN21Foo...std..fmt..Debug3fmt20h8530f8b2d5755ad6iaaE' which could not be resolved!
An unknown error occurred

To learn more, run the command again with --verbose.
$

Environment:

  • OS X Yosemite 10.10.3
  • rustc 1.5.0-nightly (6e5a32547 2015-09-19)
  • cargo 0.6.0-nightly (de11b58 2015-09-16)
  • rusti commit 842564d

Both rusti and the testi crate compiled clean with this version.

External crate:
$ cat testi/Cargo.toml
[package]
name = "testi"
version = "0.0.1"


$ cat testi/src/lib.rs

[derive(Debug)]

pub struct Foo;

@murarth
Copy link
Owner

murarth commented Oct 12, 2015

The issue here is that rusti needs both an rlib and a dylib build available for any crate it wants to load, but it doesn't check that both of these exist before trying to run the code that depends on them. Therefore, LLVM's linker encounters a missing symbol and aborts.

To build both rlib and dylib for a project, you can either add crate-type = ["rlib", "dylib"] to the [lib] section of your Cargo.toml or run cargo rustc -- --crate-type=rlib,dylib to build the project.

Keep this issue open, though. I definitely want to improve the error message for this case.

Edit: Implementing an error message for this will be problematic because some core crates (core, libc, collections, etc.) don't have dylib versions installed. I don't have any idea how rusti could differentiate between core crates and user-supplied crates for this check.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants