Skip to content
Draft
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
22 changes: 22 additions & 0 deletions libcxx/utils/libcxx/test/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,28 @@ def pretty(self, config, litParams):
return "add {} to %{{compile_flags}}".format(self._getFlag(config))


class AddBenchmarkCompileFlag(ConfigAction):
"""
This action adds the given flag to the %{benchmark_flags} substitution.

The flag can be a string or a callable, in which case it is called with the
configuration to produce the actual flag (as a string).
"""

def __init__(self, flag):
self._getFlag = lambda config: flag(config) if callable(flag) else flag

def applyTo(self, config):
flag = self._getFlag(config)
_ensureFlagIsSupported(config, flag)
config.substitutions = _appendToSubstitution(
config.substitutions, "%{benchmark_flags}", flag
)

def pretty(self, config, litParams):
return "add {} to %{{benchmark_flags}}".format(self._getFlag(config))


class AddLinkFlag(ConfigAction):
"""
This action appends the given flag to the %{link_flags} substitution.
Expand Down
5 changes: 3 additions & 2 deletions libcxx/utils/libcxx/test/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ def getSuitableClangTidy(cfg):
),
Parameter(
name="optimization",
choices=["none", "speed", "size"],
choices=["default", "none", "speed", "size"],
type=str,
help="The optimization level to use when compiling the test suite.",
default="none",
default="default", # defaults, test -> none, benchmarks -> speed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default="default", # defaults, test -> none, benchmarks -> speed
help="The optimization level to use when compiling the test suite. 'default' is to enable no optimizations for tests and to optimize benchmarks for speed.",
default="default", # defaults, test -> none, benchmarks -> speed

actions=lambda opt: filter(None, [
AddBenchmarkCompileFlag(lambda cfg: getSpeedOptimizationFlag(cfg)) if opt == "default" else None,
AddCompileFlag(lambda cfg: getSpeedOptimizationFlag(cfg)) if opt == "speed" else None,
AddCompileFlag(lambda cfg: getSizeOptimizationFlag(cfg)) if opt == "size" else None,
AddFeature(f'optimization={opt}'),
Expand Down
Loading