Skip to content

Add frame-pointer support to zlib

Matt Smiley requested to merge frame_pointers_for_zlib into master
Add frame-pointer support to zlib

Enables more informative stack traces from git process failures through
use of frame pointers. Adds the "no-omit-frame-pointer" flag to gcc when
compiling the zlib library shared object.

Closes https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1726

Changelog: changed

What does this MR do?

When building the libz.so shared object file, tell the compiler to include frame-pointer support when generating the assembly. To do so, we need to pass the no-omit-frame-pointer flag to gcc.

The zlib Makefile generation does not explicitly support appending extra flags to the SFLAGS and CFLAGS variables. When configure generates the Makefile, it appends flags to the initial CFLAGS value based on its build environment, and we want to preserve those choices. It initializes CFLAGS to either copy the value of that environment variable or set it to -O3, and additional flags are subsequently appended to that value:

193   CFLAGS="${CFLAGS--O3}"
194   SFLAGS="${CFLAGS--O3} -fPIC"

The SFLAGS variable gets initialized using the CFLAGS initial variable, so the shared object file's build will implicitly inherit the custom CFLAGS.

So we can add our custom gcc argument (-fno-omit-frame-pointer) by setting it in the CFLAGS environment variable, before running configure. We do also need to copy the configure script's default initial CFLAGS value (-O3) into the env var.

Related issues

Closes gitlab-com/gl-infra/scalability#1726 (closed)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com
  • Pipeline is green on dev.gitlab.org if the change is touching anything besides documentation or internal cookbooks
  • trigger-package has a green pipeline running against latest commit

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Tests added
  • Integration tests added to GitLab QA
  • Equivalent MR/issue for the GitLab Chart opened
Edited by Robert Marshall

Merge request reports