Add -march support for CCVER=clang* (new bsd.cpu.clang.mk)
authorJohn Marino <draco@marino.st>
Mon, 21 Mar 2016 17:56:50 +0000 (18:56 +0100)
committerJohn Marino <draco@marino.st>
Mon, 21 Mar 2016 18:06:56 +0000 (19:06 +0100)
share/mk/bsd.cpu.clang.mk [new file with mode: 0644]
share/mk/bsd.cpu.mk

diff --git a/share/mk/bsd.cpu.clang.mk b/share/mk/bsd.cpu.clang.mk
new file mode 100644 (file)
index 0000000..f8359e3
--- /dev/null
@@ -0,0 +1,45 @@
+# Set default CPU compile flags and baseline CPUTYPE for each arch.  The
+# compile flags must support the minimum CPU type for each architecture but
+# may tune support for more advanced processors.
+
+generic_x86_64=        x86_64 mmx sse sse2
+generic_i386=  i386
+
+.if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native"
+
+. if defined(CPUTYPE) && ${CPUTYPE:Mnative}
+_CPUCFLAGS=    -march=native
+. else
+_CPUCFLAGS=
+. endif
+
+MACHINE_CPU=   ${generic_${MACHINE_ARCH}}
+
+.else
+
+known_x86_64=  x86_64 i386
+known_i386=    i386
+
+. if defined(known_${MACHINE_ARCH}) && \
+     !empty(known_${MACHINE_ARCH}:M${CPUTYPE})         # CID: Check CPUTYPE
+
+# i386 used for 32-bit BIOS-based boot loaders
+
+C_x86_64=      ${generic_x86_64}
+C_i386=                ${generic_i386}
+
+_CPUCFLAGS=    -march=${CPUTYPE}
+MACHINE_CPU=   ${C_${CPUTYPE:S|-||}}
+
+. else                                                 # CID: Check CPUTYPE
+
+# CPUTYPE was defined and was not empty, but the value does not match known
+# CPU types of the defined MACHINE_ARCH.  Set -march to native and define
+# generic features based on MACHINE_ARCH
+
+_CPUCFLAGS=    -march=native
+MACHINE_CPU=   ${generic_${MACHINE_ARCH}}
+
+. endif                                                        # CID: Check CPUTYPE
+
+.endif
index 651c69c..2902691 100644 (file)
@@ -43,6 +43,8 @@ CPUTYPE= ${FORCE_CPUTYPE}
 .  include <bsd.cpu.gcc47.mk>
 .elif ${CCVER} == gcc50
 .  include <bsd.cpu.gcc50.mk>
+.elif ${CCVER:Mclang*}
+.  include <bsd.cpu.clang.mk>
 .else
 .  include <bsd.cpu.custom.mk>
 .endif