@cryptotaxi247 / netdata-1 / commits / b090c9f80

Fix static build SSL (#15842)

Costa Tsaousis committed Aug 21, 2023 at 11:19 UTC b090c9f80b64005003294d4b8390bd9b6cf0aecf
11 files changed +56 -17
collectors/freeipmi.plugin/freeipmi_plugin.c
+3
@@ -1450,6 +1450,9 @@ int main (int argc, char **argv) {
1450 error_log_errors_per_period = 100;
1451 error_log_throttle_period = 3600;
1452
1453 + // initialize the threads
1454 + netdata_threads_init_for_external_plugins(0); // set the default threads stack size here
1455 +
1456 // ------------------------------------------------------------------------
1457 // parse command line parameters
1458
collectors/systemd-journal.plugin/systemd-journal.c
+3
@@ -546,6 +546,9 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) {
546 error_log_errors_per_period = 100;
547 error_log_throttle_period = 3600;
548
549 + // initialize the threads
550 + netdata_threads_init_for_external_plugins(0); // set the default threads stack size here
551 +
552 uids = dictionary_create(0);
553 gids = dictionary_create(0);
554
libnetdata/threads/threads.c
+17 -4
@@ -123,10 +123,12 @@ size_t netdata_threads_init(void) {
123 // --------------------------------------------------------------------
124 // get the required stack size of the threads of netdata
125
126 - netdata_threads_attr = callocz(1, sizeof(pthread_attr_t));
127 - i = pthread_attr_init(netdata_threads_attr);
128 - if(i != 0)
129 - fatal("pthread_attr_init() failed with code %d.", i);
126 + if(!netdata_threads_attr) {
127 + netdata_threads_attr = callocz(1, sizeof(pthread_attr_t));
128 + i = pthread_attr_init(netdata_threads_attr);
129 + if (i != 0)
130 + fatal("pthread_attr_init() failed with code %d.", i);
131 + }
132
133 size_t stacksize = 0;
134 i = pthread_attr_getstacksize(netdata_threads_attr, &stacksize);
@@ -158,6 +160,17 @@ void netdata_threads_init_after_fork(size_t stacksize) {
160 netdata_log_error("Invalid pthread stacksize %zu", stacksize);
161 }
162
163 +// ----------------------------------------------------------------------------
164 +// threads init for external plugins
165 +
166 +void netdata_threads_init_for_external_plugins(size_t stacksize) {
167 + size_t default_stacksize = netdata_threads_init();
168 + if(default_stacksize < 1 * 1024 * 1024)
169 + default_stacksize = 1 * 1024 * 1024;
170 +
171 + netdata_threads_init_after_fork(stacksize ? stacksize : default_stacksize);
172 +}
173 +
174 // ----------------------------------------------------------------------------
175 // netdata_thread_create
176
libnetdata/threads/threads.h
+1
@@ -59,6 +59,7 @@ int netdata_thread_tag_exists(void);
59
60 size_t netdata_threads_init(void);
61 void netdata_threads_init_after_fork(size_t stacksize);
62 +void netdata_threads_init_for_external_plugins(size_t stacksize);
63
64 int netdata_thread_create(netdata_thread_t *thread, const char *tag, NETDATA_THREAD_OPTIONS options, void *(*start_routine) (void *), void *arg);
65
packaging/docker/Dockerfile
+1 -1
@@ -28,7 +28,7 @@ WORKDIR /opt/netdata.git
28 RUN chmod +x netdata-installer.sh && \
29 cp -rp /deps/* /usr/local/ && \
30 /bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \
31 - CFLAGS="$(packaging/docker/gen-cflags.sh)" LDFLAGS="-Wl,--gc-sections" ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf \
31 + CFLAGS="$(packaging/docker/gen-cflags.sh)" LDFLAGS="-Wl,--gc-sections -Wl,-z,stack-size=8388608" ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf \
32 ${EXTRA_INSTALL_OPTS} --one-time-build --enable-lto "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)"
33
34 # files to one directory
packaging/makeself/curl.version new
+1
@@ -0,0 +1 @@
1 +curl-8_2_1
packaging/makeself/jobs/20-openssl.install.sh
+4 -1
@@ -36,7 +36,8 @@ fi
36 cd "${NETDATA_MAKESELF_PATH}/tmp/openssl" || exit 1
37
38 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
39 - run ./config -static no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl
39 + sed -i "s/disable('static', 'pic', 'threads');/disable('static', 'pic');/" Configure
40 + run ./config -static threads no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl
41 run make -j "$(nproc)"
42 fi
43
@@ -44,5 +45,7 @@ run make -j "$(nproc)" install_sw
45
46 store_cache openssl "${NETDATA_MAKESELF_PATH}/tmp/openssl"
47
48 +perl configdata.pm --dump
49 +
50 # shellcheck disable=SC2015
51 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true
packaging/makeself/jobs/50-bash-5.1.16.install.sh
+1 -1
@@ -13,7 +13,7 @@ fetch "bash-${version}" "http://ftp.gnu.org/gnu/bash/bash-${version}.tar.gz" \
13 5bac17218d3911834520dad13cd1f85ab944e1c09ae1aba55906be1f8192f558 bash
14
15 export CFLAGS="-pipe"
16 -export PKG_CONFIG_PATH="/openssl-static/lib/pkgconfig"
16 +export PKG_CONFIG_PATH="/openssl-static/lib64/pkgconfig"
17
18 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
19 run ./configure \
packaging/makeself/jobs/50-curl.install.sh renamed
+21 -6
@@ -4,18 +4,33 @@
4 # shellcheck source=packaging/makeself/functions.sh
5 . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1
6
7 -version="7.87.0"
7 +version="$(cat "$(dirname "${0}")/../curl.version")"
8
9 # shellcheck disable=SC2015
10 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building cURL" || true
11
12 -fetch "curl-${version}" "https://curl.haxx.se/download/curl-${version}.tar.gz" \
13 - 8a063d664d1c23d35526b87a2bf15514962ffdd8ef7fd40519191b3c23e39548 curl
12 +if [ -d "${NETDATA_MAKESELF_PATH}/tmp/curl" ]; then
13 + rm -rf "${NETDATA_MAKESELF_PATH}/tmp/curl"
14 +fi
15 +
16 +cache="${NETDATA_SOURCE_PATH}/artifacts/cache/${BUILDARCH}/curl"
17 +
18 +if [ -d "${cache}" ]; then
19 + echo "Found cached copy of build directory for curl, using it."
20 + cp -a "${cache}/curl" "${NETDATA_MAKESELF_PATH}/tmp/"
21 + CACHE_HIT=1
22 +else
23 + echo "No cached copy of build directory for curl found, fetching sources instead."
24 + run git clone --branch "${version}" --single-branch --depth 1 'https://github.com/curl/curl.git' "${NETDATA_MAKESELF_PATH}/tmp/curl"
25 + CACHE_HIT=0
26 +fi
27 +
28 +cd "${NETDATA_MAKESELF_PATH}/tmp/curl" || exit 1
29
30 export CFLAGS="-I/openssl-static/include -pipe"
16 -export LDFLAGS="-static -L/openssl-static/lib"
31 +export LDFLAGS="-static -L/openssl-static/lib64"
32 export PKG_CONFIG="pkg-config --static"
18 -export PKG_CONFIG_PATH="/openssl-static/lib/pkgconfig"
33 +export PKG_CONFIG_PATH="/openssl-static/lib64/pkgconfig"
34
35 if [ "${CACHE_HIT:-0}" -eq 0 ]; then
36 run autoreconf -fi
@@ -52,7 +67,7 @@ fi
67
68 run make install
69
55 -store_cache curl "${NETDATA_MAKESELF_PATH}/tmp/curl-${version}"
70 +store_cache curl "${NETDATA_MAKESELF_PATH}/tmp/curl"
71
72 if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
73 run strip "${NETDATA_INSTALL_PATH}"/bin/curl
packaging/makeself/jobs/70-netdata-git.install.sh
+3 -3
@@ -12,7 +12,7 @@ else
12 export CFLAGS="-static -O1 -pipe -ggdb -Wall -Wextra -Wformat-signedness -DNETDATA_INTERNAL_CHECKS=1 -I/openssl-static/include -I/libnetfilter-acct-static/include/libnetfilter_acct -I/usr/include/libmnl"
13 fi
14
15 -export LDFLAGS="-Wl,--gc-sections -static -L/openssl-static/lib -L/libnetfilter-acct-static/lib -lnetfilter_acct -L/usr/lib -lmnl"
15 +export LDFLAGS="-Wl,--gc-sections -Wl,-z,stack-size=$[8 * 1024 * 1024] -static -L/openssl-static/lib64 -L/libnetfilter-acct-static/lib -lnetfilter_acct -L/usr/lib -lmnl"
16
17 # We export this to 'yes', installer sets this to .environment.
18 # The updater consumes this one, so that it can tell whether it should update a static install or a non-static one
@@ -21,11 +21,11 @@ export IS_NETDATA_STATIC_BINARY="yes"
21 # Set eBPF LIBC to "static" to bundle the `-static` variant of the kernel-collector
22 export EBPF_LIBC="static"
23 export PKG_CONFIG="pkg-config --static"
24 -export PKG_CONFIG_PATH="/openssl-static/lib/pkgconfig:/libnetfilter-acct-static/lib/pkgconfig:/usr/lib/pkgconfig"
24 +export PKG_CONFIG_PATH="/openssl-static/lib64/pkgconfig:/libnetfilter-acct-static/lib/pkgconfig:/usr/lib/pkgconfig"
25
26 # Set correct CMake flags for building against non-System OpenSSL
27 # See: https://github.com/warmcat/libwebsockets/blob/master/READMEs/README.build.md
28 -export CMAKE_FLAGS="-DOPENSSL_ROOT_DIR=/openssl-static -DOPENSSL_LIBRARIES=/openssl-static/lib -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static -DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include -DLWS_OPENSSL_LIBRARIES=/openssl-static/lib/libssl.a;/openssl-static/lib/libcrypto.a"
28 +export CMAKE_FLAGS="-DOPENSSL_ROOT_DIR=/openssl-static -DOPENSSL_LIBRARIES=/openssl-static/lib64 -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static -DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include -DLWS_OPENSSL_LIBRARIES=/openssl-static/lib64/libssl.a;/openssl-static/lib64/libcrypto.a"
29
30 run ./netdata-installer.sh \
31 --install-prefix "${NETDATA_INSTALL_PARENT}" \
packaging/makeself/openssl.version
+1 -1
@@ -1 +1 @@
1 -OpenSSL_1_1_1v
1 +openssl-3.1.2