Skip to content

Commit dbdda21

Browse files
committed
additional build args used to ensure debug symbols are properly linked
1 parent 87d7c6e commit dbdda21

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

src/tests/multi-server/scripts/docker/build/Dockerfile.multi-server-prof

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,41 @@
22
# Builds off of "base" profiling image, configures FreeRADIUS and builds it.
33
FROM freeradius4-default-profiling/ubuntu24:latest
44

5+
# Inject patched sources to fix valgrind/valgrind.h detection
6+
COPY configure.ac /usr/local/src/repositories/freeradius-server/configure.ac
7+
COPY src/lib/util/dl.c /usr/local/src/repositories/freeradius-server/src/lib/util/dl.c
8+
COPY src/lib/util/dl.h /usr/local/src/repositories/freeradius-server/src/lib/util/dl.h
9+
COPY src/lib/server/dependency.c /usr/local/src/repositories/freeradius-server/src/lib/server/dependency.c
10+
COPY src/bin/radiusd.c /usr/local/src/repositories/freeradius-server/src/bin/radiusd.c
11+
12+
# Regenerating configure to include the patch for valgrind/valgrind.h detection.
13+
# Proper path to valgrind/valgrind.h is needed for logic depending on RUNNING_ON_VALGRIND which
14+
# is set by valgrind/valgrind.h
15+
RUN autoreconf
16+
17+
# CFLAGS used for profiling build:
18+
# -g3 Maximum debug info for callgrind symbol resolution
19+
# -O0 No optimisation: preserves the exact call structure of the source.
20+
# Disables dead-code elimination, tail-call optimisation, and all
21+
# other transforms that remove or reorder calls.
22+
# -fno-omit-frame-pointer Keep frame pointers so callgrind can walk the call stack
23+
# -fno-inline Disable inlining (including CC_HINT(flatten)) so call edges appear in the graph
24+
# -Dalways_inline= Strip __attribute__((always_inline)) which -fno-inline does not suppress
25+
# -fno-plt Eliminate PLT trampolines on cross-library calls (e.g. worker.c ->
26+
# interpret.c). Without this, the linker inserts a PLT stub with no
27+
# DWARF debug info, which appears as an unresolved "???" node in the
28+
# callgrind call graph. With -fno-plt, the compiler generates a direct
29+
# GOT-based indirect call that callgrind resolves correctly.
30+
# -fno-builtin Prevent replacement of standard library calls (memcpy, strlen, etc.)
31+
# with inline intrinsics, which would erase them from the call graph.
32+
# -fno-optimize-sibling-calls Prevent tail-call elimination converting call+ret into a jump,
33+
# which removes the call edge from the call graph. Already implied
34+
# by -O0 but stated explicitly as a safeguard.
535
RUN ./configure \
636
--enable-developer \
737
--disable-verify-ptr \
838
--with-raddbdir=/etc/freeradius \
9-
CFLAGS="-g3 -O1 -fno-omit-frame-pointer" \
39+
CFLAGS="-g3 -O0 -fno-omit-frame-pointer -fno-inline -Dalways_inline= -fno-plt -fno-builtin -fno-optimize-sibling-calls" \
1040
LDFLAGS="-fno-omit-frame-pointer"
1141

1242
RUN make

0 commit comments

Comments
 (0)