clang broken on current?

Mark Millard marklmi at yahoo.com
Sun Feb 10 21:52:40 UTC 2019



On 2019-Feb-10, at 12:02, Mark Millard <marklmi at yahoo.com> wrote:



> On 2019-Feb-10, at 11:34, Steve Kargl <sgk at troutmask.apl.washington.edu> wrote:
> 
>> Having set CFLAGS+=-march=native -mtune=native and trying to
>> force qt5-gui configure with -sse2 option, I have a config.summary
>> that contains (my in-line comments ***)
>> 
>> Build type: freebsd-clang (i386, CPU features: <none>)
>> 
>> *** What????? ***
>> 
>> Compiler: clang 7.0.1
>> Configuration: compile_examples largefile rdrnd x86SimdAlways sharedr
>> rpath release c++11 c++14 concurrent dbus reduce_exports reduce_relocations
>> stl
>> Build options:
>> Mode ................................... release
>> Optimize release build for size ........ no
>> Building shared libraries .............. yes
>> Using C standard ....................... C11
>> Using C++ standard ..................... C++14
>> Using ccache ........................... no
>> Using gold linker ...................... no
>> Using precompiled headers .............. no
>> Using LTCG ............................. no
>> Target compiler supports:
>>   SSE .................................. <none>
>> 
>> *** That's not good. ***
>> 
>>   AVX .................................. <none>
>>   AVX512 ............................... <none>
>>   Other x86 ............................ RDRAND
>>   Intrinsics without -mXXX option ...... yes
>> Build parts ............................ libs tools
> 
> 
> /usr/ports/Mk/Uses/qt-dist.mk has:
> 
> .    if ${ARCH} == i386 && empty(MACHINE_CPU:Msse2)
> CONFIGURE_ARGS+=        -no-sse2
> .    endif
> 
> This traces back to:
> 
> /usr/src/share/mk/bsd.cpu.mk and its:
> 
> . elif ${MACHINE_CPUARCH} == "amd64"
> MACHINE_CPU = amd64 sse2 sse mmx
> . elif ${MACHINE_CPUARCH} == "arm"
> MACHINE_CPU = arm
> . elif ${MACHINE_CPUARCH} == "i386"
> MACHINE_CPU = i486
> 
> and (I'll not list it all):
> 
> ########## i386
> . if ${MACHINE_CPUARCH} == "i386"
> .  if ${CPUTYPE} == "znver1"
> MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "bdver4"
> MACHINE_CPU = xop avx2 avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "bdver3" || ${CPUTYPE} == "bdver2" || \
>    ${CPUTYPE} == "bdver1"
> MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "btver2"
> MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "btver1"
> MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "amdfam10"
> MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3"
> MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586
> .  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
> 
> . . .
> 
> and:
> 
> ########## amd64
> . elif ${MACHINE_CPUARCH} == "amd64"
> .  if ${CPUTYPE} == "znver1"
> MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse4a sse3
> . . .
> .  endif
> MACHINE_CPU += amd64 sse2 sse mmx
> ########## Mips
> . elif ${MACHINE_CPUARCH} == "mips"
> 
> 
> So it looks like freeBSD expects CPUTYPE to be set for i368 in order
> to enable sse2 in MACHINE_CPU . Other things have a similar status
> for amd64 but amd64 always has sse2 .
> 


[I see I switched which message that I was replying to. Sorry.]

Looks like when native works and clang is in use, and the context
is amd64 (or i386), CPUTYPE could be generated by the likes of
(example from my amd64 context):

# sh -c "clang -v -fsyntax-only -march=native -x c /dev/null 2>&1 | grep -e '-target-cpu' | sed -e 's|.*-target-cpu \([[:alnum:]]*\) .*|\1|'"
znver1

(I got that command from https://forums.freebsd.org/threads/make-conf-optimizations-optimizing-builds.63461/ .)

Trying such on a cortex-a57 (aarch64) got an empty-string result.
Same for cortex-a53 (aarch64) and cortex-a7 (armv7). (I do not have
a powerpc* available at the moment.)

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-toolchain mailing list