From 1c67623e37dada045e9b5d1f5e19b414cc79c3e3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 10 Mar 2009 17:50:01 +0000 Subject: [build] Enable building with the Intel C compiler (icc) --- src/Makefile.housekeeping | 84 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 8 deletions(-) (limited to 'src/Makefile.housekeeping') diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 2ab842e6..23ef8c60 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -60,6 +60,22 @@ HOST_OS := $(shell uname -s) hostos : @$(ECHO) $(HOST_OS) +############################################################################### +# +# Determine compiler + +CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2) +ccdefs: + @$(ECHO) $(CCDEFS) + +ifeq ($(filter __ICC,$(CCDEFS)),__ICC) +CCTYPE := icc +else +CCTYPE := gcc +endif +cctype: + @$(ECHO) $(CCTYPE) + ############################################################################### # # Check for tools that can cause failed builds @@ -103,10 +119,12 @@ oldgas : # default, even when -ffreestanding is specified. We therefore need # to disable -fstack-protector if the compiler supports it. # +ifeq ($(CCTYPE),gcc) SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \ -o /dev/null >/dev/null 2>&1 SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector') CFLAGS += $(SP_FLAGS) +endif ############################################################################### # @@ -279,9 +297,38 @@ ifdef BIN # Common flags # CFLAGS += -I include -I arch/$(ARCH)/include -I . -CFLAGS += -Os -ffreestanding -CFLAGS += -Wall -W -Wformat-nonliteral +CFLAGS += -Os CFLAGS += -g +ifeq ($(CCTYPE),gcc) +CFLAGS += -ffreestanding +CFLAGS += -Wall -W -Wformat-nonliteral +endif +ifeq ($(CCTYPE),icc) +CFLAGS += -fno-builtin +CFLAGS += -no-ip +CFLAGS += -no-gcc +CFLAGS += -diag-disable 111 # Unreachable code +CFLAGS += -diag-disable 128 # Unreachable loop +CFLAGS += -diag-disable 170 # Array boundary checks +CFLAGS += -diag-disable 177 # Unused functions +CFLAGS += -diag-disable 181 # printf() format checks +CFLAGS += -diag-disable 188 # enum strictness +CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers +CFLAGS += -diag-disable 280 # switch ( constant ) +CFLAGS += -diag-disable 310 # K&R parameter lists +CFLAGS += -diag-disable 424 # Extra semicolon +CFLAGS += -diag-disable 589 # Declarations mid-code +CFLAGS += -diag-disable 593 # Unused variables +CFLAGS += -diag-disable 810 # Casting ints to smaller ints +CFLAGS += -diag-disable 981 # Sequence point violations +CFLAGS += -diag-disable 1292 # Ignored attributes +CFLAGS += -diag-disable 1338 # void pointer arithmetic +CFLAGS += -diag-disable 1361 # Variable-length arrays +CFLAGS += -diag-disable 1418 # Missing prototypes +CFLAGS += -diag-disable 1419 # Missing prototypes +CFLAGS += -diag-disable 1599 # Hidden variables +CFLAGS += -Wall -Wmissing-declarations +endif CFLAGS += $(EXTRA_CFLAGS) ASFLAGS += $(EXTRA_ASFLAGS) LDFLAGS += $(EXTRA_LDFLAGS) @@ -314,11 +361,21 @@ OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT)) $(BIN)/%.flags : @$(ECHO) $(OBJ_CFLAGS) +# ICC requires postprocessing objects to fix up table alignments +# +ifeq ($(CCTYPE),icc) +POST_O = && $(ICCFIX) $@ +POST_O_DEPS := $(ICCFIX) +else +POST_O := +POST_O_DEPS := +endif + # Rules for specific object types. # COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS) -RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ -RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@ +RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O) +RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@ $(POST_O) RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@ RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@ @@ -364,15 +421,17 @@ endef define obj_template @$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \ - -Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \ - sed 's/_DEPS\s*:/_DEPS =/' >> $(2) - @$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \ + -Wno-error -MM $(1) -MG -MP | \ + sed 's/\.o\s*:/_DEPS =/' >> $(2) + @$(ECHO_E) '\n$$(BIN)/$(4).o :' \ + '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \ '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \ '\n\t$$(RULE_$(3))\n' \ '\nBOBJS += $$(BIN)/$(4).o\n' \ $(foreach TGT,$(DEBUG_TARGETS), \ $(if $(RULE_$(3)_to_$(TGT)), \ - '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \ + '\n$$(BIN)/$(4).$(TGT) :' \ + '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \ '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \ '\n\t$$(RULE_$(3)_to_$(TGT))\n' \ '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \ @@ -743,6 +802,15 @@ $(EFIROM) : util/efirom.c $(MAKEDEPS) $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $< CLEANUP += $(EFIROM) +############################################################################### +# +# The ICC fixup utility +# +$(ICCFIX) : util/iccfix.c $(MAKEDEPS) + $(QM)$(ECHO) " [HOSTCC] $@" + $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $< +CLEANUP += $(ICCFIX) + ############################################################################### # # Auto-incrementing build serial number. Append "bs" to your list of -- cgit v1.2.3-55-g7522