Include libucontext in static builds to vendor libunwind even on POWER. (#19817)
Austin S. Hemmelgarn committed
Mar 11, 2025 at 06:58 UTC
fcb6217301b634ecb34136bfdef332097e67ae2b
3 files changed
+52
-5
packaging/makeself/bundled-packages.version
+2
@@ -3,6 +3,8 @@ PACKAGES=("OPENSSL" "CURL" "BASH" "IOPING" "LIBNETFILTER_ACT")
3
SOURCE_TYPES=("GH_REPO_CLONE" "GH_REPO_CLONE" "DW_TARBALL" "GH_REPO_SOURCE" "DW_TARBALL")
4
OPENSSL_VERSION="openssl-3.4.0"
5
OPENSSL_SOURCE="https://github.com/openssl/openssl"
6
+LIBUCONTEXT_VERSION="libucontext-1.3.2"
7
+LIBUCONTEXT_SOURCE="https://github.com/kaniini/libucontext"
8
LIBUNWIND_VERSION="177deb5f89c5d792c9618db54fdcebd260e271e8" # Should be updated to a stable version once https://github.com/libunwind/libunwind/issues/742 is fixed.
9
LIBUNWIND_SOURCE="https://github.com/libunwind/libunwind"
10
CURL_VERSION="curl-8_11_1"
packaging/makeself/jobs/15-libucontext.install.sh
new
+48
@@ -0,0 +1,48 @@
1
+#!/usr/bin/env bash
2
+# SPDX-License-Identifier: GPL-3.0-or-later
3
+
4
+# shellcheck source=packaging/makeself/functions.sh
5
+. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6
+# Source of truth for all the packages we bundle in static builds
7
+. "$(dirname "${0}")/../bundled-packages.version"
8
+# shellcheck disable=SC2015
9
+[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building libucontext" || true
10
+
11
+export CFLAGS="${TUNING_FLAGS} -pipe"
12
+export CXXFLAGS="${CFLAGS}"
13
+export LDFLAGS=""
14
+
15
+if [ -d "${NETDATA_MAKESELF_PATH}/tmp/libucontext" ]; then
16
+ rm -rf "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
17
+fi
18
+
19
+cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/libucontext"
20
+
21
+if [ -d "${cache}" ]; then
22
+ echo "Found cached copy of build directory for libucontext, using it."
23
+ cp -a "${cache}/libucontext" "${NETDATA_MAKESELF_PATH}/tmp/"
24
+ CACHE_HIT=1
25
+else
26
+ echo "No cached copy of build directory for libucontext found, fetching sources instead."
27
+ run git clone --branch "${LIBUCONTEXT_VERSION}" --single-branch --depth 1 "${LIBUCONTEXT_SOURCE}" "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
28
+ CACHE_HIT=0
29
+fi
30
+
31
+cd "${NETDATA_MAKESELF_PATH}/tmp/libucontext" || exit 1
32
+
33
+case "${BUILDARCH}" in
34
+ armv6l|armv7l) arch=arm ;;
35
+ ppc64le) arch=ppc64 ;;
36
+ *) arch="${BUILDARCH}" ;;
37
+esac
38
+
39
+if [ "${CACHE_HIT:-0}" -eq 0 ]; then
40
+ run make ARCH="${arch}" EXPORT_UNPREFIXED="yes" -j "$(nproc)"
41
+fi
42
+
43
+run make ARCH="${arch}" EXPORT_UNPREFIXED="yes" DESTDIR="/libucontext-static" -j "$(nproc)" install
44
+
45
+store_cache libucontext "${NETDATA_MAKESELF_PATH}/tmp/libucontext"
46
+
47
+# shellcheck disable=SC2015
48
+[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/20-libunwind.install.sh
+2
-5
@@ -1,9 +1,6 @@
1
#!/usr/bin/env bash
2
# SPDX-License-Identifier: GPL-3.0-or-later
3
4
-# Can’t do libunwind on ppc64le with musl, so skip it.
5
-[ "${BUILDARCH}" = "ppc64le" ] && exit 0
6
-
4
# shellcheck source=packaging/makeself/functions.sh
5
. "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6
# Source of truth for all the packages we bundle in static builds
@@ -11,9 +8,9 @@
8
# shellcheck disable=SC2015
9
[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building libunwind" || true
10
14
-export CFLAGS="${TUNING_FLAGS} -fno-lto -pipe"
11
+export CFLAGS="${TUNING_FLAGS} -I/libucontext-static/usr/include -fno-lto -pipe"
12
export CXXFLAGS="${CFLAGS}"
16
-export LDFLAGS="-static"
13
+export LDFLAGS="-static -L/libucontext-static/usr/lib/ -lucontext"
14
export PKG_CONFIG="pkg-config --static"
15
16
if [ -d "${NETDATA_MAKESELF_PATH}/tmp/libunwind" ]; then