From ddc3ecaca68a8f95e653aaeed2d374f54201c25e Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:42:24 +0100 Subject: [PATCH] fix(docker): make symbol stripping configurable (#22937) --- .github/scripts/build_pgo_bolt.sh | 24 ++++++++++++++++++++---- .github/workflows/docker.yml | 1 + Dockerfile.depot | 6 +++++- docker-bake.hcl | 6 ++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/scripts/build_pgo_bolt.sh b/.github/scripts/build_pgo_bolt.sh index ffaa6ad163..fae5edeb3f 100755 --- a/.github/scripts/build_pgo_bolt.sh +++ b/.github/scripts/build_pgo_bolt.sh @@ -15,6 +15,7 @@ # PGO_BLOCKS - Number of blocks for PGO profiling (default: 20) # BOLT_BLOCKS - Number of blocks for BOLT profiling (default: 20) # SKIP_BOLT - Temporarily skip BOLT phases (default: false) +# STRIP_SYMBOLS - Strip debug symbols from output binary (default: true) # COLLECT_PGO_ONLY - Stop after producing merged.profdata (default: false) # PGO_PROFDATA - Path to pre-collected merged.profdata (optional) # PROFILE - Cargo profile (default: maxperf-symbols) @@ -48,6 +49,7 @@ cd "$(dirname "$0")/../.." PGO_BLOCKS="${PGO_BLOCKS:-20}" BOLT_BLOCKS="${BOLT_BLOCKS:-20}" SKIP_BOLT="${SKIP_BOLT:-false}" +STRIP_SYMBOLS="${STRIP_SYMBOLS:-true}" COLLECT_PGO_ONLY="${COLLECT_PGO_ONLY:-false}" PROFILE="${PROFILE:-maxperf-symbols}" FEATURES="${FEATURES:-jemalloc,asm-keccak,min-debug-logs}" @@ -64,6 +66,11 @@ if [[ "${SKIP_BOLT,,}" == "true" || "$SKIP_BOLT" == "1" ]]; then SKIP_BOLT_BOOL=true fi +STRIP_SYMBOLS_BOOL=false +if [[ "${STRIP_SYMBOLS,,}" == "true" || "$STRIP_SYMBOLS" == "1" ]]; then + STRIP_SYMBOLS_BOOL=true +fi + COLLECT_PGO_ONLY_BOOL=false if [[ "${COLLECT_PGO_ONLY,,}" == "true" || "$COLLECT_PGO_ONLY" == "1" ]]; then COLLECT_PGO_ONLY_BOOL=true @@ -116,6 +123,7 @@ echo "LLVM: $LLVM_VERSION" echo "PGO blocks: $PGO_BLOCKS" echo "BOLT blocks: $BOLT_BLOCKS" echo "Skip BOLT: $SKIP_BOLT" +echo "Strip symbols: $STRIP_SYMBOLS" echo "Collect only: $COLLECT_PGO_ONLY" echo "PGO profdata: ${PGO_PROFDATA:-}" echo "RUSTFLAGS: ${BASE_RUSTFLAGS:-}" @@ -314,8 +322,12 @@ if [ "$SKIP_BOLT_BOOL" = true ]; then cargo build "${CARGO_ARGS[@]}" --target "$TARGET" BUILT_BIN="$PWD/target/$TARGET/$PROFILE_DIR/reth" - echo "Stripping debug symbols..." - strip "$BUILT_BIN" + if [ "$STRIP_SYMBOLS_BOOL" = true ]; then + echo "Stripping debug symbols..." + strip "$BUILT_BIN" + else + echo "Skipping strip (STRIP_SYMBOLS=$STRIP_SYMBOLS)" + fi publish_binary "$BUILT_BIN" gha_section_end else @@ -386,8 +398,12 @@ else -use-gnu-stack \ --skip-funcs='.*drop_in_place.*' - echo "Stripping debug symbols..." - strip "$OPTIMIZED_BIN" + if [ "$STRIP_SYMBOLS_BOOL" = true ]; then + echo "Stripping debug symbols..." + strip "$OPTIMIZED_BIN" + else + echo "Skipping strip (STRIP_SYMBOLS=$STRIP_SYMBOLS)" + fi publish_binary "$OPTIMIZED_BIN" gha_section_end fi diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c9872342fa..247b3303b1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -139,6 +139,7 @@ jobs: ${{ steps.params.outputs.ethereum_set }} *.args.USE_PGO_BOLT=${{ steps.pgo.outputs.use_pgo_bolt }} *.args.PGO_PROFDATA=${{ steps.pgo.outputs.pgo_profdata }} + *.args.STRIP_SYMBOLS=false - name: Verify image architectures env: diff --git a/Dockerfile.depot b/Dockerfile.depot index 3503540cd5..c1262516ee 100644 --- a/Dockerfile.depot +++ b/Dockerfile.depot @@ -53,6 +53,10 @@ ENV USE_PGO_BOLT=$USE_PGO_BOLT ARG PGO_PROFDATA="" ENV PGO_PROFDATA=$PGO_PROFDATA +# Whether to strip debug symbols from PGO-built binaries. +ARG STRIP_SYMBOLS=true +ENV STRIP_SYMBOLS=$STRIP_SYMBOLS + # Build application # Platform-specific RUSTFLAGS: amd64 uses x86-64-v3 (Haswell+) with pclmulqdq for rocksdb ARG TARGETPLATFORM @@ -65,7 +69,7 @@ RUN --mount=type=secret,id=DEPOT_TOKEN,env=SCCACHE_WEBDAV_TOKEN \ sccache --start-server && \ if [ "$USE_PGO_BOLT" = "true" ] && [ "$TARGETPLATFORM" = "linux/amd64" ] && [ -n "$PGO_PROFDATA" ] && [ -f "$PGO_PROFDATA" ]; then \ apt-get update && apt-get install -y -qq lsb-release wget sudo && \ - BINARY="$BINARY" PROFILE="$BUILD_PROFILE" FEATURES="$FEATURES" SKIP_BOLT=true PGO_PROFDATA="$PGO_PROFDATA" \ + BINARY="$BINARY" PROFILE="$BUILD_PROFILE" FEATURES="$FEATURES" SKIP_BOLT=true STRIP_SYMBOLS="$STRIP_SYMBOLS" PGO_PROFDATA="$PGO_PROFDATA" \ ./.github/scripts/build_pgo_bolt.sh; \ else \ if [ "$USE_PGO_BOLT" = "true" ]; then \ diff --git a/docker-bake.hcl b/docker-bake.hcl index 5d145b7f01..1a7a928ae3 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -39,6 +39,11 @@ variable "PGO_PROFDATA" { default = "" } +// Whether to strip debug symbols in PGO build path. +variable "STRIP_SYMBOLS" { + default = "true" +} + // Common settings for all targets group "default" { targets = ["ethereum"] @@ -60,6 +65,7 @@ target "_base" { VERGEN_GIT_DIRTY = "${VERGEN_GIT_DIRTY}" USE_PGO_BOLT = "${USE_PGO_BOLT}" PGO_PROFDATA = "${PGO_PROFDATA}" + STRIP_SYMBOLS = "${STRIP_SYMBOLS}" } secret = [ {