aboutsummaryrefslogtreecommitdiff
path: root/sys/conf
diff options
context:
space:
mode:
authorTom Rhodes <trhodes@FreeBSD.org>2004-03-12 21:36:12 +0000
committerTom Rhodes <trhodes@FreeBSD.org>2004-03-12 21:36:12 +0000
commit06d6e4fcfeea94893ddd82264e531131939f2b80 (patch)
tree92d1817354827751fba22c16fc2fbfed658a79c4 /sys/conf
parent7700eb86e7740ce5ea0180c6c39e11e816f265c4 (diff)
downloadsrc-06d6e4fcfeea94893ddd82264e531131939f2b80.tar.gz
src-06d6e4fcfeea94893ddd82264e531131939f2b80.zip
This are the build infrastructure changes to allow to use the
Intel C/C++ compiler (lang/icc) to build the kernel. The icc CPUTYPE CFLAGS use icc v7 syntax, icc v8 moans about them, but doesn't abort. They also produce CPU specific code (new instructions of the CPU, not only CPU specific scheduling), so if you get coredumps with signal 4 (SIGILL, illegal instruction) you've used the wrong CPUTYPE. Incarnations of this patch survive gcc compiles and my make universe. I use it on my desktop. To use it update share/mk, add /usr/local/intel/compiler70/ia32/bin (icc v7, works) or /usr/local/intel_cc_80/bin (icc v8, doesn't work) to your PATH, make sure you have a new kernel compile directory (e.g. MYKERNEL_icc) and run CFLAGS="-O2 -ip" CC=icc make depend CFLAGS="-O2 -ip" CC=icc make in it. Don't compile with -ipo, the build infrastructure uses ld directly to link the kernel and the modules, but -ipo needs the link step to be performed with Intel's linker. Problems with icc v8: - panic: npx0 cannot be emulated on an SMP system - UP: first start of /bin/sh results in a FP exception Parts of this commit contains suggestions or submissions from Marius Strobl <marius@alchemy.franken.de>. Reviewed by: silence on -arch Submitted by: netchild
Notes
Notes: svn path=/head/; revision=126890
Diffstat (limited to 'sys/conf')
-rw-r--r--sys/conf/files4
-rw-r--r--sys/conf/kern.mk15
-rw-r--r--sys/conf/kern.pre.mk33
-rw-r--r--sys/conf/kmod.mk15
4 files changed, 61 insertions, 6 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 73d1df7e14fb..339f7db1b620 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -6,12 +6,12 @@
#
aicasm optional ahc \
dependency "$S/dev/aic7xxx/aicasm/*.[chyl]" \
- compile-with "${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
+ compile-with "CC=${CC} ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
no-obj no-implicit-rule \
clean "aicasm* y.tab.h"
aicasm optional ahd \
dependency "$S/dev/aic7xxx/aicasm/*.[chyl]" \
- compile-with "${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
+ compile-with "CC=${CC} ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
no-obj no-implicit-rule \
clean "aicasm* y.tab.h"
aic7xxx_{seq.h,reg.h,reg_print.c} optional ahc \
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index dc369df738b7..133f1cf4a66c 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -6,9 +6,14 @@
# Note that the newly added -Wcast-qual is responsible for generating
# most of the remaining warnings. Warnings introduced with -Wall will
# also pop up, but are easier to fix.
+.if ${CC} == "icc"
+#CWARNFLAGS= -w2 # use this if you are terribly bored
+CWARNFLAGS=
+.else
CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
-fformat-extensions -std=c99
+.endif
#
# The following flags are next up for working on:
# -W
@@ -22,7 +27,7 @@ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
# use of code cache tag lines) and uses more stack (less efficient use of data
# cache tag lines)
#
-.if ${MACHINE_ARCH} == "i386"
+.if ${MACHINE_ARCH} == "i386" && ${CC} != "icc"
CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
INLINE_LIMIT?= 8000
.endif
@@ -80,4 +85,12 @@ INLINE_LIMIT?= 15000
# GCC 3.0 and above like to do certain optimizations based on the
# assumption that the program is linked against libc. Stop this.
#
+.if ${CC} == "icc"
+CFLAGS+= -nolib_inline
+.else
CFLAGS+= -ffreestanding
+.endif
+
+.if ${CC} == "icc"
+CFLAGS+= -restrict
+.endif
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 9732ffb94089..4a786a54c807 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -16,14 +16,28 @@ NM?= nm
OBJCOPY?= objcopy
SIZE?= size
+.if ${CC} == "icc"
+COPTFLAGS?=-O
+.else
COPTFLAGS?=-O -pipe
-.if ${COPTFLAGS:M-O[23s]} != ""
+. if ${COPTFLAGS:M-O[23s]} != ""
COPTFLAGS+= -fno-strict-aliasing
+. endif
.endif
.if !defined(NO_CPU_COPTFLAGS)
+. if ${CC} == "icc"
+COPTFLAGS+= ${_ICC_CPUCFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
+. else
COPTFLAGS+= ${_CPUCFLAGS}
+. endif
+.endif
+.if ${CC} == "icc"
+NOSTDINC= -X
+.else
+NOSTDINC= -nostdinc
.endif
-INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S
+
+INCLUDES= ${NOSTDINC} -I- ${INCLMAGIC} -I. -I$S
# This hack lets us use the Intel ACPICA code without spamming a new
# include path into 100+ source files.
@@ -43,19 +57,34 @@ INCLUDES+= -I$S/contrib/ngatm
COPTS= ${INCLUDES} -D_KERNEL -include opt_global.h
CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
+.if ${CC} != "icc"
CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
WERROR?= -Werror
+.endif
# XXX LOCORE means "don't declare C stuff" not "for locore.s".
ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
+. if ${CC} == "icc"
+CFLAGS+= -DGPROF
+. else
CFLAGS+= -DGPROF -falign-functions=16
+. endif
.if ${PROFLEVEL} >= 2
CFLAGS+= -DGPROF4 -DGUPROF
+. if ${CC} == "icc"
+# XXX doesn't work yet
+#PROF= -prof_gen
+. else
PROF= -finstrument-functions
+. endif
.else
+. if ${CC} == "icc"
+PROF= -p
+. else
PROF= -pg
+. endif
.endif
.endif
DEFINED_PROF= ${PROF}
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 0766b71540aa..c3030619064d 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -70,6 +70,10 @@ OBJCOPY?= objcopy
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
+.if ${CC} == "icc"
+_ICC_CFLAGS:= ${CFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
+CFLAGS= ${_ICC_CFLAGS}
+.endif
CFLAGS+= ${COPTS} -D_KERNEL
CFLAGS+= -DKLD_MODULE
@@ -78,7 +82,12 @@ CFLAGS+= -DKLD_MODULE
# such paths after -nostdinc. It doesn't seem to be possible to
# add to the front of `make' variable.
_ICFLAGS:= ${CFLAGS:M-I*}
-CFLAGS+= -nostdinc -I- ${INCLMAGIC} ${_ICFLAGS}
+.if ${CC} == "icc"
+NOSTDINC= -X
+.else
+NOSTDINC= -nostdinc
+.endif
+CFLAGS+= ${NOSTDINC} -I- ${INCLMAGIC} ${_ICFLAGS}
.if defined(KERNBUILDDIR)
CFLAGS+= -include ${KERNBUILDDIR}/opt_global.h
.endif
@@ -102,11 +111,15 @@ CFLAGS+= -I${DESTDIR}/usr/include
CFLAGS+= -I@/../include -I${DESTDIR}/usr/include
.endif # @
+.if ${CC} != "icc"
CFLAGS+= -finline-limit=${INLINE_LIMIT}
+.endif
# Disallow common variables, and if we end up with commons from
# somewhere unexpected, allocate storage for them in the module itself.
+.if ${CC} != "icc"
CFLAGS+= -fno-common
+.endif
LDFLAGS+= -d -warn-common
CFLAGS+= ${DEBUG_FLAGS}