|
2 | 2 | # Builds off of "base" profiling image, configures FreeRADIUS and builds it. |
3 | 3 | FROM freeradius4-default-profiling/ubuntu24:latest |
4 | 4 |
|
| 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. |
5 | 35 | RUN ./configure \ |
6 | 36 | --enable-developer \ |
7 | 37 | --disable-verify-ptr \ |
8 | 38 | --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" \ |
10 | 40 | LDFLAGS="-fno-omit-frame-pointer" |
11 | 41 |
|
12 | 42 | RUN make |
|
0 commit comments