[SOLVED] MUSL cross compilation: how to reuse curl-sys/libz-sys/bzip2-sys/lzma-sys and other dependency includes under target?

Given a statically-compiled curl-sys , and a pre-existing C lib (w/ bindgen), how can I point build.rs or cargo to headers like curl.h in order to avoid:

compilation terminated.
make: *** [cram/cram_io.o] Error 1
hfile_s3.c:94:26: fatal error: openssl/hmac.h: No such file or directory
 #include <openssl/hmac.h>
                          ^
compilation terminated.
hfile_s3_write.c:86:23: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>
                       ^
compilation terminated.
make: *** [hfile_s3.o] Error 1
make: *** [hfile_s3_write.o] Error 1
hfile_libcurl.c:47:23: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>

Since I know they are under targets, I would like to use them instead of the preinstalled system's ones:

# find . -iname curl.h
./target/rls/debug/build/curl-sys-cc4be84bbe4142b1/out/include/curl/curl.h
./target/debug/build/curl-sys-7b180d94c0b58a3e/out/include/curl/curl.h
./target/x86_64-unknown-linux-musl/debug/build/curl-sys-3ab30d23ec0cf282/out/include/curl/curl.h 

How can I pass something like the following reliably across builds?:

-I/target/rls/debug/build/curl-sys-cc4be84bbe4142b1/out/include/curl/{curl.h}

I tried with target-dependent .cargo/config's rustcflags unsuccessfully, since it only accepts link-time flags. For more context, I'm trying to build that with cargo build --target x86_64-unknown-linux-musl, if somebody wants to reproduce what I'm mentioning above in one line and explore the backtrace in more detail, please run this oneliner:

git clone --recursive https://github.com/brainstorm/rust-htslib && cd rust-htslib && cargo install cross && cross build --target x86_64-unknown-linux-musl

The GNU toolchain (host and target pointing to x86_64-unknown-linux-gnu, not MUSL), works fine:

$ git clone --recursive https://github.com/brainstorm/rust-htslib && cd rust-htslib && cargo install cross && cross build --target x86_64-unknown-linux-gnu
(...)
   Compiling rust-htslib v0.30.1-alpha.0 (/project)
    Finished dev [unoptimized + debuginfo] target(s) in 28.59s

... which, puzzles me quite a bit, since I'm using rustembedded's Docker containers for reproducibility of the builds: both GNU and MUSL should have the same flags & compile outcomes? :_/

