Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ssl issue and improve musl builds #720

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[build]
rustflags = ["-C", "target-cpu=native"]

[target.x86_64-unknown-linux-musl]
rustflags = [
"-C", "target-cpu=native",
"-C", "link-arg=-lc",
"-C", "link-arg=-lstdc++",
"-C", "link-arg=-lgcc",
"-C", "link-arg=-lgcc_eh",
]
1 change: 1 addition & 0 deletions .depignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openssl
Licenser marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion .github/checks/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi

cnt=0

for d in $(remarshal -i $path/Cargo.toml -of json | jq -r '.dependencies | keys []')
for d in $(remarshal -i $path/Cargo.toml -of json | jq -r '.dependencies | keys []' | grep -v -f .depignore)
do
dep=$(echo $d | sed -e 's/-/_/g')
if ! rg "use $dep(::|;| )" $path -trust > /dev/null
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Default to thin-lto for all builds (prior this was only done in docker)
* Automatically generate rpms and tarballs for releases.
* Update rust to 1.49.0
* Build deb packages
* Statically link openssl

## 0.9.4

Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ postgres-protocol = "0.6"
tokio-postgres = "0.7"

# kafka. cmake is the encouraged way to build this and also the one that works on windows/with musl.
rdkafka = {version = "0.24", features = ["cmake-build", "libz"], default-features = false}
rdkafka-sys = {version = "2.0.0", features = ["cmake-build", "libz"]}# tracking the version rdkafka depends on
rdkafka = {version = "0.24", features = ["cmake-build", "libz-static"], default-features = false}
rdkafka-sys = {version = "2.0.0", features = ["cmake-build", "libz-static"]}# tracking the version rdkafka depends on

# crononome
cron = "0.7.0"
Expand All @@ -100,7 +100,7 @@ grok = "1"

# not used directly in tremor codebase, but present here so that we can turn
# on features for these (see static-ssl feature here)
#openssl = { version = "0.10" }
openssl = { version = "0.10", features = ["vendored"] }

# rest onramp
tide = "0.15"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RELEASE_TARGETS := \
# packaging using debian image itself (might also need to have separate build for
# archive packaging too).
#RELEASE_FORMATS_x86_64-unknown-linux-gnu := archive,deb,rpm
RELEASE_FORMATS_x86_64-unknown-linux-gnu := archive,rpm
RELEASE_FORMATS_x86_64-unknown-linux-gnu := archive,rpm,deb
RELEASE_FORMATS_x86_64-alpine-linux-musl := archive
RELEASE_FORMATS_x86_64-unknown-linux-musl := archive

Expand Down
12 changes: 12 additions & 0 deletions packaging/builder-images/Dockerfile.x86_64-debian-linux-gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG RUST_VERSION

# update the version here as needed
# may bring updates to things like glibc so proceed carefully.
# via https://hub.docker.com/_/rust
FROM rust:${RUST_VERSION}-buster

COPY shared/install_dependencies_debian.sh /
RUN /install_dependencies_debian.sh

COPY shared/entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
40 changes: 26 additions & 14 deletions packaging/builder-images/Dockerfile.x86_64-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG RUST_VERSION

# update the version here as needed
# via https://hub.docker.com/_/rust
FROM rust:${RUST_VERSION}-buster
FROM rustembedded/cross:x86_64-unknown-linux-musl-0.2.1

# install musl
# this setup borrowed from https://github.com/rust-embedded/cross/blob/v0.2.0/docker/musl.sh#L44
Expand All @@ -16,21 +16,33 @@ RUN temp_dir=$(mktemp -d) \
&& cd $temp_dir \
&& curl -L https://github.com/richfelker/musl-cross-make/archive/v0.9.9.tar.gz | tar --strip-components=1 -xz \
&& make install -j$(nproc) \
GCC_VER=9.2.0 \
MUSL_VER=1.2.0 \
DL_CMD="curl -C - -L -o" \
OUTPUT=/usr/local/ \
TARGET=x86_64-linux-musl \
GCC_VER=9.2.0 \
MUSL_VER=1.2.0 \
DL_CMD="curl -C - -L -o" \
OUTPUT=/usr/local/ \
TARGET=x86_64-linux-musl \
&& rm -rf $temp_dir

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc \
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++

RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update; \
apt-get install -y \
cmake `# for building C deps` \
libclang-dev `# for onig_sys (via the regex crate)` \
libssl-dev `# for openssl (via surf)` \
libsasl2-dev `# for librdkafka` \
libzstd-dev `# for librdkafka`; \
apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

#COPY shared/entrypoint.sh /
#ENTRYPOINT [ "/entrypoint.sh" ]


ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc \
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++

COPY shared/install_dependencies_debian.sh /
RUN /install_dependencies_debian.sh

COPY shared/entrypoint.sh /
ENTRYPOINT [ "/entrypoint.sh" ]
# COPY shared/entrypoint.sh /
Licenser marked this conversation as resolved.
Show resolved Hide resolved
# ENTRYPOINT [ "/entrypoint.sh" ]
6 changes: 4 additions & 2 deletions packaging/builder-images/publish_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ set -o errexit
# catch exit status for piped commands
set -o pipefail

RUST_TOOLCHAIN_FILE="../../rust-toolchain"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"


RUST_TOOLCHAIN_FILE="${SCRIPT_DIR}/../../rust-toolchain"
RUST_VERSION=$(<"$RUST_TOOLCHAIN_FILE")

IMAGES=(
Expand All @@ -28,4 +31,3 @@ IMAGES=(
for image in "${IMAGES[@]}"; do
docker push "tremorproject/${image}"
done
./publish_images
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ apt-get update
apt-get install -y \
cmake `# for building C deps` \
libclang-dev `# for onig_sys (via the regex crate)` \
libssl-dev `# for openssl (via surf)`
libssl-dev `# for openssl (via surf)` \
libsasl2-dev `# for librdkafka` \
libzstd-dev `# for librdkafka`

# cleanup
echo apt-get autoremove -y \
apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
2 changes: 2 additions & 0 deletions packaging/cross_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ fi
export RUSTFLAGS="${RUSTFLAGS} ${CUSTOM_RUSTFLAGS[@]}"
echo "RUSTFLAGS set to: ${RUSTFLAGS}"

cross -V

cross build -p tremor-cli "${BUILD_ARGS[@]}"

TARGET_BIN="${ROOT_DIR}/target/${TARGET}/${BUILD_MODE}/${BIN_NAME}"
Expand Down