godot-rust / gdext

Rust bindings for Godot 4
https://mastodon.gamedev.place/@GodotRust
Mozilla Public License 2.0
3.09k stars 194 forks source link

Add support for 32-bit #347

Open Esption opened 1 year ago

Esption commented 1 year ago

Trying to do cargo build --target i686-pc-windows-msvc fails to build. It is possible to go in and get it to manually compile by editing godt-ffi/src/opaque.rs to have an align(4) instead of 8, and the OpaqueObject in godot-ffi/src/gen/central.rs from 8uszie to 4usize (you need to wait until after you see the fail build for that, because of codegen). Likely there are other things in that need to be updated as well, but at a minimum that will successfully cause it compile. I wasn't able to figure out where that codegen is actually happening. After editing those two things, the creeps example will start and run, but appears to crash on the anim_names.to_vec() in the rust/src/mob.rs

lilizoey commented 1 year ago

i think we need to change this:

    // For float/double inference, see:
    // * https://github.com/godotengine/godot-proposals/issues/892
    // * https://github.com/godotengine/godot-cpp/pull/728
    #[cfg(feature = "double-precision")]
    let build_config = "double_64"; // TODO infer this
    #[cfg(not(feature = "double-precision"))]
    let build_config = "float_64"; // TODO infer this

in here to the respective x_32 build configs for this.

Esption commented 1 year ago

So, I'm pretty sure the codegen for the Opaques originates from godot4-prebuilt::load_gdextension_json() called in godot-codegen/src/lib.rs I guess just need to give that a different target?

lilizoey commented 1 year ago

yea probably, we can likely use https://doc.rust-lang.org/reference/conditional-compilation.html#target_pointer_width this cfg flag to decide between which representation to use

Esption commented 11 months ago

Not sure if should mention here or over there, but https://github.com/godot-rust/godot4-prebuilt seems to explictly generate for 64-bit targets. It seems fine for the most part with one exception. The built-in tests will fail due to the widths assuming 64-bit. If we added other targets, it would be nice to get win32/linux32/wasm added in there. Example command is to just run cargo test --no-default-features --target i686-pc-windows-msvc

Best I can tell, that's the only reason the itest suite fails as a whole against 32-bit targets, but hard to tell atm.

Bromeon commented 10 months ago

So this would need:

Probably it's good enough to combine this with WASM for now...

Esption commented 10 months ago

AFAIK yes that should be the final thing to tick off 32-bit support.