1# $FreeBSD$ 2 3# Set default CPU compile flags and baseline CPUTYPE for each arch. The 4# compile flags must support the minimum CPU type for each architecture but 5# may tune support for more advanced processors. 6 7.if !defined(CPUTYPE) || empty(CPUTYPE) 8_CPUCFLAGS = 9. if ${MACHINE_CPUARCH} == "i386" 10MACHINE_CPU = i486 11. elif ${MACHINE_CPUARCH} == "amd64" 12MACHINE_CPU = amd64 sse2 sse mmx 13. elif ${MACHINE_CPUARCH} == "powerpc" 14MACHINE_CPU = aim 15. elif ${MACHINE_CPUARCH} == "sparc64" 16MACHINE_CPU = ultrasparc 17. elif ${MACHINE_CPUARCH} == "arm" 18MACHINE_CPU = arm 19. elif ${MACHINE_CPUARCH} == "mips" 20MACHINE_CPU = mips 21. endif 22.else 23 24# Handle aliases (not documented in make.conf to avoid user confusion 25# between e.g. i586 and pentium) 26 27. if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 28. if ${CPUTYPE} == "barcelona" 29CPUTYPE = amdfam10 30. elif ${CPUTYPE} == "core-avx2" 31CPUTYPE = haswell 32. elif ${CPUTYPE} == "core-avx-i" 33CPUTYPE = ivybridge 34. elif ${CPUTYPE} == "corei7-avx" 35CPUTYPE = sandybridge 36. elif ${CPUTYPE} == "corei7" 37CPUTYPE = nehalem 38. elif ${CPUTYPE} == "slm" 39CPUTYPE = silvermont 40. elif ${CPUTYPE} == "atom" 41CPUTYPE = bonnell 42. elif ${CPUTYPE} == "core" 43CPUTYPE = prescott 44. endif 45. if ${MACHINE_CPUARCH} == "amd64" 46. if ${CPUTYPE} == "prescott" 47CPUTYPE = nocona 48. endif 49. else 50. if ${CPUTYPE} == "k7" 51CPUTYPE = athlon 52. elif ${CPUTYPE} == "p4" 53CPUTYPE = pentium4 54. elif ${CPUTYPE} == "p4m" 55CPUTYPE = pentium4m 56. elif ${CPUTYPE} == "p3" 57CPUTYPE = pentium3 58. elif ${CPUTYPE} == "p3m" 59CPUTYPE = pentium3m 60. elif ${CPUTYPE} == "p-m" 61CPUTYPE = pentium-m 62. elif ${CPUTYPE} == "p2" 63CPUTYPE = pentium2 64. elif ${CPUTYPE} == "i686" 65CPUTYPE = pentiumpro 66. elif ${CPUTYPE} == "i586/mmx" 67CPUTYPE = pentium-mmx 68. elif ${CPUTYPE} == "i586" 69CPUTYPE = pentium 70. endif 71. endif 72. elif ${MACHINE_ARCH} == "sparc64" 73. if ${CPUTYPE} == "us" 74CPUTYPE = ultrasparc 75. elif ${CPUTYPE} == "us3" 76CPUTYPE = ultrasparc3 77. endif 78. endif 79 80############################################################################### 81# Logic to set up correct gcc optimization flag. This must be included 82# after /etc/make.conf so it can react to the local value of CPUTYPE 83# defined therein. Consult: 84# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 85# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 86# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 87# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 88# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 89# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 90 91. if ${MACHINE_CPUARCH} == "i386" 92. if ${CPUTYPE} == "crusoe" 93_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 94. elif ${CPUTYPE} == "k5" 95_CPUCFLAGS = -march=pentium 96. elif ${CPUTYPE} == "c7" 97_CPUCFLAGS = -march=c3-2 98. else 99_CPUCFLAGS = -march=${CPUTYPE} 100. endif 101. elif ${MACHINE_CPUARCH} == "amd64" 102_CPUCFLAGS = -march=${CPUTYPE} 103. elif ${MACHINE_CPUARCH} == "arm" 104. if ${CPUTYPE} == "xscale" 105#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 106#_CPUCFLAGS = -mcpu=xscale 107_CPUCFLAGS = -march=armv5te -D__XSCALE__ 108. elif ${CPUTYPE} == "armv6" 109_CPUCFLAGS = -march=${CPUTYPE} -DARM_ARCH_6=1 110. elif ${CPUTYPE} == "cortexa" 111_CPUCFLAGS = -march=armv7 -DARM_ARCH_6=1 -mfpu=vfp 112. else 113_CPUCFLAGS = -mcpu=${CPUTYPE} 114. endif 115. elif ${MACHINE_ARCH} == "powerpc" 116. if ${CPUTYPE} == "e500" 117_CPUCFLAGS = -Wa,-me500 -msoft-float 118. else 119_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 120. endif 121. elif ${MACHINE_ARCH} == "powerpc64" 122_CPUCFLAGS = -mcpu=${CPUTYPE} 123. elif ${MACHINE_CPUARCH} == "mips" 124. if ${CPUTYPE} == "mips32" 125_CPUCFLAGS = -march=mips32 126. elif ${CPUTYPE} == "mips32r2" 127_CPUCFLAGS = -march=mips32r2 128. elif ${CPUTYPE} == "mips64" 129_CPUCFLAGS = -march=mips64 130. elif ${CPUTYPE} == "mips64r2" 131_CPUCFLAGS = -march=mips64r2 132. elif ${CPUTYPE} == "mips4kc" 133_CPUCFLAGS = -march=4kc 134. elif ${CPUTYPE} == "mips24kc" 135_CPUCFLAGS = -march=24kc 136. endif 137. elif ${MACHINE_ARCH} == "sparc64" 138. if ${CPUTYPE} == "v9" 139_CPUCFLAGS = -mcpu=v9 140. elif ${CPUTYPE} == "ultrasparc" 141_CPUCFLAGS = -mcpu=ultrasparc 142. elif ${CPUTYPE} == "ultrasparc3" 143_CPUCFLAGS = -mcpu=ultrasparc3 144. endif 145. endif 146 147# Set up the list of CPU features based on the CPU type. This is an 148# unordered list to make it easy for client makefiles to test for the 149# presence of a CPU feature. 150 151. if ${MACHINE_CPUARCH} == "i386" 152. if ${CPUTYPE} == "bdver4" 153MACHINE_CPU = xop avx2 avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 154. elif ${CPUTYPE} == "bdver3" || ${CPUTYPE} == "bdver2" || \ 155 ${CPUTYPE} == "bdver1" 156MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 157. elif ${CPUTYPE} == "btver2" 158MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 159. elif ${CPUTYPE} == "btver1" 160MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 161. elif ${CPUTYPE} == "amdfam10" 162MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586 163. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" 164MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 165. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 166 ${CPUTYPE} == "athlon-fx" 167MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 168. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 169 ${CPUTYPE} == "athlon-4" 170MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 171. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 172MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 173. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" 174MACHINE_CPU = 3dnow mmx k6 k5 i586 175. elif ${CPUTYPE} == "k6" 176MACHINE_CPU = mmx k6 k5 i586 177. elif ${CPUTYPE} == "k5" 178MACHINE_CPU = k5 i586 179. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "knl" 180MACHINE_CPU = avx512 avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 181. elif ${CPUTYPE} == "broadwell" || ${CPUTYPE} == "haswell" 182MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 183. elif ${CPUTYPE} == "ivybridge" || ${CPUTYPE} == "sandybridge" 184MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 185. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" || \ 186 ${CPUTYPE} == "silvermont" 187MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 188. elif ${CPUTYPE} == "penryn" 189MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 190. elif ${CPUTYPE} == "core2" || ${CPUTYPE} == "bonnell" 191MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 192. elif ${CPUTYPE} == "yonah" || ${CPUTYPE} == "prescott" 193MACHINE_CPU = sse3 sse2 sse i686 mmx i586 194. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || \ 195 ${CPUTYPE} == "pentium-m" 196MACHINE_CPU = sse2 sse i686 mmx i586 197. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 198MACHINE_CPU = sse i686 mmx i586 199. elif ${CPUTYPE} == "pentium2" 200MACHINE_CPU = i686 mmx i586 201. elif ${CPUTYPE} == "pentiumpro" 202MACHINE_CPU = i686 i586 203. elif ${CPUTYPE} == "pentium-mmx" 204MACHINE_CPU = mmx i586 205. elif ${CPUTYPE} == "pentium" 206MACHINE_CPU = i586 207. elif ${CPUTYPE} == "c7" 208MACHINE_CPU = sse3 sse2 sse i686 mmx i586 209. elif ${CPUTYPE} == "c3-2" 210MACHINE_CPU = sse i686 mmx i586 211. elif ${CPUTYPE} == "c3" 212MACHINE_CPU = 3dnow mmx i586 213. elif ${CPUTYPE} == "winchip2" 214MACHINE_CPU = 3dnow mmx 215. elif ${CPUTYPE} == "winchip-c6" 216MACHINE_CPU = mmx 217. endif 218MACHINE_CPU += i486 219. elif ${MACHINE_CPUARCH} == "amd64" 220. if ${CPUTYPE} == "bdver4" 221MACHINE_CPU = xop avx2 avx sse42 sse41 ssse3 sse4a sse3 222. elif ${CPUTYPE} == "bdver3" || ${CPUTYPE} == "bdver2" || \ 223 ${CPUTYPE} == "bdver1" 224MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 225. elif ${CPUTYPE} == "btver2" 226MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 227. elif ${CPUTYPE} == "btver1" 228MACHINE_CPU = ssse3 sse4a sse3 229. elif ${CPUTYPE} == "amdfam10" 230MACHINE_CPU = k8 3dnow sse4a sse3 231. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ 232 ${CPUTYPE} == "k8-sse3" 233MACHINE_CPU = k8 3dnow sse3 234. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 235 ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" 236MACHINE_CPU = k8 3dnow 237. elif ${CPUTYPE} == "skylake" || ${CPUTYPE} == "knl" 238MACHINE_CPU = avx512 avx2 avx sse42 sse41 ssse3 sse3 239. elif ${CPUTYPE} == "broadwell" || ${CPUTYPE} == "haswell" 240MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 241. elif ${CPUTYPE} == "ivybridge" || ${CPUTYPE} == "sandybridge" 242MACHINE_CPU = avx sse42 sse41 ssse3 sse3 243. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" || \ 244 ${CPUTYPE} == "silvermont" 245MACHINE_CPU = sse42 sse41 ssse3 sse3 246. elif ${CPUTYPE} == "penryn" 247MACHINE_CPU = sse41 ssse3 sse3 248. elif ${CPUTYPE} == "core2" || ${CPUTYPE} == "bonnell" 249MACHINE_CPU = ssse3 sse3 250. elif ${CPUTYPE} == "nocona" 251MACHINE_CPU = sse3 252. endif 253MACHINE_CPU += amd64 sse2 sse mmx 254. elif ${MACHINE_ARCH} == "powerpc" 255. if ${CPUTYPE} == "e500" 256MACHINE_CPU = booke 257. endif 258. elif ${MACHINE_ARCH} == "sparc64" 259. if ${CPUTYPE} == "v9" 260MACHINE_CPU = v9 261. elif ${CPUTYPE} == "ultrasparc" 262MACHINE_CPU = v9 ultrasparc 263. elif ${CPUTYPE} == "ultrasparc3" 264MACHINE_CPU = v9 ultrasparc ultrasparc3 265. endif 266. endif 267.endif 268 269.if ${MACHINE_CPUARCH} == "mips" 270CFLAGS += -G0 271.endif 272 273.if ${MACHINE_ARCH} == "armv6" 274_CPUCFLAGS += -mfloat-abi=softfp 275.endif 276 277# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 278 279.if !defined(NO_CPU_CFLAGS) 280CFLAGS += ${_CPUCFLAGS} 281.endif 282 283# Add in any architecture-specific CFLAGS. 284# These come from make.conf or the command line or the environment. 285CFLAGS += ${CFLAGS.${MACHINE_ARCH}} 286CXXFLAGS += ${CXXFLAGS.${MACHINE_ARCH}} 287