Forceflow / libmorton

C++ header-only library with methods to efficiently encode/decode Morton codes in/from 2D/3D coordinates
MIT License
596 stars 71 forks source link

Compilation failure in VirtualBox when AVX2 is enabled #54

Closed dktapps closed 3 years ago

dktapps commented 4 years ago

In multiple cases now I've seen my users have compilation issues when AVX2 is enabled in a VM but not BMI2.

I understand that you used a check for __AVX2__ as a substitute for __BMI2__ on MSVC, but this breaks on *nix if AVX2 happens to be enabled without BMI2 (e.g. weird CPU flags or VM).

The checks for AVX2 should likely be coupled with a check for _MSC_VER.

https://github.com/pmmp/php-build-scripts/issues/109

Forceflow commented 3 years ago

I've deployed a possible fix in https://github.com/Forceflow/libmorton/tree/avx_bmi_fix

Can you test it?

dktapps commented 3 years ago

Thanks. There are a couple more places where this needs fixing (https://github.com/Forceflow/libmorton/blob/avx_bmi_fix/libmorton/include/morton.h#L38 and https://github.com/Forceflow/libmorton/blob/avx_bmi_fix/libmorton/include/morton.h#L80). After patching these locally my build succeeded.

Forceflow commented 3 years ago

Fixed in 0.2.6. Thanks!