Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test profiles that disable all EMBOSS_CHECKs. #211

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions compiler/back_end/cpp/build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@ def emboss_cc_test(name, copts = None, no_w_sign_compare = False, **kwargs):
"""Generates cc_test rules with and without -DEMBOSS_NO_OPTIMIZATIONS."""
native.cc_test(
name = name,
copts = ["-DEMBOSS_FORCE_ALL_CHECKS"] + (copts or []),
copts = copts or [],
**kwargs
)
native.cc_test(
name = name + "_no_opts",
copts = [
"-DEMBOSS_NO_OPTIMIZATIONS",
"-DEMBOSS_FORCE_ALL_CHECKS",
] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
**kwargs
)
native.cc_test(
name = name + "_no_checks",
copts = ["-DEMBOSS_SKIP_CHECKS"] + (copts or []),
EricRahm marked this conversation as resolved.
Show resolved Hide resolved
**kwargs
)
native.cc_test(
name = name + "_no_checks_no_opts",
copts = [
"-DEMBOSS_NO_OPTIMIZATIONS",
"-DEMBOSS_SKIP_CHECKS",
] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
**kwargs
)
8 changes: 8 additions & 0 deletions runtime/cpp/emboss_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,17 @@
//
// By default, checks are only enabled on non-NDEBUG builds. (Note that all
// translation units MUST be built with the same value of NDEBUG!)
//
// The EMBOSS_SKIP_CHECKS parameter allows all CHECKs to be compiled out
// without -DNDEBUG; this is useful for testing.
#if !defined(EMBOSS_CHECK)
#if defined(EMBOSS_SKIP_CHECKS)
#define EMBOSS_CHECK(x) ((void)0)
#define EMBOSS_CHECK_ABORTS false
#else // !defined(EMBOSS_SKIP_CHECKS)
#define EMBOSS_CHECK(x) assert((x))
#define EMBOSS_CHECK_ABORTS (!(NDEBUG))
#endif // defined(EMBOSS_SKIP_CHECKS)
#endif // !defined(EMBOSS_CHECK)

#if !defined(EMBOSS_CHECK_ABORTS)
Expand Down