Add clang as a compiler

This commit is contained in:
CrashOveride95
2021-08-05 18:11:55 -04:00
parent cd08052d48
commit 9fe5ad21b7
2 changed files with 16 additions and 6 deletions

View File

@@ -38,8 +38,9 @@ endif
# COMPILER - selects the C compiler to use
# gcc - uses the GNU C Compiler
# clang - uses clang C/C++ frontend for LLVM
COMPILER ?= gcc
$(eval $(call validate-option,COMPILER,gcc))
$(eval $(call validate-option,COMPILER,gcc clang))
# LIBGCCDIR - selects the libgcc configuration for checking for dividing by zero
@@ -139,7 +140,12 @@ endif
ifeq ($(COMPILER),gcc)
NON_MATCHING := 1
MIPSISET := -mips3
OPT_FLAGS := -O2 -g
OPT_FLAGS := -O2
else ifeq ($(COMPILER),clang)
NON_MATCHING := 1
# clang doesn't support ABI 'o32' for 'mips3'
MIPSISET := -mips2
OPT_FLAGS := -O2
endif
@@ -371,6 +377,8 @@ export LD_LIBRARY_PATH=./tools
AS := $(CROSS)as
ifeq ($(COMPILER),gcc)
CC := $(CROSS)gcc
else ifeq ($(COMPILER),clang)
CC := clang
endif
# Prefer gcc's cpp if installed on the system
ifneq (,$(call find-command,cpp-10))
@@ -404,9 +412,12 @@ DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES)
CFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) $(MIPSISET) $(DEF_INC_CFLAGS)
ifeq ($(COMPILER),gcc)
CFLAGS += -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
else ifeq ($(COMPILER),clang)
CFLAGS += -target mips -mabi=32 -G 0 -mhard-float -fomit-frame-pointer -fno-stack-protector -fno-common -I include -I src/ -I $(BUILD_DIR)/include -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
else
CFLAGS += -non_shared -Wab,-r4300_mul -Xcpluscomm -Xfullwarn -signed -32
endif
ASMFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d))
RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d)))
@@ -460,8 +471,8 @@ YELLOW := \033[0;33m
BLINK := \033[33;5m
endif
# Use Objcopy instead of extract_data_for_mio
ifeq ($(COMPILER),gcc)
# For non-IDO, use objcopy instead of extract_data_for_mio
ifneq ($(COMPILER),ido)
EXTRACT_DATA_FOR_MIO := $(OBJCOPY) -O binary --only-section=.data
endif
@@ -724,7 +735,7 @@ $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
# Assemble assembly code
$(BUILD_DIR)/%.o: %.s
$(call print,Assembling:,$<,$@)
$(V)$(CC) -c $(CFLAGS) $(foreach i,$(INCLUDE_DIRS),-Wa,-I$(i)) -x assembler-with-cpp -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<
$(V)$(CROSS)gcc -c $(ASMFLAGS) $(foreach i,$(INCLUDE_DIRS),-Wa,-I$(i)) -x assembler-with-cpp -MMD -MF $(BUILD_DIR)/$*.d -o $@ $<
# Assemble RSP assembly code
$(BUILD_DIR)/rsp/%.bin $(BUILD_DIR)/rsp/%_data.bin: rsp/%.s