@cryptotaxi247 / netdata-1 / commits / 2d4e91ab5

Build optimizations (#15381)

Signed-off-by: Tasos Katsoulas <tasos@netdata.cloud>

Tasos Katsoulas committed Jul 18, 2023 at 15:05 UTC 2d4e91ab505dadf08ed2e31cbf9fa9398f1c3fb8
3 files changed +8 -7
packaging/docker/Dockerfile
+2 -2
@@ -28,8 +28,8 @@ 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)" ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf \
32 - ${EXTRA_INSTALL_OPTS} --one-time-build "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)"
31 + CFLAGS="$(packaging/docker/gen-cflags.sh)" LDFLAGS="-Wl,--gc-sections" ./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
35 RUN mkdir -p /app/usr/sbin/ \
packaging/docker/gen-cflags.sh
+2 -2
@@ -3,7 +3,7 @@
3 if [ -n "${CFLAGS}" ]; then
4 echo "${CFLAGS}"
5 elif [ -n "${DEBUG_BUILD}" ]; then
6 - echo "-Og -ggdb -pipe"
6 + echo "-ffunction-sections -fdata-sections -Og -ggdb -pipe"
7 else
8 - echo "-O2 -pipe"
8 + echo "-ffunction-sections -fdata-sections -O2 -funroll-loops -pipe"
9 fi
packaging/makeself/jobs/70-netdata-git.install.sh
+4 -3
@@ -7,12 +7,12 @@
7 cd "${NETDATA_SOURCE_PATH}" || exit 1
8
9 if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then
10 - export CFLAGS="-static -O2 -I/openssl-static/include -I/libnetfilter-acct-static/include/libnetfilter_acct -I/usr/include/libmnl -pipe"
10 + export CFLAGS="-ffunction-sections -fdata-sections -static -O2 -funroll-loops -I/openssl-static/include -I/libnetfilter-acct-static/include/libnetfilter_acct -I/usr/include/libmnl -pipe"
11 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="-static -L/openssl-static/lib -L/libnetfilter-acct-static/lib -lnetfilter_acct -L/usr/lib -lmnl"
15 +export LDFLAGS="-Wl,--gc-sections -static -L/openssl-static/lib -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
@@ -34,7 +34,8 @@ run ./netdata-installer.sh \
34 --require-cloud \
35 --use-system-protobuf \
36 --dont-scrub-cflags-even-though-it-may-break-things \
37 - --one-time-build
37 + --one-time-build \
38 + --enable-lto
39
40 # shellcheck disable=SC2015
41 [ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Finishing netdata install" || true