Skip to content

Commit 6d17c4f

Browse files
authored
libdeflate, cloudflare's zlib, versioned containers (#208)
* That is no longer the case, I encouraged @FiloSottile to bottle it up via a fork in FiloSottile/homebrew-musl-cross#13 (comment), so now it's fast to install (just a bottle pour) :) * Update both GNU and MUSL containers, add libdeflate to both * Re-add bzip2, make sure curl is cleaned up * Add libdeflate sys crate (libdeflater), unsure on whether to make it optional or just ship it enabled by default in light of @juliangehring htslib benchmarks link * Reverting changes to build.rs and Cargo.toml related to libdeflate in favor of PR #189. Leaving only docker-related setups
1 parent b9ed3ad commit 6d17c4f

File tree

7 files changed

+38
-29
lines changed

7 files changed

+38
-29
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ default = ["bzip2", "lzma", "curl"]
3737
bzip2 = ["hts-sys/bzip2"]
3838
lzma = ["hts-sys/lzma"]
3939
curl = ["hts-sys/curl"]
40-
#openssl = ["hts-sys/openssl"]
4140
serde = ["serde_base", "serde_bytes"]
4241
static = []
4342

Cross.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ passthrough = [
77

88

99
[target.x86_64-unknown-linux-musl]
10-
image = "brainstorm/cross-x86_64-unknown-linux-musl:latest"
10+
image = "brainstorm/cross-x86_64-unknown-linux-musl:1.0.0"
1111
[target.x86_64-unknown-linux-gnu]
12-
image = "brainstorm/cross-x86_64-unknown-linux-gnu:libcurl-openssl"
12+
image = "brainstorm/cross-x86_64-unknown-linux-gnu:1.0.0"

docker/Dockerfile.gnu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
FROM rustembedded/cross:x86_64-unknown-linux-gnu
22

3-
#ENV LIBCLANG_PATH /usr/lib/x86_64-linux-musl
43
ENV LIBCLANG_PATH /usr/lib/llvm-10/lib
54
ENV LLVM_CONFIG_PATH /usr/bin
65
RUN apt-get update
7-
RUN apt-get install -y wget gnupg lsb-release software-properties-common apt-transport-https ca-certificates # Otherwise LLVM bump below fails
6+
RUN apt-get install -y build-essential wget gnupg lsb-release software-properties-common apt-transport-https ca-certificates # Otherwise LLVM bump below fails
87
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
9-
RUN apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev libbz2-dev liblzma-dev # htslib deps
8+
RUN apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev libbz2-dev liblzma-dev # htslib deps
9+
RUN git clone --depth 1 https://github.com/ebiggers/libdeflate.git && \
10+
cd libdeflate && make -j40 CFLAGS="-fPIC -O3" install && \
11+
cd .. && rm -rf libdeflate

docker/Dockerfile.musl

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ RUN apt-get install -y wget gnupg lsb-release software-properties-common apt-tra
2626
# Autodetect and fetch latest LLVM repos for the current distro, avoids LLVM warnings and other issues, might generate slower builds for now though, see:
2727
# https://www.phoronix.com/scan.php?page=news_item&px=Rust-Hurt-On-LLVM-10
2828
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
29-
#RUN apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev libbz2-dev liblzma-dev musl musl-dev musl-tools # htslib deps
29+
#RUN apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev \
30+
# libbz2-dev liblzma-dev musl musl-dev musl-tools # htslib deps
3031

3132
# Remove pre-installed musl, to avoid cross-musl-make interference
3233
RUN apt-get remove -y musl
@@ -38,7 +39,8 @@ RUN wget https://github.com/richfelker/musl-cross-make/archive/v$MUSL_CROSS_MAKE
3839
&& tar xvfz v$MUSL_CROSS_MAKE_VERSION.tar.gz
3940
WORKDIR /root/musl-cross-make-$MUSL_CROSS_MAKE_VERSION
4041
COPY config-musl-cross-make.mak config.mak
41-
RUN make -j40 install
42+
RUN make -j40 install && cd .. && rm v$MUSL_CROSS_MAKE_VERSION.tar.gz
43+
#&& rm -rf musl-cross-make-*
4244

4345
# Now we assume we have a properly configured musl-cross...
4446
ENV PATH "/usr/local/musl/bin:$PATH"
@@ -52,24 +54,30 @@ ENV CPPFLAGS "-I/usr/local/musl/include -I/usr/local/include"
5254
ENV LDFLAGS "-L/usr/local/musl/lib -L/usr/local/lib"
5355

5456
# .. and carry on with the htslib deps
55-
RUN wget https://www.zlib.net/zlib-$ZLIB_VERSION.tar.gz \
56-
&& tar xvfz zlib-$ZLIB_VERSION.tar.gz \
57-
&& cd zlib-$ZLIB_VERSION \
58-
&& ./configure --static --prefix=/usr/local/musl \
59-
&& make -j40 install
6057
WORKDIR /root
58+
RUN git clone --depth 1 https://github.com/ebiggers/libdeflate.git && \
59+
cd libdeflate && make -j40 CFLAGS="-fPIC -O3" PREFIX="/usr/local/musl" install && \
60+
cd .. && rm -rf libdeflate
61+
RUN git clone https://github.com/cloudflare/zlib cloudflare-zlib && \
62+
cd cloudflare-zlib && ./configure --static --prefix=/usr/local/musl && \
63+
make install && cd .. && rm -rf cloudflare-zlib
64+
#RUN wget https://www.zlib.net/zlib-$ZLIB_VERSION.tar.gz \
65+
# && tar xvfz zlib-$ZLIB_VERSION.tar.gz \
66+
# && cd zlib-$ZLIB_VERSION \
67+
# && ./configure --static --prefix=/usr/local/musl \
68+
# && make -j40 install
6169
RUN git clone git://sourceware.org/git/bzip2 \
6270
&& cd bzip2 \
63-
#&& make -j40 CC=$CC AR=$AR RANLIB=$RANLIB CFLAGS=$CFLAGS bzip2 \
71+
&& make -j40 CC=$CC AR=$AR RANLIB=$RANLIB CFLAGS=$CFLAGS bzip2 \
6472
&& make PREFIX=/usr/local/musl -j40 bzip2 \
65-
&& make -j40 install
66-
WORKDIR /root
73+
&& make -j40 install && cd .. && rm -rf bzip2
6774
RUN wget https://tukaani.org/xz/xz-$LZMA_VERSION.tar.bz2 \
6875
&& tar xvfj xz-$LZMA_VERSION.tar.bz2 \
6976
&& cd xz-$LZMA_VERSION \
70-
&& ./configure --prefix=/usr/local/musl --enable-static --disable-shared --host x86_64-unknown-linux-musl \
71-
&& make -j40 install
72-
WORKDIR /root
77+
&& ./configure --prefix=/usr/local/musl \
78+
--enable-static --disable-shared \
79+
--host x86_64-unknown-linux-musl \
80+
&& make -j40 install && cd .. && rm -rf xz-$LZMA_VERSION xz-$LZMA_VERSION.tar.bz2
7381

7482
# A few gems from: https://wiki.openssl.org/index.php/Compilation_and_Installation
7583
# "OpenSSL has been around a long time, and it carries around a lot of cruft"
@@ -91,20 +99,20 @@ RUN wget https://github.com/openssl/openssl/archive/OpenSSL_$OPENSSL_VERSION.tar
9199
&& make AR=x86_64-linux-musl-ar \
92100
CC=x86_64-linux-musl-cc \
93101
-j40 \
94-
&& make RANLIB=x86_64-linux-musl-ranlib -j40 install
102+
&& make RANLIB=x86_64-linux-musl-ranlib -j40 install && cd .. \
103+
&& rm -rf OpenSSL_$OPENSSL_VERSION.tar.gz openssl-OpenSSL_$OPENSSL_VERSION
95104

96-
WORKDIR /root
97105
RUN wget https://curl.haxx.se/download/curl-$CURL_VERSION.tar.gz \
98106
&& tar xvfz curl-$CURL_VERSION.tar.gz && cd curl-$CURL_VERSION \
99107
&& ./configure --prefix=/usr/local/musl --host x86_64-linux-musl \
100108
--with-ssl=/usr/local/musl --with-zlib=/usr/local/musl --enable-static \
101-
--disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap \
109+
--disable-dict --disable-ftp --disable-gopher --disable-imap \
102110
--disable-pop3 --disable-rtsp --disable-smb --disable-smtp --disable-telnet \
103111
--disable-tftp --disable-ntlm --disable-ldap \
104-
&& make -j40 install
112+
&& make -j40 install && cd .. \
113+
&& rm -rf curl-$CURL_VERSION.tar.gz curl-$CURL_VERSION
105114

106115
# To cater Rust's openssl-sys needs...
107-
#ENV OPENSSL_DIR /usr/local/openssl
108116
ENV OPENSSL_DIR /usr/local/musl
109117

110118
# Hack to force ld stick to musl on the hts-sys/build.rs side, otherwise:
@@ -118,4 +126,4 @@ RUN rm /usr/bin/ld && ln -sf /usr/local/musl/bin/x86_64-linux-musl-ld /usr/bin/l
118126
# && . $HOME/.cargo/env \
119127
# && rustup target add x86_64-unknown-linux-musl
120128

121-
CMD ["bash"]
129+
CMD ["bash"]

docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Allows to compile (rust-)htslib in a variety of environments and architectures v
66

77
```shell
88
$ cd docker
9-
$ docker build -t brainstorm/cross-x86_64-unknown-linux-musl:libcurl-openssl . -f Dockerfile.musl
10-
$ docker build -t brainstorm/cross-x86_64-unknown-linux-gnu:libcurl-openssl . -f Dockerfile.gnu
9+
$ docker build -t brainstorm/cross-x86_64-unknown-linux-musl:1.0.0 . -f Dockerfile.musl
10+
$ docker build -t brainstorm/cross-x86_64-unknown-linux-gnu:1.0.0 . -f Dockerfile.gnu
1111
```
1212

1313
Then, to build and test rust-htslib with the above containers, proceed as you would with `cargo`, using `cross` instead, i.e:

hts-sys/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ curl-sys = { version = "0.4.31", optional = true, features = ["static-curl", "st
2727
default = ["bzip2", "lzma"]
2828
bzip2 = ["bzip2-sys"]
2929
lzma = ["lzma-sys"]
30-
#openssl = ["openssl-sys"]
3130
curl = ["curl-sys"]
3231
static = []
3332

3433
[build-dependencies]
3534
fs-utils = "1.1"
3635
bindgen = { version = "0.53.2", default-features = false, features = ["runtime"] }
3736
cc = "1.0"
38-
glob = "0.3.0"
37+
glob = "0.3.0"

hts-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fn main() {
7373
} else if let Ok(inc) = env::var("DEP_CURL_INCLUDE").map(PathBuf::from) {
7474
cfg.include(inc);
7575
}
76+
7677

7778
let tool = cfg.get_compiler();
7879
let (cc_path, cflags_env) = (tool.path(), tool.cflags_env());

0 commit comments

Comments
 (0)