Skip to content

Commit

Permalink
Enable adding prefix to host compiler
Browse files Browse the repository at this point in the history
To enable cross compile.
  • Loading branch information
tyfkda committed Dec 21, 2023
1 parent 5d13783 commit c430b0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions src/xcc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit c430b0a

Please sign in to comment.