From 6d844a038a4b5244a2c459b1e7c0c4fee4baf5bf Mon Sep 17 00:00:00 2001 From: "Gabriel L. Somlo" Date: Fri, 23 Aug 2019 08:56:02 -0400 Subject: [PATCH] software: use native toolchain for same host, target architectures LiteX rightfully assumes that most often the target software must be cross-compiled from an x86 host platform. However, LiteX can be also built on a 'linux-riscv64' platform (e.g. Fedora's riscv64 port), where the software for riscv64 targets should be compiled using the native toolchain. Signed-off-by: Gabriel Somlo --- litex/soc/integration/cpu_interface.py | 6 ++++++ litex/soc/software/common.mak | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/litex/soc/integration/cpu_interface.py b/litex/soc/integration/cpu_interface.py index 7eaeb515..238f5203 100644 --- a/litex/soc/integration/cpu_interface.py +++ b/litex/soc/integration/cpu_interface.py @@ -15,6 +15,7 @@ import os import json from shutil import which +from sysconfig import get_platform from migen import * @@ -58,8 +59,13 @@ def get_cpu_mak(cpu): r = None if not isinstance(triple, tuple): triple = (triple,) + p = get_platform() for i in range(len(triple)): t = triple[i] + # use native toolchain if host and target platforms are the same + if t == 'riscv64-unknown-elf' and p == 'linux-riscv64': + r = '--native--' + break if which(t+"-gcc"): r = t break diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 11e8fc38..18fc50c3 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -1,4 +1,8 @@ +ifeq ($(TRIPLE),--native--) +TARGET_PREFIX= +else TARGET_PREFIX=$(TRIPLE)- +endif RM ?= rm -f PYTHON ?= python3 -- 2.30.2