Skip to content

Commit

Permalink
Add script to download + build libelf and zlib
Browse files Browse the repository at this point in the history
usage:

```
$ tools/build_deps
$ export RUSTFLAGS="-L $PWD/target/static-libs"
$ cargo b # will now link against libelf and zlib
```

This allows us to have more control on the actual version of
both libraries that libbpf depends on, rather than always using
the ones installed by a package manager or a previous manual
installation.

They are compiled with clang and frame pointers. See comment
for the warnings that were disabled to compile elfutils with clang.

Signed-off-by: Francisco Javier Honduvilla Coto <javierhonduco@gmail.com>
  • Loading branch information
javierhonduco committed Jan 22, 2023
1 parent 10aff35 commit 44d3de7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
62 changes: 62 additions & 0 deletions tools/build_deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -o errexit nounset pipefail

NPROC=$(nproc --all)
ELFUTILS_VERSION="0.188"
ELFUTILS_SHA_512="585551b2d937d19d1becfc2f28935db1dd1a3d25571a62f322b70ac8da98c1a741a55d070327705df6c3e2ee026652e0b9a3c733b050a0b0ec5f2fc75d5b74b5"

ZLIB_VERSION="1.2.13"
ZLIB_SHA256="b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"

run() {
"$@" >/dev/null 2>&1
}

mkdir -p target/static-libs
mkdir -p target/static-libs/libz
mkdir -p target/static-libs/elfutils
STATIC_LIBS_OUT_PATH="${PWD}/target/static-libs"

run pushd "${STATIC_LIBS_OUT_PATH}"

# Notes:
# * -fpic is not the same as -FPIC
# https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
#
# * cflags required for clang to compile elfutils
export CFLAGS="-fno-omit-frame-pointer -fpic -Wno-gnu-variable-sized-type-not-at-end -Wno-unused-but-set-parameter"
export CC=clang

echo "=> Building elfutils"
run curl -L -O "https://sourceware.org/pub/elfutils/${ELFUTILS_VERSION}/elfutils-${ELFUTILS_VERSION}.tar.bz2"
if ! sha512sum "elfutils-${ELFUTILS_VERSION}.tar.bz2" | grep -q "$ELFUTILS_SHA_512"; then
echo "Checksum for elfutils doesn't match"
exit 1
fi

run tar xjf "elfutils-${ELFUTILS_VERSION}.tar.bz2"

run pushd "elfutils-${ELFUTILS_VERSION}"
run ./configure --prefix="${STATIC_LIBS_OUT_PATH}/elfutils" --disable-debuginfod --disable-libdebuginfod

run make "-j${NPROC}"
run make install
cp "${STATIC_LIBS_OUT_PATH}/elfutils/lib/libelf.a" "${STATIC_LIBS_OUT_PATH}"
run popd

echo "=> Building zlib"
run curl -L -O "https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz"
if ! sha256sum "zlib-${ZLIB_VERSION}.tar.gz" | grep -q "$ZLIB_SHA256"; then
echo "Checksum for zlib doesn't match"
exit 1
fi
run tar xzf zlib-${ZLIB_VERSION}.tar.gz

run pushd "zlib-${ZLIB_VERSION}"
run ./configure --prefix="${STATIC_LIBS_OUT_PATH}/libz" >/dev/null
run make "-j${NPROC}" >/dev/null
run make install >/dev/null
cp "${STATIC_LIBS_OUT_PATH}/libz/lib/libz.a" "${STATIC_LIBS_OUT_PATH}"
run popd

run popd
12 changes: 6 additions & 6 deletions tools/pull_ruby_images
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

ruby_versions=(
2.6.0
2.6.3
2.7.1
2.6.3
2.7.1
2.7.4
2.7.6
3.0.0
3.0.4
3.1.2
3.0.0
3.0.4
3.1.2
)

for ruby_version in "${ruby_versions[@]}"; do
podman pull ruby:$ruby_version
podman pull "ruby:$ruby_version"
done

0 comments on commit 44d3de7

Please sign in to comment.