Skip to content

Commit 91b913a

Browse files
committed
Don't fail on missing llvm-mc
* Disable selftest if llvm-mc cannot be found. * Issue warning in log.
1 parent f0c3d96 commit 91b913a

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

slothy/core/config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"""
2929
SLOTHY configuration
3030
"""
31-
31+
import shutil
3232

3333
from copy import deepcopy
3434

@@ -143,7 +143,12 @@ def selftest(self):
143143
144144
This is so far implemented as a repeated randomized test -- nothing clever.
145145
"""
146-
return self._selftest
146+
selftest_enabled = self._selftest
147+
if shutil.which("llvm-mc") is None:
148+
self.logger.warning("llvm-mc not found, disabling selftest.")
149+
selftest_enabled = False
150+
151+
return selftest_enabled
147152

148153
@property
149154
def selftest_iterations(self):
@@ -1294,11 +1299,12 @@ def rename_hint_orig_rename(self, val):
12941299
def order_hint_orig_order(self, val):
12951300
self._order_hint_orig_order = val
12961301

1297-
def __init__(self, Arch, Target):
1302+
def __init__(self, Arch, Target, logger):
12981303
super().__init__()
12991304

13001305
self._arch = Arch
13011306
self._target = Target
1307+
self.logger = logger
13021308

13031309
self._sw_pipelining = Config.SoftwarePipelining()
13041310
self._constraints = Config.Constraints()

slothy/core/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,10 @@ def __init__(
16061606
self, Arch: any, Target: any, *, logger: any = None, config: any = None
16071607
):
16081608
super().__init__()
1609-
self.config = config if config is not None else Config(Arch, Target)
16101609
self.logger = logger if logger is not None else logging.getLogger("slothy")
1610+
self.config = (
1611+
config if config is not None else Config(Arch, Target, self.logger)
1612+
)
16111613
self.logger.input = self.logger.getChild("input")
16121614
self.logger.config = self.logger.getChild("config")
16131615
self.logger.result = self.logger.getChild("result")

slothy/core/slothy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ def _get_target(self):
9797
target = property(_get_target)
9898

9999
def __init__(self, arch, target, logger=None):
100-
self.config = Config(arch, target)
101-
102100
# Configure default logging to stdout if no handlers are configured
103101
if logger is None:
104102
root_logger = logging.getLogger()
@@ -108,6 +106,8 @@ def __init__(self, arch, target, logger=None):
108106
else:
109107
self.logger = logger
110108

109+
self.config = Config(arch, target, logger=logger)
110+
111111
# The source, once loaded, is represented as a list of strings
112112
self._source = None
113113
self._original_source = None

0 commit comments

Comments
 (0)