software: use native toolchain for same host, target architectures
authorGabriel L. Somlo <gsomlo@gmail.com>
Fri, 23 Aug 2019 12:56:02 +0000 (08:56 -0400)
committerGabriel L. Somlo <gsomlo@gmail.com>
Fri, 23 Aug 2019 13:04:55 +0000 (09:04 -0400)
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>
litex/soc/integration/cpu_interface.py
litex/soc/software/common.mak

index 7eaeb5154b25d3a86d34eee04e832cef67b13656..238f5203b9e804e31c10567f2790d46ec8c68b7d 100644 (file)
@@ -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
index 11e8fc3855e2cf853bc622ea2946edfd4308fd53..18fc50c3f299e751a0dc538477c8a7327186b858 100644 (file)
@@ -1,4 +1,8 @@
+ifeq ($(TRIPLE),--native--)
+TARGET_PREFIX=
+else
 TARGET_PREFIX=$(TRIPLE)-
+endif
 
 RM ?= rm -f
 PYTHON ?= python3