Skip to content

Calling function with bad signature, Rust 0.13.0-nightly #17974

Closed
@alexispurslane

Description

@alexispurslane

So, i am compileing a version of rustboot that uses some changes that someone else had made so that it could display text on the screen, but when I compile I get this:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Instructions.cpp:276: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() && Args.size() > FTy->getNumParams())) && "Calling a function with bad signature!"' failed.
make: *** [main.o] Aborted (core dumped)

i have checked all the other issues about this, but none of them have helped. My code looks like this:

#![no_std]
#![allow(ctypes)]
#![feature(lang_items)]

#[allow(dead_code)]
enum Color {
    Black      = 0,
    Blue       = 1,
    Green      = 2,
    Cyan       = 3,
    Red        = 4,
    Pink       = 5,
    Brown      = 6,
    LightGray  = 7,
    DarkGray   = 8,
    LightBlue  = 9,
    LightGreen = 10,
    LightCyan  = 11,
    LightRed   = 12,
    LightPink  = 13,
    Yellow     = 14,
    White      = 15,
}

enum DisplayInfo {
    VGAWIDTH = 80,
    VGAHEIGHT = 25,
    VGAADDRESS = 0xb8000,
}

#[lang="sized"]
fn clear_screen(background: Color) {
    let limit = 80u * 25u;
    let mut i = 0u;
    while i < limit {
        unsafe {
            *((VGAADDRESS as u16 + i as u16 * 2) as *mut u16) = (background as u16) << 12;
        }
        i += 1;
    }
}

fn make_vgaentry(c: u8, fg: Color, bg: Color) -> u16 {
    let color = fg as u16 | (bg as u16 << 4);
    c as u16 | (color << 8)
}
pub fn putc(x: u16, y: u16, c: u8) {
    let idx: uint = (y * VGAWIDTH as u16 * 2 + x * 2) as uint;
    unsafe {
        *((VGAADDRESS as u16 + idx as u16) as *mut u16) = make_vgaentry(c, Green, Black)
    }
}

#[lang="fail_bounds_check"]
pub fn write_x_y(s: &[u8], x: u16, y: u16, len: uint) {
    let mut i = 0u;
    while i < len {
        putc(x + i as u16, y, s[i]);
        i += 1;
    }
}


#[no_mangle]
#[no_split_stack]
pub fn main() {
    clear_screen(Black);
    let prompt = b"==> ";
    write_x_y(prompt, 2, 3, 4);
}

I am fairly new to rust, and pretty much copy-and-pasteing stuff in. You will notice I cannot program very rust-idiomaticly becouse I have to do without the standard library, and cannot compile libcore for i386-intel-linux, which is what the loader assembly code is written for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions