aboutsummaryrefslogtreecommitdiff
path: root/Makefile.main
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-08-12 16:42:58 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-08-12 16:42:58 +1000
commite41e541fafb27f54d4d28223bdca9667d78cb50f (patch)
treebed69151f6e6af5939fb2d00d7a12bdcc08b7d00 /Makefile.main
parenta35105c5d0742d5536c2d3a4b64bc2973262e2d5 (diff)
downloadskiboot-e41e541fafb27f54d4d28223bdca9667d78cb50f.zip
skiboot-e41e541fafb27f54d4d28223bdca9667d78cb50f.tar.gz
skiboot-e41e541fafb27f54d4d28223bdca9667d78cb50f.tar.bz2
Test compiler flags before using, force abiv1 if needed
We will now test if the compiler supports a certain complier flag before using it (ones that have been introduced "recently"). We also add -mabi=elfv1 if compiler supports it (e.g. gcc 4.9) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'Makefile.main')
-rw-r--r--Makefile.main23
1 files changed, 19 insertions, 4 deletions
diff --git a/Makefile.main b/Makefile.main
index 48d8b8d..d5975e2 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -14,22 +14,31 @@ SIZE=$(CROSS)size
LD_TEXT=0x0
NM += --synthetic
+try = $(shell set -e; if ($(1)) >/dev/null 2>&1; \
+ then echo "$(2)"; \
+ else echo "$(3)"; fi )
+
+try-cflag = $(call try,$(1) $(2) -c /dev/null -o /dev/null,$(2))
+
# Base warnings
CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration -Wdeclaration-after-statement \
-Wno-pointer-sign -Wextra -Wno-sign-compare \
-Wmissing-prototypes -Wmissing-declarations \
- -Wwrite-strings -Wcast-align -Wjump-misses-init \
+ -Wwrite-strings -Wcast-align \
-Winit-self \
- -Wsuggest-attribute=const \
- -Wsuggest-attribute=noreturn \
- -Wframe-larger-than=1024 -Wstack-usage=1024 \
+ -Wframe-larger-than=1024 \
-Werror -Wno-error=format
# Host tools and options
HOSTCC=gcc
HOSTEND=$(shell uname -m | sed -e 's/^i.*86$$/LITTLE/' -e 's/^x86.*/LITTLE/' -e 's/^ppc64le/LITTLE/' -e 's/^ppc.*/BIG/')
HOSTCFLAGS=-O1 $(CWARNS) -DHAVE_$(HOSTEND)_ENDIAN -MMD
+HOSTCFLAGS += $(call try-cflag,$(HOSTCC),-Wjump-misses-init) \
+ $(call try-cflag,$(HOSTCC),-Wsuggest-attribute=const) \
+ $(call try-cflag,$(HOSTCC),-Wsuggest-attribute=noreturn) \
+ $(call try-cflag,$(HOSTCC),-Wstack-usage=1024)
+
VALGRIND=valgrind -q --show-reachable=yes --error-exitcode=99
# Target options
@@ -52,6 +61,7 @@ CPPFLAGS += -ffreestanding
CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie -mbig-endian -m64
CFLAGS += -Wl,--oformat,elf64-powerpc
+CFLAGS += $(call try-cflag,$(CC),-mabi=elfv1)
ifeq ($(SKIBOOT_GCOV),1)
CFLAGS += -fprofile-arcs -ftest-coverage -DSKIBOOT_GCOV=1
@@ -65,6 +75,11 @@ else
CFLAGS += -fstack-protector
endif
+CFLAGS += $(call try-cflag,$(CC),-Wjump-misses-init) \
+ $(call try-cflag,$(CC),-Wsuggest-attribute=const) \
+ $(call try-cflag,$(CC),-Wsuggest-attribute=noreturn) \
+ $(call try-cflag,$(CC),-Wstack-usage=1024)
+
CFLAGS += $(CWARNS) $(OPTS) $(DBG)
LDFLAGS := -m64 -static -nostdlib -pie