jguhlin / minimap2-rs

Rust bindings to minimap2 library
Other
51 stars 11 forks source link

FEATURE: Conditional compilation for aarch64, arm_neon, and simde #13

Closed jguhlin closed 4 months ago

jguhlin commented 1 year ago

I think I've got SSE2 and SSE4.1 working

Adoni5 commented 10 months ago
error: failed to run custom build command for `minimap2-sys v0.1.15+minimap2.2.26`

Caused by:
  process didn't exit successfully: `/home/runner/work/mappy-rs/mappy-rs/target/release/build/minimap2-sys-a8b700e453c2304c/build-script-build` (exit status: 1)
  --- stdout
  armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rustc-link-lib=m
  cargo:rustc-link-lib=pthread
  cargo:rerun-if-changed=minimap2/*.c
  cargo:rerun-if-env-changed=ZLIB_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  TARGET = Some("armv7-unknown-linux-gnueabihf")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_armv7-unknown-linux-gnueabihf
  CC_armv7-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CC_armv7_unknown_linux_gnueabihf
  CC_armv7_unknown_linux_gnueabihf = Some("armv7-unknown-linux-gnueabihf-gcc")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = None
  cargo:rerun-if-env-changed=CFLAGS_armv7-unknown-linux-gnueabihf
  CFLAGS_armv7-unknown-linux-gnueabihf = None
  cargo:rerun-if-env-changed=CFLAGS_armv7_unknown_linux_gnueabihf
  CFLAGS_armv7_unknown_linux_gnueabihf = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "sccache" "armv7-unknown-linux-gnueabihf-gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=armv7-a" "-mfpu=vfpv3-d16" "-I" "minimap2" "-I" "minimap2/lib/simde" "-I" "minimap2/" "-I" "/home/runner/work/mappy-rs/mappy-rs/target/armv7-unknown-linux-gnueabihf/release/build/libz-sys-72c7251e49206614/out/include" "-Wc++-compat" "-DSIMDE_ENABLE_NATIVE_ALIASES" "-DUSE_SIMDE" "-msse2" "-DKSW_SSE2_ONLY" "-DHAVE_KALLOC" "-lm" "-lpthread" "-o" "/home/runner/work/mappy-rs/mappy-rs/target/armv7-unknown-linux-gnueabihf/release/build/minimap2-sys-8c2a0d1063207b7a/out/minimap2/pe.o" "-c" "minimap2/pe.c"
  cargo:warning=armv7-unknown-linux-gnueabihf-gcc: error: unrecognized command line option '-msse2'

  exit status: 1

Just sticking this here, will fix this afternoon - v0.1.15 Doesn't compile for aarch64 and armv7 linux as the -msse2 flag is still passed for non x86 architectures. We're heading into winter an I want to heat my house with my raspberry PI

Should add that this is with "simde" feature enabled

Adoni5 commented 10 months ago

Turns out that this was an issue that is specific to cross compilation! The problem was that the cfg(target_arch=...) picks up the host system architecture, irrespective of the architecture listed in the target triple. This meant that the x86_64 compilation flags were being set, and not the SIMDE/NEON flags for aarch. I've fixed it in the build script by checking the env TARGET, and I'll open a PR tomorrow. I've made something of a mess commit wise so a bit too tired to do it tonight