The output from the command above looks like this, btw (again, compiles successfully with GNU's x86_64, glibc), I don't understand why the -I flags are not passed on the MUSL version:

$ git clone --recursive https://github.com/brainstorm/rust-htslib && cd rust-htslib && cargo install cross && cross build --target x86_64-unknown-linux-musl
Cloning into 'rust-htslib'...
remote: Enumerating objects: 270, done.
remote: Counting objects: 100% (270/270), done.
remote: Compressing objects: 100% (198/198), done.
remote: Total 14030 (delta 164), reused 158 (delta 64), pack-reused 13760
Receiving objects: 100% (14030/14030), 5.89 MiB | 1.59 MiB/s, done.
Resolving deltas: 100% (10726/10726), done.
Submodule 'htslib' (https://github.com/samtools/htslib.git) registered for path 'hts-sys/htslib'
Cloning into 'hts-sys/htslib'...
remote: Enumerating objects: 39, done.
remote: Counting objects: 100% (39/39), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 13074 (delta 13), reused 21 (delta 10), pack-reused 13035
Receiving objects: 100% (13074/13074), 9.75 MiB | 3.65 MiB/s, done.
Resolving deltas: 100% (9372/9372), done.
Submodule path 'hts-sys/htslib': checked out 'fd0f89554459b78c07303e2c8a42acacd6851b46'
    Updating crates.io index
     Ignored package `cross v0.2.0` is already installed, use --force to override
    Updating crates.io index
   Compiling cc v1.0.53
   Compiling memchr v2.3.3
   Compiling libc v0.2.70
   Compiling pkg-config v0.3.17
   Compiling proc-macro2 v1.0.13
   Compiling unicode-xid v0.2.0
   Compiling bitflags v1.2.1
   Compiling version_check v0.9.1
   Compiling glob v0.3.0
   Compiling syn v1.0.22
   Compiling autocfg v1.0.0
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.17
   Compiling bindgen v0.53.2
   Compiling lazycell v1.2.1
   Compiling peeking_take_while v0.1.2
   Compiling semver v0.1.20
   Compiling quick-error v1.2.3
   Compiling cfg-if v0.1.10
   Compiling shlex v0.1.1
   Compiling rustc-hash v1.1.0
   Compiling matches v0.1.8
   Compiling doc-comment v0.3.3
   Compiling smallvec v1.4.0
   Compiling serde v1.0.110
   Compiling percent-encoding v2.1.0
   Compiling either v1.5.3
   Compiling ieee754 v0.2.6
   Compiling custom_derive v0.1.7
   Compiling linear-map v1.2.0
   Compiling unicode-bidi v0.3.4
   Compiling thread_local v1.0.1
   Compiling fs-utils v1.1.4
   Compiling itertools v0.9.0
   Compiling unicode-normalization v0.1.12
   Compiling rustc_version v0.1.7
   Compiling nom v5.1.1
   Compiling aho-corasick v0.7.10
   Compiling clang-sys v0.29.3
   Compiling newtype_derive v0.1.6
   Compiling openssl-src v111.9.0+1.1.1g
   Compiling quote v1.0.6
   Compiling libloading v0.5.2
   Compiling libz-sys v1.0.25
   Compiling openssl-sys v0.9.56
   Compiling curl-sys v0.4.31+curl-7.70.0
   Compiling lzma-sys v0.1.16
   Compiling bzip2-sys v0.1.8+1.0.8
   Compiling idna v0.2.0
   Compiling url v2.1.1
   Compiling regex v1.3.7
   Compiling cexpr v0.4.0
   Compiling derive-new v0.5.8
   Compiling snafu-derive v0.6.8
   Compiling serde_derive v1.0.110
   Compiling snafu v0.6.8
   Compiling hts-sys v1.10.2 (/project/hts-sys)
   Compiling bio-types v0.6.0
error: failed to run custom build command for `hts-sys v1.10.2 (/project/hts-sys)`

Caused by:
  process didn't exit successfully: `/target/debug/build/hts-sys-52e216de7356c1d2/build-script-build` (exit code: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-musl = None
CC_x86_64_unknown_linux_musl = Some("x86_64-linux-musl-gcc")
CFLAGS_x86_64-unknown-linux-musl = None
CFLAGS_x86_64_unknown_linux_musl = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
echo '/* Default config.h generated by Makefile */' > config.h
echo '#define HAVE_LIBBZ2 1' >> config.h
echo '#define HTS_VERSION_TEXT ""' > version.h
echo '#define HAVE_LIBLZMA 1' >> config.h
echo '#ifndef __APPLE__' >> config.h
echo '#define HAVE_LZMA_H 1' >> config.h
echo '#endif' >> config.h
echo '#define HAVE_DRAND48 1' >> config.h
echo '#define HAVE_LIBCURL 1' >> config.h
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o kfunc.o kfunc.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o knetfile.o knetfile.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o kstring.o kstring.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o bcf_sr_sort.o bcf_sr_sort.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o bgzf.o bgzf.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o errmod.o errmod.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o faidx.o faidx.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o header.o header.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o hfile.o hfile.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o hfile_net.o hfile_net.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o hts.o hts.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o hts_os.o hts_os.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o md5.o md5.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o multipart.o multipart.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o probaln.o probaln.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o realn.o realn.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o regidx.o regidx.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o region.o region.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o sam.o sam.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o synced_bcf_reader.o synced_bcf_reader.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o vcf_sweep.o vcf_sweep.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o tbx.o tbx.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o textutils.o textutils.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o thread_pool.o thread_pool.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o vcf.o vcf.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o vcfutils.o vcfutils.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_codecs.o cram/cram_codecs.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_decode.o cram/cram_decode.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_encode.o cram/cram_encode.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_external.o cram/cram_external.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_index.o cram/cram_index.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_io.o cram/cram_io.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_samtools.o cram/cram_samtools.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/cram_stats.o cram/cram_stats.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/mFILE.o cram/mFILE.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/open_trace_file.o cram/open_trace_file.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/pooled_alloc.o cram/pooled_alloc.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/rANS_static.o cram/rANS_static.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o cram/string_alloc.o cram/string_alloc.c
x86_64-linux-musl-gcc -g -Wall -O2 -fvisibility=hidden -I.  -c -o hfile_libcurl.o hfile_libcurl.c
Makefile:133: recipe for target 'hts.o' failed
Makefile:133: recipe for target 'sam.o' failed
Makefile:133: recipe for target 'bgzf.o' failed
Makefile:133: recipe for target 'cram/cram_index.o' failed
Makefile:133: recipe for target 'cram/cram_decode.o' failed
Makefile:133: recipe for target 'cram/cram_encode.o' failed
Makefile:133: recipe for target 'cram/cram_stats.o' failed
Makefile:133: recipe for target 'cram/cram_io.o' failed
Makefile:133: recipe for target 'hfile_libcurl.o' failed

--- stderr
fatal: not a git repository: /target/x86_64-unknown-linux-musl/debug/build/hts-sys-4619d6a310e6fc8b/out/htslib/../../.git/modules/htslib
fatal: not a git repository: /target/x86_64-unknown-linux-musl/debug/build/hts-sys-4619d6a310e6fc8b/out/htslib/../../.git/modules/htslib
hts.c:29:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
make: *** [hts.o] Error 1
make: *** Waiting for unfinished jobs....
sam.c:34:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
bgzf.c:38:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
make: *** [sam.o] Error 1
make: *** [bgzf.o] Error 1
cram/cram_index.c:60:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
make: *** [cram/cram_index.o] Error 1
cram/cram_decode.c:44:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
cram/cram_encode.c:40:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
make: *** [cram/cram_decode.o] Error 1
make: *** [cram/cram_encode.o] Error 1
cram/cram_stats.c:39:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
cram/cram_io.c:51:18: fatal error: zlib.h: No such file or directory
 #include <zlib.h>
                  ^
compilation terminated.
make: *** [cram/cram_stats.o] Error 1
make: *** [cram/cram_io.o] Error 1
hfile_libcurl.c:47:23: fatal error: curl/curl.h: No such file or directory
 #include <curl/curl.h>
                       ^
compilation terminated.
make: *** [hfile_libcurl.o] Error 1
thread 'main' panicked at 'failed to build htslib', hts-sys/build.rs:111:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

There is a DEP_CURL_INCLUDE environment variable referenced in the build script. This might be what you're looking for?

There's also an open PR: Musl support for htslib 1.10.2 by brainstorm · Pull Request #193 · rust-bio/rust-htslib · GitHub Seems like MUSL is currently not supported at all. But that is probably the best bet to get started. Oh this is your PR, of course! Well, I honestly don't know where else to go, here.

Hey, thanks for taking the time to take a peek at it! Yes, I'm the author of that ongoing PR :slight_smile:

Assuming I were to use that DEP_CURL_INCLUDE include flag, how should I tell cargo to use the one under target so that it doesn't depend on the system's ones? i.e:

./target/rls/debug/build/curl-sys-cc4be84bbe4142b1/out/include/curl/curl.h

I assumed that if curl-sys is present with static cargo flags (vendored for openssl-sys if you follow the crate deps chain):

https://github.com/brainstorm/rust-htslib/blob/musl_support/hts-sys/Cargo.toml#L24

Cargo would use those includes therein by default instead of the system's ones? I should uninstall curl-dev and similar system packages and verify that the GNU build breaks, since build.rs works perfecty fine when target is x86_64-unknown-linux-gnu instead of x86_64-unknown-linux-musl... good points.

EDIT: There's another extra gotcha: how would one pass that DEP_Z_INCLUDE env var from the host to the Rustembedded's MUSL docker container via cross build?

I don't know if this helps, but GitHub - clux/muslrust: Docker environment for building musl based static linux rust binaries is a Docker image that includes support for targeting MUSL with curl and openssl.

1 Like

Yes, I tried clux's docker container in the past after going through this custom-made Dockerfile abomination of my own (which eventually worked for dynamic libs, IIRC).

Unfortunately, the clux/muslrust fails the same way as with Rustembedded's cross:

(...)
error: failed to run custom build command for `hts-sys v1.10.2 (/volume/hts-sys)`

Caused by:
  process didn't exit successfully: `/volume/target/debug/build/hts-sys-c0c8b7013e16df12/build-script-build` (exit code: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-unknown-linux-musl")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-musl = None
CC_x86_64_unknown_linux_musl = None
TARGET_CC = None
CC = Some("musl-gcc")
CFLAGS_x86_64-unknown-linux-musl = None
CFLAGS_x86_64_unknown_linux_musl = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o hts.o hts.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o cram/cram_decode.o cram/cram_decode.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o cram/cram_encode.o cram/cram_encode.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o cram/cram_index.o cram/cram_index.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o cram/cram_io.o cram/cram_io.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o cram/cram_stats.o cram/cram_stats.c
musl-gcc -g -Wall -O2 -fvisibility=hidden -fPIC -fvisibility=hidden -I.  -c -o hfile_s3.o hfile_s3.c
Makefile:133: recipe for target 'hts.o' failed
Makefile:133: recipe for target 'cram/cram_encode.o' failed
Makefile:133: recipe for target 'cram/cram_decode.o' failed
Makefile:133: recipe for target 'cram/cram_stats.o' failed
Makefile:133: recipe for target 'cram/cram_index.o' failed
Makefile:133: recipe for target 'cram/cram_io.o' failed
Makefile:133: recipe for target 'hfile_s3.o' failed

--- stderr
fatal: Not a git repository: ../../.git/modules/htslib
fatal: Not a git repository: ../../.git/modules/htslib
hts.c:29:18: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [hts.o] Error 1
make: *** Waiting for unfinished jobs....
cram/cram_encode.c:40:18: fatal error: zlib.h: No such file or directory
cram/cram_decode.c:44:18: fatal error: zlib.h: No such file or directory
compilation terminated.
compilation terminated.
cram/cram_stats.c:39:18: fatal error: zlib.h: No such file or directory
compilation terminated.
cram/cram_index.c:60:18: fatal error: zlib.h: No such file or directory
compilation terminated.
cram/cram_io.c:51:18: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [cram/cram_encode.o] Error 1
make: *** [cram/cram_decode.o] Error 1
make: *** [cram/cram_stats.o] Error 1
make: *** [cram/cram_index.o] Error 1
make: *** [cram/cram_io.o] Error 1
hfile_s3.c:94:26: fatal error: openssl/hmac.h: No such file or directory
compilation terminated.
make: *** [hfile_s3.o] Error 1
thread 'main' panicked at 'failed to build htslib', hts-sys/build.rs:109:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I just added that muslrust container back in this commit, if somebody wants to reproduce it with clux/muslrust container too.

Also, since I cannot just pass the system's -I/usr/include, because it clashes badly with other GNU headers and everything fails, I guess I'll have to manually download deps and pass the includedirs to isolated directories away from the system's /usr/include... unless somebody knows how to refer to libz-sys's header files zlib.h and/or curl-sys's header curl.h on a stable way, so I can -I/target/curl-sys/..../curl.h, for instance.... that would be neat because it would neatly self-contain all this cross-compilation process.

Going inside that clux muslrust container I just noticed a couple of things going on:

root@872d0223db02:/volume/hts-sys/htslib# CFLAGS="-I/musl/include -I/usr/include/x86_64-linux-musl" ./configure 
checking for gcc... musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether musl-gcc accepts -g... yes
checking for musl-gcc option to accept ISO C89... none needed
checking for ranlib... ranlib
checking for grep that handles long lines and -e... /bin/grep
checking for C compiler warning flags... -Wall
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking shared library type for unknown-Linux... plain .so
checking whether the compiler accepts -fvisibility=hidden... yes
checking how to run the C preprocessor... musl-gcc -E
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking for gmtime_r... yes
checking for fsync... yes
checking for drand48... yes
checking whether fdatasync is declared... yes
checking for fdatasync... yes
checking for library containing log... none required
checking for zlib.h... yes
checking for inflate in -lz... no
configure: error: zlib development files not found

HTSlib uses compression routines from the zlib library <http://zlib.net>.
Building HTSlib requires zlib development files to be installed on the build
machine; you may need to ensure a package such as zlib1g-dev (on Debian or
Ubuntu Linux) or zlib-devel (on RPM-based Linux distributions or Cygwin)
is installed.

FAILED.  This error must be resolved in order to build HTSlib successfully.

So I guess that going with custom paths is the way to go in MUSL:

root@872d0223db02:/volume/hts-sys/htslib# CFLAGS="-I/musl/include -I/usr/include/x86_64-linux-musl -L/musl/lib" ./configure 
checking for gcc... musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether musl-gcc accepts -g... yes
checking for musl-gcc option to accept ISO C89... none needed
checking for ranlib... ranlib
checking for grep that handles long lines and -e... /bin/grep
checking for C compiler warning flags... -Wall
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking shared library type for unknown-Linux... plain .so
checking whether the compiler accepts -fvisibility=hidden... yes
checking how to run the C preprocessor... musl-gcc -E
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... yes
checking for gmtime_r... yes
checking for fsync... yes
checking for drand48... yes
checking whether fdatasync is declared... yes
checking for fdatasync... yes
checking for library containing log... none required
checking for zlib.h... yes
checking for inflate in -lz... yes
checking for library containing recv... none required
checking for bzlib.h... no
checking for BZ2_bzBuffToBuffCompress in -lbz2... no
configure: error: libbzip2 development files not found

The CRAM format may use bzip2 compression, which is implemented in HTSlib
by using compression routines from libbzip2 <http://www.bzip.org/>.

Building HTSlib requires libbzip2 development files to be installed on the
build machine; you may need to ensure a package such as libbz2-dev (on Debian
or Ubuntu Linux) or bzip2-devel (on RPM-based Linux distributions or Cygwin)
is installed.

Either configure with --disable-bz2 (which will make some CRAM files
produced elsewhere unreadable) or resolve this error to build HTSlib.

So that last message means that I'll most probably have to MUSL-compile bzip2 and refer to it from the C part.... I so much wish Cargo was smart enough to use the files sitting on ./target already, specially when i.e curl-sys can be statically compiled and has all the include files under ./target... unless I'm missing some crucial bit that would make that last convenience "feature" impossible for non-pure-Rust projects that have some C? :-S

I finally got it working, but what a monstruous docker container I had to put together, check it out:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.