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

Build fails for armv7-unknown-linux-gnueabihf; i8/u8 type mismatch #191

Open
maiphi opened this issue May 19, 2024 · 2 comments
Open

Build fails for armv7-unknown-linux-gnueabihf; i8/u8 type mismatch #191

maiphi opened this issue May 19, 2024 · 2 comments

Comments

@maiphi
Copy link

maiphi commented May 19, 2024

I'm trying to build raylib-rs master (5.0.0) for armv7-unknown-linux-gnueabihf. The build fails due to type mismatch between u8 and i8. I guess this is the same issue as described here: rust-lang/rust#60226. There are several patches from projects linked that had the same problem.

Build log is attached: build.log

How to reproduce

Dockerfile:

FROM ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:latest
RUN dpkg --add-architecture armhf
RUN apt-get update -y
RUN apt-get install -y libx11-dev:armhf
RUN apt-get install -y xorg-dev clang libclang1-5.0

podman build -t raylib_rs_env .

Cross.toml:

[build]
default-target = "armv7-unknown-linux-gnueabihf"
[target.armv7-unknown-linux-gnueabihf]
image = "raylib_rs_env"
cargo install cross
cross build --release

(edit: removed packages from Dockerfile which are not needed to build a small example; added libx11-dev:armhf)

@maiphi
Copy link
Author

maiphi commented May 20, 2024

Turns out this is not the only issue.

Replacing i8 by ::std::os::raw::c_char in core/callbacks.rs, core/data.rs and core/input.rs makes the code compile.

But then linking to an example program fails, because it wants to link bcm_host, brcmEGL, brcmGLESv2 and vcos, i.e. Raspberry Pi/Broadcom libraries.

It seems that the build system erroneously detects the platform as "Raspberry Pi" (passed to cmake when building raylib).

@maiphi
Copy link
Author

maiphi commented May 20, 2024

The problem with the platform detection is in raylib-sys/build.rs:359-360. There it is assumed that the target armv7-unknown-linux implies that the platform is "Raspberry Pi". Commenting the two lines, compilation and linking is successful.

While the fix i8::std::os::raw::c_char should be portable, of course, for the platform detection one would need something more sophisticated to detect the RPI. Personally, I'd be happy with a build option to specify the platform.

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

1 participant