diff --git a/Makefile b/Makefile index 5ad4de27c..fe9b5f227 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ LIB_DIR:=lib # NO_VLA:=1 # NO_WCHAR:=1 +# HOST_CC_PREFIX=riscv64-unknown-elf- + ifeq ("$(ARCHTYPE)", "") ARCHTYPE:=x64 ARCH:=$(shell arch) @@ -50,6 +52,10 @@ ifneq ("$(NO_WCHAR)","") CFLAGS+=-D__NO_WCHAR endif +ifneq ("$(HOST_CC_PREFIX)","") +CFLAGS+=-DHOST_CC_PREFIX=$(HOST_CC_PREFIX) +endif + # For release build: # CFLAGS+=-DNDEBUG diff --git a/src/xcc/main.c b/src/xcc/main.c index 96b24d292..ffd684e91 100644 --- a/src/xcc/main.c +++ b/src/xcc/main.c @@ -260,6 +260,13 @@ int main(int argc, char *argv[]) { #if !defined(AS_USE_CC) char *as_path = join_exe_prefix(xccpath, prefix, "as"); char *ld_path = join_exe_prefix(xccpath, prefix, "ld"); +#elif defined(HOST_CC_PREFIX) +#define S(x) S2(x) +#define S2(x) #x + char *as_path = S(HOST_CC_PREFIX) "as"; + char *ld_path = S(HOST_CC_PREFIX) "gcc"; +#undef S2 +#undef S #else char *as_path = "/usr/bin/as"; char *ld_path = "/usr/bin/cc";