Skip to content

Commit

Permalink
Perform Valgrind checks with minimal inlining
Browse files Browse the repository at this point in the history
Disable LTO and use `-Og` for Valgrind and Helgrind builds, so that we
can avoid making our Valgrind suppressions any more broad than
necessary.

Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
  • Loading branch information
godlygeek authored and pablogsal committed May 13, 2022
1 parent 0b2d857 commit eeaf46f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-test.txt
python3 -m pip install -e .
env:
MEMRAY_MINIMIZE_INLINING: 1
- name: Run Valgrind
run: make valgrind
- name: Run Helgrind
Expand Down
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def build_js_files(self):
if os.getenv("CYTHON_TEST_MACROS", None) is not None:
TEST_BUILD = True

MINIMIZE_INLINING = os.getenv("MEMRAY_MINIMIZE_INLINING", "") != ""

COMPILER_DIRECTIVES = {
"language_level": 3,
"embedsignature": True,
Expand All @@ -133,8 +135,15 @@ def build_js_files(self):
"c_string_encoding": "utf8",
}
EXTRA_COMPILE_ARGS = []
EXTRA_LINK_ARGS = []
UNDEF_MACROS = []

if MINIMIZE_INLINING:
EXTRA_COMPILE_ARGS.append("-Og")
else:
EXTRA_COMPILE_ARGS.append("-flto")
EXTRA_LINK_ARGS.append("-flto")

# For Python 3.9+, hide all of our symbols except the module init function. For
# Python 3.8 and earlier this isn't as easy, because PyMODINIT_FUNC doesn't
# include __attribute__((visibility ("default"))), and Cython doesn't give us
Expand Down Expand Up @@ -204,8 +213,8 @@ def build_js_files(self):
library_dirs=[str(LIBBACKTRACE_LIBDIR)],
include_dirs=["src", str(LIBBACKTRACE_INCLUDEDIRS)],
language="c++",
extra_compile_args=["-std=c++17", "-Wall", "-flto", *EXTRA_COMPILE_ARGS],
extra_link_args=["-std=c++17", "-flto", "-l:libbacktrace.a"],
extra_compile_args=["-std=c++17", "-Wall", *EXTRA_COMPILE_ARGS],
extra_link_args=["-std=c++17", "-l:libbacktrace.a", *EXTRA_LINK_ARGS],
define_macros=DEFINE_MACROS,
undef_macros=UNDEF_MACROS,
)
Expand Down
2 changes: 1 addition & 1 deletion valgrind.supp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<cython_cached_constants>
Memcheck:Leak
...
fun:__Pyx_InitCachedConstants
fun:*__Pyx_InitCachedConstants*
...
}

Expand Down

0 comments on commit eeaf46f

Please sign in to comment.