Skip to content

Commit

Permalink
perf: update htslib and corresponding bindings to 1.16 (#366)
Browse files Browse the repository at this point in the history
* perf: update htslib and corresponding bindings

* fix bindings

* add new files from htscodecs, and pass enable special instruction sets based on the rust target_feature configs

* revert the change to the linux bindings - no change is required and something weird happened with the new ones.

Co-authored-by: Patrick Marks <pmarks@gmail.com>
Co-authored-by: Patrick Marks <patrick@10xgenomics.com>
  • Loading branch information
3 people authored Oct 13, 2022
1 parent 0f8c666 commit f597ce0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions hts-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ const FILES: &[&str] = &[
"htscodecs/htscodecs/htscodecs.c",
"htscodecs/htscodecs/pack.c",
"htscodecs/htscodecs/rANS_static4x16pr.c",
"htscodecs/htscodecs/rANS_static32x16pr_avx2.c",
"htscodecs/htscodecs/rANS_static32x16pr_avx512.c",
"htscodecs/htscodecs/rANS_static32x16pr_sse4.c",
"htscodecs/htscodecs/rANS_static32x16pr_neon.c",
"htscodecs/htscodecs/rANS_static32x16pr.c",
"htscodecs/htscodecs/rANS_static.c",
"htscodecs/htscodecs/rle.c",
"htscodecs/htscodecs/tokenise_name3.c",
"htscodecs/htscodecs/utils.c",
];

fn main() {
Expand Down Expand Up @@ -180,6 +186,35 @@ fn main() {
println!("cargo:rerun-if-changed=htslib/hfile_s3_write.c");
}

// pass through target-feature flags to enable special instruction
// support in htscodecs build.
// TODO: add AVX512 support once Rust has it as a target feature.
if let Ok(targets) = env::var("CARGO_CFG_TARGET_FEATURE") {
if targets.contains("avx2") {
cfg.flag("-mavx2");
config_lines.push("#define HAVE_AVX2 1");
}

if targets.contains("sse4.1") {
cfg.flag("-msse4.1");
config_lines.push("#define HAVE_SSE4_1 1");
}

if targets.contains("ssse3") {
cfg.flag("-mssse3");
config_lines.push("#define HAVE_SSSE3 1");
}

if targets.contains("popcnt") {
cfg.flag("-mpopcnt");
config_lines.push("#define HAVE_POPCNT 1");
}

if targets.contains("neon") {
config_lines.push("#define __ARM_NEON 1");
}
}

// write out config.h which controls the options htslib will use
{
let mut f = std::fs::File::create(out.join("htslib").join("config.h")).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion hts-sys/htslib
Submodule htslib updated 106 files

0 comments on commit f597ce0

Please sign in to comment.