From 4956f61d7c94b065ee9075530c138854800c050e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 21 Mar 2021 11:07:59 +0000 Subject: [PATCH] add override for build commands powerpc64-linux-gnu-{ENVVAR} --- src/soc/simulator/envcmds.py | 9 +++++++++ src/soc/simulator/program.py | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/soc/simulator/envcmds.py diff --git a/src/soc/simulator/envcmds.py b/src/soc/simulator/envcmds.py new file mode 100644 index 00000000..e6525c08 --- /dev/null +++ b/src/soc/simulator/envcmds.py @@ -0,0 +1,9 @@ +import os + +# set up environment variable overrides, can use for different versions +# as well as native (TALOS-II POWER9) builds. +cmds = {} +for cmd in ['objcopy', 'as', 'ld', 'gcc', 'ar', 'gdb']: + cmds[cmd] = os.environ.get(cmd.upper(), "powerpc64-linux-gnu-%s" % cmd) + + diff --git a/src/soc/simulator/program.py b/src/soc/simulator/program.py index 47e873c6..1acd02da 100644 --- a/src/soc/simulator/program.py +++ b/src/soc/simulator/program.py @@ -15,6 +15,7 @@ import os import sys from io import BytesIO +from soc.simulator.envcmds import cmds filedir = os.path.dirname(os.path.realpath(__file__)) memmap = os.path.join(filedir, "memmap") @@ -58,7 +59,7 @@ class Program: def _get_binary(self, elffile): self.binfile = tempfile.NamedTemporaryFile(suffix=".bin") - args = ["powerpc64-linux-gnu-objcopy", + args = [cmds['objcopy'], "-O", "binary", "-I", self.endian_fmt, elffile.name, @@ -67,7 +68,7 @@ class Program: def _link(self, ofile): with tempfile.NamedTemporaryFile(suffix=".elf") as elffile: - args = ["powerpc64-linux-gnu-ld", + args = [cmds['ld'], self.ld_fmt, "-o", elffile.name, "-T", memmap, @@ -77,7 +78,7 @@ class Program: def _assemble(self): with tempfile.NamedTemporaryFile(suffix=".o") as outfile: - args = ["powerpc64-linux-gnu-as", + args = [cmds['as'], '-mpower9', '-mregnames', self.obj_fmt, -- 2.30.2