Skip to content

Unexpected failure during compilation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Pranz opened this issue Oct 28, 2014 · 4 comments
Open

Unexpected failure during compilation #1

Pranz opened this issue Oct 28, 2014 · 4 comments

Comments

@Pranz
Copy link
Owner

Pranz commented Oct 28, 2014

Fails at compiling due to recent commit aa44e25 with the following error message:

   Compiling tcod v0.1.0 (file:///home/pranz/gitbuilds/tcod-rs)
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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
task 'rustc' failed at 'expected item, found foreign item ffi::TCOD_black::TCOD_black (id=7409)', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_map/mod.rs:326


Could not compile `tcod`.

I'm guessing this is because I'm not interacting with the FFI in the proper way. Do you, @tomassedovic, know what could be wrong with the code?

@tomassedovic
Copy link

Hm, that's not good. ICE is a bug in Rust, so you did the right thing opening a Rust issue. It'd help the Rust devs if you could reduce the example to the minimal amount of code which still triggers it.

I'll try to compile your code and look into it later, but I wonder if it's because of the static keyword? It was changed to const for the use case you have there (see tomassedovic@3af930b).

@tomassedovic
Copy link

Looks like the ICE was fixed in one of the recent commits. I'm not seeing it any more with this:

$ rustc --version verbose
rustc 0.13.0-nightly (221fc1e3c 2014-10-31 02:27:15 +0000)
binary: rustc
commit-hash: 221fc1e3cdcc208e1bb7debcc2de27d47c847747
commit-date: 2014-10-31 02:27:15 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly

It now produces proper compilation errors.

@tomassedovic
Copy link

Oh, and I've looked into the colour issue a bit more. Casting tcod::Color to tcod::ffi::TCOD_color_t doesn't work because the types are different and the casting operation would be unsafe. You can use std::mem::transmute to convert between the two, but that doesn't work for const or static items.

I've coded up a quick proof of concept that should demonstrate what you're trying to do (if I understood your commit directly):

tomassedovic#24

This just adds one colour alias, but as you can see and test in the example, that colour is usable in the safe tcod bindings. You can just as well use the ffi::TCOD_... variants, too so the re-exports in the color module are not necessary although they do make things nicer.

Would this work for you?

@Pranz
Copy link
Owner Author

Pranz commented Nov 3, 2014

Ah yes, I realized afterwards that casting in Rust doesn't work that way. This adresses my issue.

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

No branches or pull requests

2 participants