Closed Adoni5 closed 10 months ago
Final note - the Cargo.toml for minimap2-rs currently points to the local minimap2-sys. This should be updated when the new version of minimap2-sys is up on crates.io
Amazin!. I'm recovering from a conference but will get this pushed out in the next few days.
Main changes
After hitting https://github.com/jguhlin/minimap2-rs/issues/13#issuecomment-1697216678 a couple of time whilst trying to compile
mappy-rs
wheels for multiple architectures, I realised that checkingtarget_arch
in the build.rs script of minimap2-sys, only considers the host architecture and not the target triple. This meant that thetarget_specific
function https://github.com/jguhlin/minimap2-rs/blob/bb118a5cde0a30d9b0a205562136f73143d61957/minimap2-sys/build.rs#L153-L154 was being run for x86_64 every time, irrespective of which cross compilation was occurring. To catch this I have changed thetarget_specific
function and dropped conditional compilation for it based on target architecture, and instead used a check against the TARGET env variable inside the function, adding flags based on whether the target triple is x86 or aarch64.In the
minimap2-rs
library code, I had to add aFrom
trait to convert presets to C strings for both i8 and u8 types. I also conditionally compile any sections where pointers are passed through to the underlying FFI functions based on architecture. In linux aarch64/armv7 cross compilation, the underlying C compiler expectsu8
pointers, whereaslinux x86_64
,macOS x86_64
, andmacOS aarch64
expecti8
pointers. I have not been able to test if this breaks native compilation onlinux aarch64
.Other changes
For linux aarch64, for some reason to cross compile, the C99 standard had to be enabled, due to for loop constructions in minimap2. I've added this to the
simde
feature function, https://github.com/Adoni5/minimap2-rs/blob/d804692362e414058123de21d3464f6e7d615f52/minimap2-sys/build.rs#L167 But I don't know if that's the best place to put it?I added fakeminimap2 and minimap2-sys as cargo workspaces in the root Cargo.toml, simply so that
rust-analyzer
would work in the directory. This can be removed if you prefer, but I don't think it has any knock on effects otherwise.Built fakeminimap2 with local minimap2-rs crate - no reason, just seems semi-logical as it seems useful for testing.