bsd.cpu.mk revision 177385
1147997Srwatson# $FreeBSD: head/share/mk/bsd.cpu.mk 177385 2008-03-19 12:20:44Z imp $ 2147997Srwatson 3147997Srwatson# Set default CPU compile flags and baseline CPUTYPE for each arch. The 4147997Srwatson# compile flags must support the minimum CPU type for each architecture but 5147997Srwatson# may tune support for more advanced processors. 6147997Srwatson 7147997Srwatson.if !defined(CPUTYPE) || empty(CPUTYPE) 8147997Srwatson_CPUCFLAGS = 9147997Srwatson. if ${MACHINE_ARCH} == "i386" 10147997SrwatsonMACHINE_CPU = i486 11147997Srwatson. elif ${MACHINE_ARCH} == "amd64" 12147997SrwatsonMACHINE_CPU = amd64 sse2 sse 13147997Srwatson. elif ${MACHINE_ARCH} == "ia64" 14147997SrwatsonMACHINE_CPU = itanium 15147997Srwatson. elif ${MACHINE_ARCH} == "powerpc" 16147997SrwatsonMACHINE_CPU = aim 17147997Srwatson. elif ${MACHINE_ARCH} == "sparc64" 18147997Srwatson. elif ${MACHINE_ARCH} == "arm" 19147997SrwatsonMACHINE_CPU = arm 20147997Srwatson. elif ${MACHINE_ARCH} == "mips" 21147997SrwatsonMACHINE_CPU = mips 22147997Srwatson. endif 23147997Srwatson.else 24147997Srwatson 25147997Srwatson# Handle aliases (not documented in make.conf to avoid user confusion 26147997Srwatson# between e.g. i586 and pentium) 27147997Srwatson 28147997Srwatson. if ${MACHINE_ARCH} == "i386" 29147997Srwatson. if ${CPUTYPE} == "nocona" 30147997SrwatsonCPUTYPE = prescott 31147997Srwatson. elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2" 32147997SrwatsonCPUTYPE = prescott 33147997Srwatson. elif ${CPUTYPE} == "p4" 34147997SrwatsonCPUTYPE = pentium4 35147997Srwatson. elif ${CPUTYPE} == "p4m" 36147997SrwatsonCPUTYPE = pentium4m 37147997Srwatson. elif ${CPUTYPE} == "p3" 38147997SrwatsonCPUTYPE = pentium3 39148041Srwatson. elif ${CPUTYPE} == "p3m" 40148041SrwatsonCPUTYPE = pentium3m 41148041Srwatson. elif ${CPUTYPE} == "p-m" 42148041SrwatsonCPUTYPE = pentium-m 43148041Srwatson. elif ${CPUTYPE} == "p2" 44148041SrwatsonCPUTYPE = pentium2 45148041Srwatson. elif ${CPUTYPE} == "i686" 46148041SrwatsonCPUTYPE = pentiumpro 47147997Srwatson. elif ${CPUTYPE} == "i586/mmx" 48147997SrwatsonCPUTYPE = pentium-mmx 49147997Srwatson. elif ${CPUTYPE} == "i586" 50147997SrwatsonCPUTYPE = pentium 51147997Srwatson. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 52147997Srwatson ${CPUTYPE} == "k8" 53147997SrwatsonCPUTYPE = athlon-mp 54147997Srwatson. elif ${CPUTYPE} == "k7" 55147997SrwatsonCPUTYPE = athlon 56147997Srwatson. endif 57147997Srwatson. elif ${MACHINE_ARCH} == "amd64" 58147997Srwatson. if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2" 59147997SrwatsonCPUTYPE = nocona 60147997Srwatson. endif 61147997Srwatson. endif 62147997Srwatson 63147997Srwatson############################################################################### 64147997Srwatson# Logic to set up correct gcc optimization flag. This must be included 65147997Srwatson# after /etc/make.conf so it can react to the local value of CPUTYPE 66147997Srwatson# defined therein. Consult: 67147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 68147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html 69147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html 70147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 71147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 72147997Srwatson# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 73147997Srwatson 74147997Srwatson. if ${MACHINE_ARCH} == "i386" 75147997Srwatson. if ${CPUTYPE} == "crusoe" 76147997Srwatson_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 77147997Srwatson. elif ${CPUTYPE} == "k5" 78148094Srwatson_CPUCFLAGS = -march=pentium 79147997Srwatson. else 80147997Srwatson_CPUCFLAGS = -march=${CPUTYPE} 81147997Srwatson. endif # GCC on 'i386' 82147997Srwatson. if ${CPUTYPE} == "crusoe" 83147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xiM 84147997Srwatson. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 85147997Srwatson ${CPUTYPE} == "athlon-4" 86147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xiMK 87147997Srwatson. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 88147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xiM 89147997Srwatson. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 90147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xi 91147997Srwatson. elif ${CPUTYPE} == "k5" 92147997Srwatson_ICC_CPUCFLAGS = -tpp5 93147997Srwatson. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 94147997Srwatson_ICC_CPUCFLAGS = -tpp7 -xiMKW 95147997Srwatson. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 96147997Srwatson ${CPUTYPE} == "pentium-m" 97147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xiMK 98147997Srwatson. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 99147997Srwatson_ICC_CPUCFLAGS = -tpp6 -xiM 100147997Srwatson. elif ${CPUTYPE} == "pentium-mmx" 101147997Srwatson_ICC_CPUCFLAGS = -tpp5 -xM 102147997Srwatson. elif ${CPUTYPE} == "pentium" 103147997Srwatson_ICC_CPUCFLAGS = -tpp5 104147997Srwatson. else 105147997Srwatson_ICC_CPUCFLAGS = 106147997Srwatson. endif # ICC on 'i386' 107147997Srwatson. elif ${MACHINE_ARCH} == "amd64" 108147997Srwatson_CPUCFLAGS = -march=${CPUTYPE} 109147997Srwatson. elif ${MACHINE_ARCH} == "arm" 110147997Srwatson. if ${CPUTYPE} == "xscale" 111147997Srwatson#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 112147997Srwatson#_CPUCFLAGS = -mcpu=xscale 113147997Srwatson_CPUCFLAGS = -march=armv5te -D__XSCALE__ 114147997Srwatson. else 115147997Srwatson_CPUCFLAGS = -mcpu=${CPUTYPE} 116147997Srwatson. endif 117147997Srwatson. elif ${MACHINE_ARCH} == "powerpc" 118147997Srwatson. if ${CPUTYPE} == "e500" 119147997SrwatsonMACHINE_CPU = booke 120147997Srwatson_CPUCFLAGS = -Wa,-me500 -msoft-float 121147997Srwatson. endif 122147997Srwatson. elif ${MACHINE_ARCH} == "mips" 123147997Srwatson. if ${CPUTYPE} == "mips32" 124147997Srwatson_CPUCFLAGS = -march=mips32 125147997Srwatson. elif ${CPUTYPE} == "mips32r2" 126147997Srwatson_CPUCFLAGS = -march=mips32r2 127147997Srwatson. elif ${CPUTYPE} == "mips64" 128147997Srwatson_CPUCFLAGS = -march=mips64 129147997Srwatson. elif ${CPUTYPE} == "mips64r2" 130147997Srwatson_CPUCFLAGS = -march=mips64r2 131147997Srwatson. elif ${CPUTYPE} == "mips4kc" 132147997Srwatson_CPUCFLAGS = -march=4kc 133147997Srwatson. elif ${CPUTYPE} == "mips24kc" 134147997Srwatson_CPUCFLAGS = -march=24kc 135147997Srwatson. endif 136147997Srwatson. endif 137147997Srwatson 138147997Srwatson# Set up the list of CPU features based on the CPU type. This is an 139147997Srwatson# unordered list to make it easy for client makefiles to test for the 140147997Srwatson# presence of a CPU feature. 141147997Srwatson 142148094Srwatson. if ${MACHINE_ARCH} == "i386" 143147997Srwatson. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 144147997SrwatsonMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 145. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 146 ${CPUTYPE} == "athlon-4" 147MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 148. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 149MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 150. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 151MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 152. elif ${CPUTYPE} == "k6" 153MACHINE_CPU = mmx k6 k5 i586 i486 i386 154. elif ${CPUTYPE} == "k5" 155MACHINE_CPU = k5 i586 i486 i386 156. elif ${CPUTYPE} == "c3" 157MACHINE_CPU = 3dnow mmx i586 i486 i386 158. elif ${CPUTYPE} == "c3-2" 159MACHINE_CPU = sse mmx i586 i486 i386 160. elif ${CPUTYPE} == "c7" 161MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 162. elif ${CPUTYPE} == "prescott" 163MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 164. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 165MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 166. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 167MACHINE_CPU = sse i686 mmx i586 i486 i386 168. elif ${CPUTYPE} == "pentium2" 169MACHINE_CPU = i686 mmx i586 i486 i386 170. elif ${CPUTYPE} == "pentiumpro" 171MACHINE_CPU = i686 i586 i486 i386 172. elif ${CPUTYPE} == "pentium-mmx" 173MACHINE_CPU = mmx i586 i486 i386 174. elif ${CPUTYPE} == "pentium" 175MACHINE_CPU = i586 i486 i386 176. elif ${CPUTYPE} == "i486" 177MACHINE_CPU = i486 i386 178. elif ${CPUTYPE} == "i386" 179MACHINE_CPU = i386 180. endif 181. elif ${MACHINE_ARCH} == "amd64" 182. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 183MACHINE_CPU = k8 3dnow 184. elif ${CPUTYPE} == "nocona" 185MACHINE_CPU = sse3 186. endif 187MACHINE_CPU += amd64 sse2 sse mmx 188. elif ${MACHINE_ARCH} == "ia64" 189. if ${CPUTYPE} == "itanium" 190MACHINE_CPU = itanium 191. endif 192. endif 193.endif 194 195.if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 196CFLAGS += -mbig-endian 197LDFLAGS += -mbig-endian 198LD += -EB 199.endif 200 201.if ${MACHINE_ARCH} == "mips" 202. if defined(TARGET_BIG_ENDIAN) 203CFLAGS += -EB 204LDFLAGS += -Wl,-EB 205LD += -EB 206. else 207CFLAGS += -EL 208LDFLAGS += -Wl,-EL 209LD += -EL 210. endif 211CFLAGS += -msoft-float -G0 -mno-dsp -mabicalls 212.endif 213 214# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 215 216.if !defined(NO_CPU_CFLAGS) 217. if ${CC} == "icc" 218CFLAGS += ${_ICC_CPUCFLAGS} 219. else 220CFLAGS += ${_CPUCFLAGS} 221. endif 222.endif 223