Skip to content

Commit

Permalink
Disable V extension when compiler doesn't support it. (riscv-software…
Browse files Browse the repository at this point in the history
…-src#317)

This allows the vast majority of these tests to work with compilers that
don't support the V extension yet, which is helpful for people who
aren't using a vector branch of the compiler.

Specifically, this will hopefully allow us to run regression tests
against OpenOCD on every change, per
riscv-collab/riscv-openocd#563.
  • Loading branch information
timsifive committed Jan 8, 2021
1 parent cd6ebbc commit 4743239
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions debug/targets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib
import os.path
import re
import sys
import tempfile

Expand Down Expand Up @@ -118,6 +119,7 @@ def __init__(self, path, parsed):
self.server_cmd = parsed.server_cmd
self.sim_cmd = parsed.sim_cmd
self.temporary_binary = None
self.compiler_supports_v = True
Target.isolate = parsed.isolate
if not self.name:
self.name = type(self).__name__
Expand Down Expand Up @@ -147,7 +149,7 @@ def server(self):
config=self.openocd_config_path,
timeout=self.server_timeout_sec)

def compile(self, hart, *sources):
def do_compile(self, hart, *sources):
binary_name = "%s_%s-%d" % (
self.name,
os.path.basename(os.path.splitext(sources[0])[0]),
Expand All @@ -174,9 +176,11 @@ def compile(self, hart, *sources):
args.append("-DRV32E")
else:
march = "rv%dima" % hart.xlen
for letter in "fdcv":
for letter in "fdc":
if hart.extensionSupported(letter):
march += letter
if hart.extensionSupported("v") and self.compiler_supports_v:
march += "v"
args.append("-march=%s" % march)
if hart.xlen == 32:
args.append("-mabi=ilp32")
Expand All @@ -186,6 +190,24 @@ def compile(self, hart, *sources):
testlib.compile(args)
return binary_name

def compile(self, hart, *sources):
while True:
try:
return self.do_compile(hart, *sources)
except testlib.CompileError as e:
# If the compiler doesn't support V, disable it from the
# current configuration. Eventually all gcc branches will
# support V, but we're not there yet.
m = re.search(r"Error: cannot find default versions of the "
r"ISA extension `(\w)'", e.stderr.decode())
if m and m.group(1) in "v":
extension = m.group(1)
print("Disabling extension %r because the "
"compiler doesn't support it." % extension)
self.compiler_supports_v = False
else:
raise

def add_target_options(parser):
parser.add_argument("target", help=".py file that contains definition for "
"the target to test with.")
Expand Down

0 comments on commit 4743239

Please sign in to comment.