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