diff options
author | Joel Stanley <joel@jms.id.au> | 2018-05-04 11:40:27 +0930 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2018-05-04 03:25:04 -0500 |
commit | 97cb32538ac0cdbab4a7dfed3c85fdca0b39701a (patch) | |
tree | be50d154511d72ebb98485a0df7e37335616f204 | |
parent | 1f1b3b4ed20432d487a9da05b57b3559330e8358 (diff) | |
download | skiboot-97cb32538ac0cdbab4a7dfed3c85fdca0b39701a.zip skiboot-97cb32538ac0cdbab4a7dfed3c85fdca0b39701a.tar.gz skiboot-97cb32538ac0cdbab4a7dfed3c85fdca0b39701a.tar.bz2 |
Makefile: Add additional flags when using clang
Clang needs to be told which target it's building for, as unlike GCC the
one binary targets many architectures.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
-rw-r--r-- | Makefile.main | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Makefile.main b/Makefile.main index 72b6821..05222a1 100644 --- a/Makefile.main +++ b/Makefile.main @@ -21,6 +21,8 @@ try = $(shell set -e; if ($(1)) >/dev/null 2>&1; \ try-cflag = $(call try,$(1) $(2) -x c -c /dev/null -o /dev/null,$(2)) test_cflag = $(call try,$(1) $(2) -x c -c /dev/null -o /dev/null,1,0) +cc-name := $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) + # Base warnings CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Werror-implicit-function-declaration -Wdeclaration-after-statement \ @@ -142,6 +144,27 @@ else AFLAGS += $(call try-cflag,$(CC),-mabi=elfv1) endif +ifeq ($(cc-name),clang) +ifneq ($(CROSS),) +CLANG_TARGET := --target=$(notdir $(CROSS:%-=%)) +GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) +endif +CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) +CFLAGS += $(call cc-option, -no-integrated-as) +AFLAGS += $(call cc-option, -no-integrated-as) + +LDFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) + +CFLAGS += -mcpu=pwr8 +LDFLAGS += -mcpu=pwr8 +ASFLAGS += -mcpu=pwr8 + +endif + # Special tool flags: # Do not use the floating point unit CFLAGS += -msoft-float |