-
Notifications
You must be signed in to change notification settings - Fork 6
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
incompatible i2c_t
types
#24
Comments
Just to make sure I understand the issue right: If you built without modifications but setting If so, then RIOT is breaking its (not very explicit) promise to have all cross-compilation-unit interfaces compiler independent (which it upholds in other places eg. by casting enums to explicitly sized types). A possible remedy might be ensuring that compatible compiler flags are used. Please use your workarounds for the moment; I'd like to coordinate this with the RIOT maintainers. (A fix might be sold most easily if this also shows up when some modules are built with clang and others with gcc). |
yes, my guess is that everything works when also compiling RIOT with llvm. But I can't test this because I don't have a board that works with |
I was unaware we had any such board (at least, outside AVR which is not suported by riot-sys yet). Which board is it / is there an open issue about that it doesn't work? (Fixing Rust-on-RIOT stuff is generally easier once LLVM works). |
When using an esp32 I get the message: |
Chances are things work fine on the ARM board either way. Which ESP32 are you using, a RISC-V or an Xtensa one? (The latter is unsupported so far and the former might have other issues, but I'd guess you're from the same project as Remmirad, and you might be using adjustments from #20). |
Yes I am from the same project. I used both a RISC-V and Xtensa esp32. But we also had this problem with an arm board. I will try to reproduce this. |
When building for When setting Even when not using Rust and just building a pure C application, the size of |
When trying to generate bindings for the
bmx280
device driver, I noticed that the size of the structbmx280_params_t
differs from C to Rust. I used the moduleUSEMODULE += bmp280_i2c
and added these lines torust-riot-sys/riot-headers.h
to generate the bindings:The struct contains an
i2c_dev
of typei2c_t
which seems to be the reason for the difference. I used the following programs to print the sizes. In C:In Rust:
In the file
RIOT/drivers/include/periph/i2c.h
the type is defined as follows:For native, xtensa, risc-v and arm, it seems like all the fast integer types are defined through internal compiler defines like
typedef __INT_FAST8_TYPE__ int_fast8_t;
These types differ since RIOT is compiled by gcc and the Rust bindings are created with llvm. I did some tests and got the following types using different architectures. The cells show the actual type when using gcc / clang:long long int
long long int
long long int
One workaround is to redefine these macros when generating the bindings so that they match the types used by gcc. For the
uint_fast8_t
this can be done by adding the following lines toriot-bindgen.h
andriot-c2rust.h
:Alternatively, this also works:
However there should be a better way that actually guarantees that the same type is used when compiling RIOT and creating the bindings.
The text was updated successfully, but these errors were encountered: