Allow using gcc for or1k.

* Using CLANG can set by using CLANG=1 or CLANG=0 in the environment.
 * or1k continues to default to CLANG if environment is not net.
This commit is contained in:
Tim 'mithro' Ansell 2016-04-19 13:29:07 +10:00
parent 2f834d0aa2
commit e7f3c585b7
1 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import os
from litex.gen import * from litex.gen import *
from litex.soc.interconnect.csr import CSRStatus from litex.soc.interconnect.csr import CSRStatus
@ -9,18 +11,30 @@ cpu_endianness = {
} }
def get_cpu_mak(cpu): def get_cpu_mak(cpu):
clang = os.getenv("CLANG", "")
if clang != "":
clang = bool(int(clang))
else:
clang = None
if cpu == "lm32": if cpu == "lm32":
assert not clang, "lm32 not supported with clang."
triple = "lm32-elf" triple = "lm32-elf"
cpuflags = "-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled" cpuflags = "-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled"
clang = ""
elif cpu == "or1k": elif cpu == "or1k":
triple = "or1k-linux" # Default to CLANG unless told otherwise
cpuflags = "-mhard-mul -mhard-div -mror -mffl1 -maddc" if clang is None:
clang = "1" clang = True
triple = "or1k-elf"
cpuflags = "-mhard-mul -mhard-div -mror"
if clang:
triple = "or1k-linux"
cpuflags += "-mffl1 -maddc"
elif cpu == "riscv32": elif cpu == "riscv32":
assert not clang, "riscv32 not supported with clang."
triple = "riscv32-unknown-elf" triple = "riscv32-unknown-elf"
cpuflags = "-mno-save-restore" cpuflags = "-mno-save-restore"
clang = ""
else: else:
raise ValueError("Unsupported CPU type: "+cpu) raise ValueError("Unsupported CPU type: "+cpu)
return [ return [
@ -28,7 +42,7 @@ def get_cpu_mak(cpu):
("CPU", cpu), ("CPU", cpu),
("CPUFLAGS", cpuflags), ("CPUFLAGS", cpuflags),
("CPUENDIANNESS", cpu_endianness[cpu]), ("CPUENDIANNESS", cpu_endianness[cpu]),
("CLANG", clang) ("CLANG", str(int(clang)))
] ]