Skip to content

Integer width is asumed to be 32 bit at some points #685

Open
@Jomosoto

Description

@Jomosoto

I'm building for a target that has an int width of 16 bit. Compilation fails at some points, because an integer width of 32 bit is assumed.

Here (and similar builtins just below):

OverflowOp::Add => match new_kind {
Int(I8) => "__builtin_add_overflow",
Int(I16) => "__builtin_add_overflow",
Int(I32) => "__builtin_sadd_overflow",
Int(I64) => "__builtin_saddll_overflow",
Int(I128) => "__builtin_add_overflow",
Uint(U8) => "__builtin_add_overflow",
Uint(U16) => "__builtin_add_overflow",
Uint(U32) => "__builtin_uadd_overflow",
Uint(U64) => "__builtin_uaddll_overflow",
Uint(U128) => "__builtin_add_overflow",
_ => unreachable!(),
},

__builtin_s/uadd_overflow takes ints, but on my platform they are only 16 bit long.

And here:

let fill_byte = self.context.new_cast(self.location, fill_byte, self.i32_type);
let size = self.intcast(size, self.type_size_t(), false);
self.block.add_eval(
self.location,
self.context.new_call(self.location, memset, &[ptr, fill_byte, size]),
);

memset takes an int, but the fill_byte is hardcoded to i32.

(PS: Thank you for your work! This project makes it possible to use rust on my architecture at all <3 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions