makspll / bevy_mod_scripting

Bevy Scripting Plugin
Apache License 2.0
390 stars 31 forks source link

Re-generate code to fix build on ARM Macs #77

Closed CyanBlob closed 5 months ago

CyanBlob commented 11 months ago

Updating the glam and bevy versions and then re-generating generate.rs fixes #70. This issue seems to ultimately stem from https://github.com/bitshifter/glam-rs/issues/296.

This should be tested on x86 platforms before merging to ensure compatibility wasn't broken.

A better solution will be to eventually generate different code for each platform via cross-compilation.

makspll commented 11 months ago

Hi, yes once aarch64 targets get SIMD support in glam this will disappear, however that seems to require nightly rust to run together with the core-simd feature!

Thanks for the PR!

Changing these signatures does seem to fix this on arm64 however it breaks again on x86, I guess this is the other side of the problem.

A full fix will need to somehow work on both, probably need a bit of logic in the macro code along the lines of:

However I am not sure this generalizes to all the cases where these vectors are used. Glam is quite confusing, It contains both replacement Vec4 versions for different platforms depending on simd support (the issue we're facing) but also replacement BVec4A and such types which do not use simd instructions on non-simd platforms.

To be honest this seems like a portability issue in glam itself to me. If you rely on an A vector being returned on x86 in your code, this will break on non simd platforms. I think maybe the best fix for now will indeed be generating alternative .rs files depending on simd support, but then removing that once the issue in glam is fixed.

makspll commented 11 months ago

Currently working on trying to generate alternative simd files but cross is playing up: https://github.com/cross-rs/cross/issues/1341

makspll commented 5 months ago

Already fixed on main