-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to download + build libelf and zlib
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
1 parent
10aff35
commit 44d3de7
Showing
2 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
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 |
This file contains 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