Skip to content
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

bfc does not compile on ARM #4

Closed
MagaTailor opened this issue Jan 3, 2016 · 10 comments
Closed

bfc does not compile on ARM #4

MagaTailor opened this issue Jan 3, 2016 · 10 comments

Comments

@MagaTailor
Copy link
Contributor

The issue I've been tracking from the beginning says hullo:

 Compiling bfc v1.3.0 (file:///tmp/bfc-master)
src/llvm.rs:44:38: 44:49 error: mismatched types:
 expected `*const u8`,
    found `*mut i8`
(expected u8,
    found i8) [E0308]
src/llvm.rs:44         let llvm_ir = CStr::from_ptr(llvm_ir_ptr);
                                                    ^~~~~~~~~~~
src/llvm.rs:44:38: 44:49 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
Could not compile `bfc`.

Also, please update tempfile in Cargo.toml due to the same issue.

@MagaTailor MagaTailor changed the title ARM still unbroken ARM still not unbroken Jan 3, 2016
@MagaTailor
Copy link
Contributor Author

Well no, that was an old source file. Nowadays it's going to need more casts:

Compiling bfc v1.4.0 (file:///tmp/bfc-master)
src/llvm.rs:53:42: 53:53 error: mismatched types:
 expected `*const u8`,
    found `*mut i8`
(expected u8,
    found i8) [E0308]
src/llvm.rs:53             let llvm_ir = CStr::from_ptr(llvm_ir_ptr);
                                                        ^~~~~~~~~~~
src/llvm.rs:53:42: 53:53 help: run `rustc --explain E0308` to see a detailed explanation
src/llvm.rs:270:36: 270:66 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
src/llvm.rs:270         LLVMSetTarget(llvm_module, target_triple_cstring.as_ptr());
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/llvm.rs:270:36: 270:66 help: run `rustc --explain E0308` to see a detailed explanation
src/llvm.rs:773:40: 773:57 error: mismatched types:
 expected `*const u8`,
    found `*mut i8`
(expected u8,
    found i8) [E0308]
src/llvm.rs:773         target_triple = CStr::from_ptr(target_triple_ptr).to_owned();
                                                       ^~~~~~~~~~~~~~~~~
src/llvm.rs:773:40: 773:57 help: run `rustc --explain E0308` to see a detailed explanation
src/llvm.rs:803:41: 803:53 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
src/llvm.rs:803                                         cpu.as_ptr(),
                                                        ^~~~~~~~~~~~
src/llvm.rs:803:41: 803:53 help: run `rustc --explain E0308` to see a detailed explanation
src/llvm.rs:804:41: 804:58 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
src/llvm.rs:804                                         features.as_ptr(),
                                                        ^~~~~~~~~~~~~~~~~
src/llvm.rs:804:41: 804:58 help: run `rustc --explain E0308` to see a detailed explanation
src/llvm.rs:843:56: 843:65 error: mismatched types:
 expected `*const u8`,
    found `*mut i8`
(expected u8,
    found i8) [E0308]
src/llvm.rs:843             println!("obj_error: {:?}", CStr::from_ptr(obj_error));
                                                                       ^~~~~~~~~
<std macros>:2:25: 2:56 note: in this expansion of format_args!
<std macros>:3:1: 3:54 note: in this expansion of print! (defined in <std macros>)
src/llvm.rs:843:13: 843:68 note: in this expansion of println! (defined in <std macros>)
src/llvm.rs:843:56: 843:65 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to 6 previous errors
Could not compile `bfc`.

So, after casting llvm_ir_ptr as *const _ and so on I managed to get it to compile. It works as expected.

Wilfred added a commit that referenced this issue Jan 3, 2016
See discussion in #4.
@Wilfred
Copy link
Owner

Wilfred commented Jan 3, 2016

Yikes. I've upgraded to the latest libc, but sounds like we'll still need those casts. Would you like to send a pull request?

@MagaTailor
Copy link
Contributor Author

No problem. Give me a few minutes.

@Wilfred
Copy link
Owner

Wilfred commented Jan 3, 2016

Closed by #5.

@Wilfred Wilfred closed this as completed Jan 3, 2016
Wilfred added a commit that referenced this issue Jan 3, 2016
@MagaTailor
Copy link
Contributor Author

Hi again,

Another one has just popped up ;)

src/llvm.rs:795:51: 795:62 error: mismatched types:
 expected `*const u8`,
    found `*mut i8`
(expected u8,
    found i8) [E0308]
src/llvm.rs:795                 let err_msg_cstr = CStr::from_ptr(err_msg_ptr);

Have you considered a possible switch away from libc in favour of std::os::raw?

Wilfred added a commit that referenced this issue Jan 15, 2016
@Wilfred
Copy link
Owner

Wilfred commented Jan 15, 2016

OK, I've removed the dependency on libc -- we're not actually using it.

@Wilfred
Copy link
Owner

Wilfred commented Jan 15, 2016

Regarding the compilation failure, I'm trying to cross-compile to ARM to reproduce the issue. . I've downloaded the .rlib files for rustc from RustBuild to ~/.multirust/toolchains/stable/lib/rustlib as documented in ruststrap.

I've also set up .cargo/config with:

[target.arm-unknown-linux-gnueabihf]
linker = "arm-none-eabi-gcc-5.3.0"

This is the ARM compiler on arch linux as far as I can see. I'm now getting linking errors:

/usr/lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld: cannot find crt0.o: No such file or directory

Any ideas? Ideally we'd configure Travis to cross-compile too, to verify that the build isn't broken again in future.

@MagaTailor
Copy link
Contributor Author

Yes, you have the linker but not the rest of the multilib/multarch stuff. The failure should still happen in rust, though.

@MagaTailor
Copy link
Contributor Author

The libc crate is being added back cause others depend on it (tempfile needs 0.2) and anyway, where are you going to get your c_char, etc from?

Have a look here for a possible solution.

@Wilfred Wilfred reopened this Jan 17, 2016
@Wilfred Wilfred changed the title ARM still not unbroken bfc does not compile on ARM Jan 17, 2016
@MagaTailor
Copy link
Contributor Author

It's not about bfc at all - it was caused by systemic breakage (called a fix) and there's no sign of a top-down solution.

For now I suggest we simply add another cast while investigating the alternative.

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

No branches or pull requests

2 participants