Created attachment 175492 [details] v1 Defining CPUTYPE via make.conf appends -march=${CPUTYPE} to CFLAGS and advertises SIMD features via MACHINE_CPU to ports. -msse2 is implicit on amd64 but marisa-trie appears to gate intrinsics based on its own configure flags. See /usr/share/mk/bsd.cpu.mk. $ clang -target i386--freebsd -dM -E -</dev/null | fgrep SSE $ clang -target x86_64--freebsd -dM -E -</dev/null | fgrep SSE #define __SSE2_MATH__ 1 #define __SSE2__ 1 #define __SSE_MATH__ 1 #define __SSE__ 1
Comment on attachment 175492 [details] v1 Thanks!
By the way, I am also curious about: is there any better way to get the CPU features shown in `dmesg` and put them in OPTIONS_DEFAULT? I just read the `bsd.cpu.mk` and it just defines constant. And the CPU info from dmesg is helpful, but the `dmesg` may be gone. So .. . how to get the info without dmesg? My CPU info from dmesg looks like this: ---- CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz (3392.37-MHz K8-class CPU) Origin="GenuineIntel" Id=0x206a7 Family=0x6 Model=0x2a Stepping=7 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x1fbae3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX> AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM> AMD Features2=0x1<LAHF> XSAVE Features=0x1<XSAVEOPT> VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID TSC: P-state invariant, performance statistics
dmesg(8) or rather /var/run/dmesg.boot is a basic CPUID check in kernel. What you probably want is extract supported features out of compiler, similar to bug 112997. Output depends on compiler type and version, so any make(1) magic would have to accomodate. Here's an example: ############################# .ifnmake describe _CC1!= ${CC} -E -v -march=native -</dev/null 2>&1 | fgrep cc1 . if ${_CC1:M*-triple*} # clang _SIMD= ${_CC1:M+*:S/^+//:S/.//g} . else _SIMD= ${_CC1:N-mno-*:N-march*:N-mtune*:M-m*:S/-m//:S/.//g} . endif MACHINE_CPU+= ${_SIMD} .endif print-simd: @${ECHO} ${_SIMD} ############################# $ cc -v |& fgrep ' version' FreeBSD clang version 3.9.0 (tags/RELEASE_390/final 280324) (based on LLVM 3.9.0) $ gcc6 -v |& fgrep ' version' gcc version 6.2.0 (FreeBSD Ports Collection) $ make print-simd sse2 cx16 prfchw bmi2 xsavec fsgsbase popcnt aes xsaves smap mmx rdseed hle clflushopt xsave invpcidavx rtm fma bmi rdrnd sse41 sse42 avx2 sse lzcnt pclmul f16c ssse3 sgx cmov movbe xsaveopt adx sse3 $ make print-simd CC=gcc6 mmx sse sse2 sse3 ssse3 cx16 sahf movbe aes pclmul popcnt abm fma bmi bmi2 avx avx2 sse42 sse41 lzcnt rtm hle rdrnd f16c fsgsbase rdseed prfchw adx fxsr xsave xsaveopt clflushopt xsavec xsaves $ make -V OPTIONS_DEFAULT ADX AES AMD64 AVX AVX2 BMI BMI2 CLFLUSHOPT CMOV CX16 F16C FMA FMA3 FSGSBASE HLE INVPCID LZCNT MMX MOVBE PCLMUL POPCNT PRFCHW RDRND RDSEED RTM SGX SMAP SSE SSE2 SSE3 SSE41 SSE42 SSSE3 XSAVE XSAVEC XSAVEOPT XSAVES ############################# It maybe worth to write new USES for to supplant bsd.cpu.mk but let's keep individual port's Makefiles in a declarative style. This means complex stuff like conditionals, shell invocations should be avoided or kept to minimum.
A commit references this bug: Author: jbeich Date: Mon Oct 10 04:26:23 UTC 2016 New revision: 423634 URL: https://svnweb.freebsd.org/changeset/ports/423634 Log: devel/marisa-trie: enable SSE2 by default on amd64 Respect CPUTYPE defined via make.conf in order to derive option defaults. PR: 213271 Approved by: Iblis Lin (maintainer) Changes: head/devel/marisa-trie/Makefile