Repository navigation
Conversation
Bump the htslib submodule from 1.23 to 1.25 (htscodecs 1.6.5 -> 1.6.7). The library source list in the 1.25 Makefile is unchanged. - Define HAVE___BUILTIN_PREFETCH in the generated config.h, mirroring the configure check added in htslib 1.24. - Regenerate the prebuilt bindings with bindgen 0.72.1. The Linux file is now generated on Linux; the previous one had been generated on macOS. - Fix the README binding-regeneration recipes: use a dedicated target dir, and locate bindings.rs in both the old and new cargo build-dir layouts.
The lzma block in build.rs defined HAVE_LIBBZ2 instead of HAVE_LIBLZMA, so lzma support was never compiled in. bzip2-sys only exports an include dir when it builds bzip2 from source, so with a system libbz2 the bzip2 block never defined HAVE_LIBBZ2 either; bz2 support worked only through the lzma block's typo. Define HAVE_LIBLZMA/HAVE_LZMA_H whenever the lzma feature is enabled (lzma-sys always ships lzma.h) and HAVE_LIBBZ2 whenever the bzip2 feature is enabled, and add tests asserting each codec is compiled in exactly when its feature is on, including a real xz decode.
Author
|
The numbers on the PR are large(!) at |
Contributor
|
Still failing in the CI. |
Homebrew no longer recognises curl-openssl, so the macOS jobs failed in the "Install htslib dependencies" step. The formula has been named curl for years.
Author
|
Thanks @johanneskoester - seems like the CI failure was an unrelated shift in the curl packages available via brew. I've fixed here but can make it a separate PR if that's preferred. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the bundled htslib from 1.23 to 1.25, and fixes the build so that lzma and bzip2 support are actually compiled in when their features are enabled. The 1.23 bump on
main(#36) was never released, so for users the next release moves htslib from 1.19.1 (hts-sys 2.2.1) to 1.25.A matching rust-htslib PR is ready and will be opened as soon as there is an hts-sys release it can reference.
Changes
LIBHTS_OBJS) is unchanged, sobuild.rs'sFILESneeds no update.HAVE___BUILTIN_PREFETCHadded to the generatedconfig.h, mirroring a new configure check in htslib 1.24+. Without it,hts_prefetch()(used in the pileup hot loop) falls back to a volatile read.build.rsdefinedHAVE_LIBBZ2instead ofHAVE_LIBLZMA, so with thelzmafeature on, htslib could not decode CRAM blocks using LZMA ("Lzma compression is not compiled into this version") or identify xz-compressed files. It now definesHAVE_LIBLZMAandHAVE_LZMA_H. lzma-sys is builtstatic, so it always provideslzma.h, including on macOS.HAVE_LIBBZ2, and bz2 support worked only because the lzma block set it by mistake. Observed on macOS:--no-default-features --features bzip2had no bz2 support, and--features lzmaalone claimed bz2. The same should apply on Linux whenever pkg-config finds libbz2 (e.g. withlibbz2-devinstalled), but that was not tested against the oldbuild.rs.HAVE_LIBBZ2is now set whenever thebzip2feature is on, and the include dir is added when one is exported.tests/codec_support.rs: asserts viahts_features()that bz2/lzma are compiled in exactly when their features are enabled, and decodes an xz-compressed SAM header throughhts_detect_format2to exercise liblzma for real. These tests fail on the previousbuild.rs.linux_prebuilt_bindings.rsonmainhad been generated on macOS (it contained__darwin_va_list, with the_link-name prefixes removed by hand); it is now generated on Linux, so libc declarations andva_listare correct for glibc. All htslib struct and union definitions are identical between the two files.osx_prebuilt_bindings.rsis generated on arm64; the 2.2.1 release's was x86_64. The only htslib-relevant difference isva_list(affectscram_set_voptionandkvsprintf).target/(so the Linux recipe could pick up macOS bindings) and globbedhts-sys-*/out, which current cargo (build/hts-sys/<hash>/out) no longer produces. Both recipes now use a dedicated target dir and reproduce the committed files byte for byte.API changes since the last release (2.2.1 / htslib 1.19.1)
For htslib's own API this is purely additive: no htslib functions, constants, structs or type aliases removed, and no signatures or struct layouts changed. The only modified htslib items are parameter renames (
kstrstr,kstrnstr,kmemmem,bcf_sr_remove_reader) and theHTS_VERSIONvalue.The system declarations bindgen sweeps in (libc, platform headers) vary with the generation host. Comparing the Linux files like for like against 2.2.1, nothing at all was removed, two glibc float128 aliases were added, and a few glibc version constants changed. The macOS file loses about 46 x86_64-only
mcontextbitfield accessors because it is now generated on arm64.Added since 1.19.1 include:
bcf_itr_querys1,bcf_itr_regarray,bcf_itr_regions,tbx_itr_querys1,tbx_itr_regarray,tbx_itr_regions,tbx_itr_next1,sam_hdr_remove_tag_all,khgetline,kfgetline,bcf_sr_add_hreader,BCF_VL_P/LA/LG/LR/M,BAM_MAX_QNAME_LEN,CRAM_OPT_RM_UR,FASTQ_OPT_UMI/FASTQ_OPT_UMI_REGEX,BCF_SR_PAIR_ID,tbx_conf_gaf, and newbcf_sr_errorvalues (bcf_sr_ok,bcf_sr_open_failed,bcf_sr_seek_error,bcf_sr_regions_error,bcf_sr_samples_error).Behaviour changes users will see
From htslib's NEWS, 1.19.1 → 1.25:
1|1now decodes as both alleles phased; 1.19.1 left the first unphased. Code comparing decoded genotypes structurally will see different results.bgzf_thread_pool()call on the same handle now returns -2 instead of silently replacing (and leaking) the first pool.REF_PATHis unset.@SQlines with multiple differingLNvalues now fail to parse.SEEK_CURwere removed.Number=(1.23): VCFv4.4/4.5Number=P/LA/LG/LR/Mare now parsed as newBCF_VL_*values; exhaustive matches onBCF_VL_*downstream need new arms.errnumtobcf_sr_open_failed(11). Previously they setopen_failed, which is 0 and indistinguishable from success.lzmafeature is enabled (it was silently absent before).Versioning
This PR is titled
feat:, so release-please will cut 2.3.0. If you would rather release it as 3.0.0, retitling tofeat!:before merging is all that's needed. The evidence either way:hts-sys = "2.2.0"(i.e.^2.2), so a 2.3.0 release reaches every existing rust-htslib user oncargo update, bringing the behaviour changes above (notably GT phasing) without rust-htslib opting in. As 3.0.0, rust-htslib adopts it explicitly, and can pair it with its own pending breaking release.The lzma/bzip2 fix is a separate
fix:commit for easier review. Since PRs here are squash-merged, it won't get its own changelog entry; happy to split it into its own PR if you'd prefer that.#24 (lzma-sys → liblzma-sys) doesn't touch
build.rsand shouldn't conflict; the new codec tests will catch it if the swap ever stops lzma being compiled in.Testing
cargo testwith default features,--no-default-features,--features bzip2,--features lzma,--features bzip2,lzma, and--all-features; pluscargo fmt --checkandcargo clippy --all-targets. bzip2-sys used the system libbz2 here.--all-features(which enablesbindgen) use the prebuilt Linux bindings. bzip2 was also built from source, with no systembzlib.hor pkg-config entry, to exercise theDEP_BZIP2_INCLUDEpath.build.rs(macOS) and passing after the fix.libhts.areferencesBZ2_*) but no bz2 data is decoded.[patch.crates-io]path override. Its adaptations to htslib's behaviour changes (e.g. the newNumber=kinds) live on the rust-htslib side; nothing further was needed here.bindgen: 170 tests + 38 doctests pass with both live bindgen and the prebuilt bindings.--all-featuresand--no-default-features: all pass. The prebuilt macOS bindings were also tested (157 tests + 38 doctests pass) before the lzma/bz2 fix, which does not change the bindings.