Skip to content

Commit 6ee8096

Browse files
authored
java: Fix async-profiler compatibility on CentOS 6 (#453)
This PR fixes compatibility with CentOS 6. When we switched to build on CentOS 7, we didn't pass the -static-libstdc++ flag, and at the point when we fixed that regression, we didn't test for CentOS 6 support, which broke because -static-libstdc++ pulls in some symbols which require newer glibc. This PR avoids -static-libstdc++ on glibc; it's required for musl-based because musl-based JVMs aren't always dependent on libstdc++; and we've never seen that with glibc. Additionally, this PR adds a test for final dependency resolving compatibility on CentOS 6. Also included is a cherry pick of async-profiler/async-profiler@b8c8db4, which prevents async-profiler from crashing if it is re-loaded after a previous load has failed.
1 parent 6f0d767 commit 6ee8096

4 files changed

+15
-3
lines changed

pyi.Dockerfile

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ARG PERF_BUILDER_UBUNTU
77
ARG PHPSPY_BUILDER_UBUNTU
88
ARG AP_BUILDER_CENTOS
99
ARG AP_BUILDER_ALPINE
10+
ARG AP_CENTOS_MIN
1011
ARG BURN_BUILDER_GOLANG
1112
ARG GPROFILER_BUILDER
1213
ARG PYPERF_BUILDER_UBUNTU
@@ -64,6 +65,12 @@ COPY scripts/async_profiler_build_shared.sh .
6465
COPY scripts/async_profiler_build_glibc.sh .
6566
RUN ./async_profiler_build_shared.sh /tmp/async_profiler_build_glibc.sh
6667

68+
# a build step to ensure the minimum CentOS version that we require can "ldd" our libasyncProfiler.so file.
69+
FROM centos${AP_CENTOS_MIN} AS async-profiler-centos-min-test-glibc
70+
SHELL ["/bin/bash", "-c", "-euo", "pipefail"]
71+
COPY --from=async-profiler-builder-glibc /tmp/async-profiler/build/libasyncProfiler.so /libasyncProfiler.so
72+
RUN if ldd /libasyncProfiler.so 2>&1 | grep -q "not found" ; then echo "libasyncProfiler.so is not compatible with minimum CentOS!"; ldd /libasyncProfiler.so; exit 1; fi
73+
6774
# async-profiler musl
6875
FROM alpine${AP_BUILDER_ALPINE} AS async-profiler-builder-musl
6976
WORKDIR /tmp
@@ -234,7 +241,7 @@ COPY --from=async-profiler-builder-glibc /usr/bin/xargs gprofiler/resources/php/
234241

235242
COPY --from=async-profiler-builder-glibc /tmp/async-profiler/build/jattach gprofiler/resources/java/jattach
236243
COPY --from=async-profiler-builder-glibc /tmp/async-profiler/build/async-profiler-version gprofiler/resources/java/async-profiler-version
237-
COPY --from=async-profiler-builder-glibc /tmp/async-profiler/build/libasyncProfiler.so gprofiler/resources/java/glibc/libasyncProfiler.so
244+
COPY --from=async-profiler-centos-min-test-glibc /libasyncProfiler.so gprofiler/resources/java/glibc/libasyncProfiler.so
238245
COPY --from=async-profiler-builder-musl /tmp/async-profiler/build/libasyncProfiler.so gprofiler/resources/java/musl/libasyncProfiler.so
239246
COPY --from=async-profiler-builder-glibc /tmp/async-profiler/build/fdtransfer gprofiler/resources/java/fdtransfer
240247

scripts/async_profiler_build_shared.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#
66
set -euo pipefail
77

8-
VERSION=v2.8.3g2
9-
GIT_REV="ef1d3b3c29e7337d52f54035a12ae9a90eb1c710"
8+
VERSION=v2.8.3g3
9+
GIT_REV="008a8cf435bedce8eec3ef36fdc67e742b070566"
1010

1111
git clone --depth 1 -b "$VERSION" https://github.com/Granulate/async-profiler.git && cd async-profiler && git reset --hard "$GIT_REV"
1212
source "$1"

scripts/build_aarch64_executable.sh

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ docker buildx build --platform=linux/arm64 \
2626
--build-arg PHPSPY_BUILDER_UBUNTU=$UBUNTU_VERSION \
2727
--build-arg AP_BUILDER_CENTOS=$CENTOS7_VERSION \
2828
--build-arg AP_BUILDER_ALPINE=$ALPINE_VERSION \
29+
--build-arg AP_CENTOS_MIN=$CENTOS7_VERSION \
2930
--build-arg BURN_BUILDER_GOLANG=$GOLANG_VERSION \
3031
--build-arg GPROFILER_BUILDER=$CENTOS8_VERSION \
3132
. -f pyi.Dockerfile --output type=local,dest=build/aarch64/ $@

scripts/build_x86_64_executable.sh

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ UBUNTU_VERSION=@sha256:cf31af331f38d1d7158470e095b132acd126a7180a54f263d386da88e
1515
AP_BUILDER_CENTOS=@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
1616
# async-profiler musl - alpine
1717
AP_BUILDER_ALPINE=@sha256:69704ef328d05a9f806b6b8502915e6a0a4faa4d72018dc42343f511490daf8a
18+
# minimum CentOS version we intend to support with async-profiler (different between x86_64, where we require
19+
# an older version)
20+
AP_CENTOS_MIN=:6
1821
# burn - golang:1.16.3
1922
BURN_BUILDER_GOLANG=@sha256:f7d3519759ba6988a2b73b5874b17c5958ac7d0aa48a8b1d84d66ef25fa345f1
2023
# bcc & gprofiler - centos:7
@@ -30,6 +33,7 @@ DOCKER_BUILDKIT=1 docker build -f pyi.Dockerfile --output type=local,dest=build/
3033
--build-arg PHPSPY_BUILDER_UBUNTU=$UBUNTU_VERSION \
3134
--build-arg AP_BUILDER_CENTOS=$AP_BUILDER_CENTOS \
3235
--build-arg AP_BUILDER_ALPINE=$AP_BUILDER_ALPINE \
36+
--build-arg AP_CENTOS_MIN=$AP_CENTOS_MIN \
3337
--build-arg BURN_BUILDER_GOLANG=$BURN_BUILDER_GOLANG \
3438
--build-arg GPROFILER_BUILDER=$GPROFILER_BUILDER \
3539
. $@

0 commit comments

Comments
 (0)