0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-08 07:10:12 +00:00
netdata_netdata/packaging/makeself/jobs/20-libunwind.install.sh
Costa Tsaousis e90f3f4e22
enable libunwind in static builds ()
* enable libunwind in static builds

* add libunwind and backtrace to buildinfo

* add linunwind to alpine packages

* add -dev packages

* add remove libunwind binary from the packages

* Vendor libunwind in static builds instead of using a copy from the build environment.

This is required to ensure that the C++ exception handling functionality
in libunwind is _disabled_, because it does not play nice with static
linking when using C++ with exception handling support enabled.

* Remove changes from local testing.

* Fix cross architecture builds.

* Disable libunwind on 64-bit POWER builds.

musl libc does not include functions that are required to build
libunwind for this platform, so just disable it there for now.

---------

Co-authored-by: Austin S. Hemmelgarn <austin@netdata.cloud>
2025-03-06 12:39:10 +02:00

59 lines
1.8 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# Cant do libunwind on ppc64le with musl, so skip it.
[ "${BUILDARCH}" = "ppc64le" ] && exit 0
# shellcheck source=packaging/makeself/functions.sh
. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
# Source of truth for all the packages we bundle in static builds
. "$(dirname "${0}")/../bundled-packages.version"
# shellcheck disable=SC2015
[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building libunwind" || true
export CFLAGS="${TUNING_FLAGS} -fno-lto -pipe"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-static"
export PKG_CONFIG="pkg-config --static"
if [ -d "${NETDATA_MAKESELF_PATH}/tmp/libunwind" ]; then
rm -rf "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
fi
cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/libunwind"
if [ -d "${cache}" ]; then
echo "Found cached copy of build directory for libunwind, using it."
cp -a "${cache}/libunwind" "${NETDATA_MAKESELF_PATH}/tmp/"
CACHE_HIT=1
else
echo "No cached copy of build directory for libunwind found, fetching sources instead."
run git clone "${LIBUNWIND_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
cd "${NETDATA_MAKESELF_PATH}/tmp/libunwind" && run git checkout "${LIBUNWIND_VERSION}"
CACHE_HIT=0
fi
cd "${NETDATA_MAKESELF_PATH}/tmp/libunwind" || exit 1
if [ "${CACHE_HIT:-0}" -eq 0 ]; then
run autoreconf -ivf
run ./configure \
--prefix=/libunwind-static \
--build="$(gcc -dumpmachine)" \
--disable-cxx-exceptions \
--disable-documentation \
--disable-tests \
--disable-shared \
--enable-static \
--disable-dependency-tracking
run make -j "$(nproc)"
fi
run make -j "$(nproc)" install
store_cache libunwind "${NETDATA_MAKESELF_PATH}/tmp/libunwind"
# shellcheck disable=SC2015
[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true