Skip to content

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

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
Jomosoto opened this issue May 24, 2025 · 3 comments
Open

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

Jomosoto opened this issue May 24, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@Jomosoto
Copy link

Jomosoto commented May 24, 2025

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 )

@antoyo
Copy link
Contributor

antoyo commented May 24, 2025

Thanks for reporting this issue!

Could you please share which architecture you test on so that I can try to make its support better?

@antoyo antoyo added the bug Something isn't working label May 24, 2025
@Jomosoto
Copy link
Author

Sure: I'm testing on cr16 that was dropped and I reintroduced off tree for a project, but in tree there's m68k (with -mshort) and avr, that have the same int size.

@antoyo
Copy link
Contributor

antoyo commented May 25, 2025

Ok. I'll take a look at AVR, but that might take some time before I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants