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 <gsomlo@gmail.com>
import os
import json
from shutil import which
+from sysconfig import get_platform
from migen import *
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
+ifeq ($(TRIPLE),--native--)
+TARGET_PREFIX=
+else
TARGET_PREFIX=$(TRIPLE)-
+endif
RM ?= rm -f
PYTHON ?= python3