bsd.cpu.mk revision 188923
172878Skris# $FreeBSD: head/share/mk/bsd.cpu.mk 188923 2009-02-22 18:45:30Z nwhitehorn $ 272878Skris 3100772Sjhb# Set default CPU compile flags and baseline CPUTYPE for each arch. The 4100772Sjhb# compile flags must support the minimum CPU type for each architecture but 5100772Sjhb# may tune support for more advanced processors. 672878Skris 7101232Sru.if !defined(CPUTYPE) || empty(CPUTYPE) 8136606Sobrien_CPUCFLAGS = 9100773Sjhb. if ${MACHINE_ARCH} == "i386" 10113374SobrienMACHINE_CPU = i486 11126657Sbde. elif ${MACHINE_ARCH} == "amd64" 12115175SpeterMACHINE_CPU = amd64 sse2 sse 13100773Sjhb. elif ${MACHINE_ARCH} == "ia64" 14103560SjhbMACHINE_CPU = itanium 15176776Sraj. elif ${MACHINE_ARCH} == "powerpc" 16176776SrajMACHINE_CPU = aim 17100773Sjhb. elif ${MACHINE_ARCH} == "sparc64" 18129217Scognet. elif ${MACHINE_ARCH} == "arm" 19129217ScognetMACHINE_CPU = arm 20177385Simp. elif ${MACHINE_ARCH} == "mips" 21177385SimpMACHINE_CPU = mips 22100773Sjhb. endif 23100772Sjhb.else 2472878Skris 2572878Skris# Handle aliases (not documented in make.conf to avoid user confusion 2672878Skris# between e.g. i586 and pentium) 2772878Skris 28100773Sjhb. if ${MACHINE_ARCH} == "i386" 29166071Sdes. if ${CPUTYPE} == "nocona" 30166071SdesCPUTYPE = prescott 31166071Sdes. elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2" 32166071SdesCPUTYPE = prescott 33136607Sobrien. elif ${CPUTYPE} == "p4" 34136606SobrienCPUTYPE = pentium4 35136606Sobrien. elif ${CPUTYPE} == "p4m" 36136606SobrienCPUTYPE = pentium4m 37136606Sobrien. elif ${CPUTYPE} == "p3" 38136606SobrienCPUTYPE = pentium3 39136606Sobrien. elif ${CPUTYPE} == "p3m" 40136606SobrienCPUTYPE = pentium3m 41136606Sobrien. elif ${CPUTYPE} == "p-m" 42136606SobrienCPUTYPE = pentium-m 43136606Sobrien. elif ${CPUTYPE} == "p2" 44136606SobrienCPUTYPE = pentium2 45136606Sobrien. elif ${CPUTYPE} == "i686" 46136606SobrienCPUTYPE = pentiumpro 47136606Sobrien. elif ${CPUTYPE} == "i586/mmx" 48136606SobrienCPUTYPE = pentium-mmx 49136606Sobrien. elif ${CPUTYPE} == "i586" 50136606SobrienCPUTYPE = pentium 51136607Sobrien. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 52136607Sobrien ${CPUTYPE} == "k8" 53133525SobrienCPUTYPE = athlon-mp 54103045Smux. elif ${CPUTYPE} == "k7" 55103045SmuxCPUTYPE = athlon 56100773Sjhb. endif 57136607Sobrien. elif ${MACHINE_ARCH} == "amd64" 58166072Sdes. if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2" 59136607SobrienCPUTYPE = nocona 60136607Sobrien. endif 6172878Skris. endif 6272878Skris 63136606Sobrien############################################################################### 6496421Sobrien# Logic to set up correct gcc optimization flag. This must be included 6572878Skris# after /etc/make.conf so it can react to the local value of CPUTYPE 6696421Sobrien# defined therein. Consult: 67160536Simp# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 68179989Sale# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 69179989Sale# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 70177385Simp# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 7196421Sobrien# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 72179989Sale# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 7372878Skris 7472878Skris. if ${MACHINE_ARCH} == "i386" 75127888Sdfr. if ${CPUTYPE} == "crusoe" 76133000Sobrien_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 77136606Sobrien. elif ${CPUTYPE} == "k5" 78136606Sobrien_CPUCFLAGS = -march=pentium 79136606Sobrien. else 80136606Sobrien_CPUCFLAGS = -march=${CPUTYPE} 81136606Sobrien. endif # GCC on 'i386' 82136606Sobrien. if ${CPUTYPE} == "crusoe" 83127888Sdfr_ICC_CPUCFLAGS = -tpp6 -xiM 84127888Sdfr. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 85126938Strhodes ${CPUTYPE} == "athlon-4" 86126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 87126890Strhodes. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 88126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 89112768Sobrien. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 90126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xi 9172878Skris. elif ${CPUTYPE} == "k5" 92126890Strhodes_ICC_CPUCFLAGS = -tpp5 93136606Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 94126890Strhodes_ICC_CPUCFLAGS = -tpp7 -xiMKW 95136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 96136606Sobrien ${CPUTYPE} == "pentium-m" 97126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 98136606Sobrien. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 99126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 100136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 101126890Strhodes_ICC_CPUCFLAGS = -tpp5 -xM 102136606Sobrien. elif ${CPUTYPE} == "pentium" 103126890Strhodes_ICC_CPUCFLAGS = -tpp5 104136606Sobrien. else 105126890Strhodes_ICC_CPUCFLAGS = 106136606Sobrien. endif # ICC on 'i386' 107136607Sobrien. elif ${MACHINE_ARCH} == "amd64" 108136607Sobrien_CPUCFLAGS = -march=${CPUTYPE} 109135678Scognet. elif ${MACHINE_ARCH} == "arm" 110136606Sobrien. if ${CPUTYPE} == "xscale" 111172706Scognet#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 112172706Scognet#_CPUCFLAGS = -mcpu=xscale 113172706Scognet_CPUCFLAGS = -march=armv5te -D__XSCALE__ 114136606Sobrien. else 115136606Sobrien_CPUCFLAGS = -mcpu=${CPUTYPE} 116135678Scognet. endif 117176776Sraj. elif ${MACHINE_ARCH} == "powerpc" 118176776Sraj. if ${CPUTYPE} == "e500" 119176776SrajMACHINE_CPU = booke 120176776Sraj_CPUCFLAGS = -Wa,-me500 -msoft-float 121188923Snwhitehorn. else 122188923Snwhitehorn_CPUCFLAGS = -mcpu=${CPUTYPE} 123176776Sraj. endif 124177385Simp. elif ${MACHINE_ARCH} == "mips" 125177385Simp. if ${CPUTYPE} == "mips32" 126177385Simp_CPUCFLAGS = -march=mips32 127177385Simp. elif ${CPUTYPE} == "mips32r2" 128177385Simp_CPUCFLAGS = -march=mips32r2 129177385Simp. elif ${CPUTYPE} == "mips64" 130177385Simp_CPUCFLAGS = -march=mips64 131177385Simp. elif ${CPUTYPE} == "mips64r2" 132177385Simp_CPUCFLAGS = -march=mips64r2 133177385Simp. elif ${CPUTYPE} == "mips4kc" 134177385Simp_CPUCFLAGS = -march=4kc 135177385Simp. elif ${CPUTYPE} == "mips24kc" 136177385Simp_CPUCFLAGS = -march=24kc 137177385Simp. endif 13872878Skris. endif 13972878Skris 14072878Skris# Set up the list of CPU features based on the CPU type. This is an 14172878Skris# unordered list to make it easy for client makefiles to test for the 14272878Skris# presence of a CPU feature. 14372878Skris 144126657Sbde. if ${MACHINE_ARCH} == "i386" 145136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 146136607SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 147136607Sobrien. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 148125254Sbde ${CPUTYPE} == "athlon-4" 149136606SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 150126657Sbde. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 151112768SobrienMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 152126657Sbde. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 153103045SmuxMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 154103562Sjhb. elif ${CPUTYPE} == "k6" 15574069SsobomaxMACHINE_CPU = mmx k6 k5 i586 i486 i386 156103562Sjhb. elif ${CPUTYPE} == "k5" 15772878SkrisMACHINE_CPU = k5 i586 i486 i386 158160497Sdes. elif ${CPUTYPE} == "c3" 159161259SdesMACHINE_CPU = 3dnow mmx i586 i486 i386 160160497Sdes. elif ${CPUTYPE} == "c3-2" 161160497SdesMACHINE_CPU = sse mmx i586 i486 i386 162176665Sjhb. elif ${CPUTYPE} == "c7" 163176665SjhbMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 164166071Sdes. elif ${CPUTYPE} == "prescott" 165166069SdesMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 166136607Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 167103045SmuxMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 168136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 16973145SkrisMACHINE_CPU = sse i686 mmx i586 i486 i386 170136606Sobrien. elif ${CPUTYPE} == "pentium2" 17174553SkrisMACHINE_CPU = i686 mmx i586 i486 i386 172136606Sobrien. elif ${CPUTYPE} == "pentiumpro" 17372878SkrisMACHINE_CPU = i686 i586 i486 i386 174136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 17573145SkrisMACHINE_CPU = mmx i586 i486 i386 176136606Sobrien. elif ${CPUTYPE} == "pentium" 17772878SkrisMACHINE_CPU = i586 i486 i386 178103562Sjhb. elif ${CPUTYPE} == "i486" 17972878SkrisMACHINE_CPU = i486 i386 180103562Sjhb. elif ${CPUTYPE} == "i386" 18172878SkrisMACHINE_CPU = i386 182103562Sjhb. endif 183115175Speter. elif ${MACHINE_ARCH} == "amd64" 184136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 185138685SobrienMACHINE_CPU = k8 3dnow 186166071Sdes. elif ${CPUTYPE} == "nocona" 187138685SobrienMACHINE_CPU = sse3 188136607Sobrien. endif 189138685SobrienMACHINE_CPU += amd64 sse2 sse mmx 190103562Sjhb. elif ${MACHINE_ARCH} == "ia64" 191103562Sjhb. if ${CPUTYPE} == "itanium" 19272878SkrisMACHINE_CPU = itanium 193103562Sjhb. endif 19472878Skris. endif 19572878Skris.endif 196103561Sjhb 197163513Scognet.if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 198160534ScognetCFLAGS += -mbig-endian 199160544ScognetLDFLAGS += -mbig-endian 200160535ScognetLD += -EB 201160534Scognet.endif 202160534Scognet 203177385Simp.if ${MACHINE_ARCH} == "mips" 204177385Simp. if defined(TARGET_BIG_ENDIAN) 205177385SimpCFLAGS += -EB 206177385SimpLDFLAGS += -Wl,-EB 207177385SimpLD += -EB 208177385Simp. else 209177385SimpCFLAGS += -EL 210177385SimpLDFLAGS += -Wl,-EL 211177385SimpLD += -EL 212177385Simp. endif 213177385SimpCFLAGS += -msoft-float -G0 -mno-dsp -mabicalls 214177385Simp.endif 215177385Simp 216124347Sru# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 217103561Sjhb 218103561Sjhb.if !defined(NO_CPU_CFLAGS) 219126890Strhodes. if ${CC} == "icc" 220126890StrhodesCFLAGS += ${_ICC_CPUCFLAGS} 221126890Strhodes. else 222103561SjhbCFLAGS += ${_CPUCFLAGS} 223126890Strhodes. endif 224103561Sjhb.endif 225