Re: 13.2-BETA2: xz: illegal instruction

2023-02-23 Thread Jamie Landeg-Jones
Peter  wrote:

> > # ./xz < /dev/zero > /dev/null
> > Illegal instruction (core dumped)
>   
>   
> > CPU: Intel(R) Core(TM) i3 CPU 540  @ 3.07GHz (3059.08-MHz K8-class 
> > CPU)
> > Origin="GenuineIntel"  Id=0x20655  Family=0x6  Model=0x25  Stepping=5   
> >   
>   
>   
> > CPUTYPE?=westmere
>
> It's liblzma, and it doesn't want westmere, it apparently wants
> penryn.

Doesn't "CPUTYPE?=native" do the right thing?

You can see what features this enables/disables on your machine
and also the determined "-target-cpu" in the following output:

/usr/bin/env -i /usr/bin/clang -v -x c -march=native -fsyntax-only -o /dev/null 
/dev/null 2>&1

Cheers, Jamie



Re: 13.2-BETA2: xz: illegal instruction

2023-02-23 Thread Peter
On Thu, Feb 23, 2023 at 02:22:01PM +, Jamie Landeg-Jones wrote:
! Peter  wrote:
! 
! > > # ./xz < /dev/zero > /dev/null
! > > Illegal instruction (core dumped)
! > 

! > > CPU: Intel(R) Core(TM) i3 CPU 540  @ 3.07GHz (3059.08-MHz 
K8-class CPU)
! > > Origin="GenuineIntel"  Id=0x20655  Family=0x6  Model=0x25  Stepping=5 

! > 

! > > CPUTYPE?=westmere
! >
! > It's liblzma, and it doesn't want westmere, it apparently wants
! > penryn.
! 
! Doesn't "CPUTYPE?=native" do the right thing?

Good point, I should test that. (It doesn't concern me, because that
would likely get me code for the machine that is actually doing the
build, and that is not the old i3)

! You can see what features this enables/disables on your machine
! and also the determined "-target-cpu" in the following output:
! 
! /usr/bin/env -i /usr/bin/clang -v -x c -march=native -fsyntax-only -o 
/dev/null /dev/null 2>&1

Thanks, You're helpful! :)

 -target-cpu westmere

But when building with CPTYPE?=native, the code works!


$  /usr/bin/env -i /usr/bin/clang -v -x c -march=native -fsyntax-only -o 
/dev/null /dev/null 2>&1
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git 
llvmorg-14.0.5-0-gc12386ae247c)
Target: x86_64-unknown-freebsd13.2
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd13.2 -fsyntax-only 
-disable-free -clear-ast-before-backend -disable-llvm-verifier 
-discard-value-names -main-file-name null -mrelocation-model static 
-mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases 
-funwind-tables=2 -target-cpu westmere -target-feature -avx512pf 
-target-feature -tsxldtrk -target-feature +cx16 -target-feature +sahf 
-target-feature -tbm -target-feature -avx512ifma -target-feature -sha 
-target-feature +crc32 -target-feature -fma4 -target-feature -vpclmulqdq 
-target-feature -prfchw -target-feature -bmi2 -target-feature -cldemote 
-target-feature -fsgsbase -target-feature -ptwrite -target-feature -amx-tile 
-target-feature -uintr -target-feature -gfni -target-feature +popcnt 
-target-feature -widekl -target-feature -aes -target-feature -avx512bitalg 
-target-feature -movdiri -target-feature -xsaves -target-feature -avx512er 
-target-feature -avxvnni -target-feature -avx512fp16 -target-feature 
-avx512vnni -target-feature -amx-bf16 -target-feature -avx512vpopcntdq 
-target-feature -pconfig -target-feature -clwb -target-feature -avx512f 
-target-feature -xsavec -target-feature -clzero -target-feature -pku 
-target-feature +mmx -target-feature -lwp -target-feature -rdpid 
-target-feature -xop -target-feature -rdseed -target-feature -waitpkg 
-target-feature -kl -target-feature -movdir64b -target-feature -sse4a 
-target-feature -avx512bw -target-feature -clflushopt -target-feature -xsave 
-target-feature -avx512vbmi2 -target-feature +64bit -target-feature -avx512vl 
-target-feature -serialize -target-feature -hreset -target-feature -invpcid 
-target-feature -avx512cd -target-feature -avx -target-feature -vaes 
-target-feature -avx512bf16 -target-feature +cx8 -target-feature -fma 
-target-feature -rtm -target-feature -bmi -target-feature -enqcmd 
-target-feature -rdrnd -target-feature -mwaitx -target-feature +sse4.1 
-target-feature +sse4.2 -target-feature -avx2 -target-feature +fxsr 
-target-feature -wbnoinvd -target-feature +sse -target-feature -lzcnt 
-target-feature -pclmul -target-feature -prefetchwt1 -target-feature -f16c 
-target-feature +ssse3 -target-feature -sgx -target-feature -shstk 
-target-feature +cmov -target-feature -avx512vbmi -target-feature -amx-int8 
-target-feature -movbe -target-feature -avx512vp2intersect -target-feature 
-xsaveopt -target-feature -avx512dq -target-feature +sse2 -target-feature -adx 
-target-feature +sse3 -mllvm -treat-scalable-fixed-error-as-warning 
-debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/operator -resource-dir 
/usr/lib/clang/14.0.5 -fdebug-compilation-dir=/home/operator -ferror-limit 19 
-fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c /dev/null
clang -cc1 version 14.0.5 based upon LLVM 14.0.5 default target 
x86_64-unknown-freebsd13.2
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/14.0.5/include
 /usr/include
End of search list.

$  /usr/bin/env -i /usr/bin/clang -v -x c -march=westmere -fsyntax-only -o 
/dev/null /dev/null 2>&1
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git 
llvmorg-14.0.5-0-gc12386ae247c)
Target: x86_64-unknown-freebsd13.2
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd13.2 -fsyntax-only 
-disable-free -clear-ast-before-backend -disable-llvm-verifier 
-discard-value-names -main-file-name null -mrelocation-model static 
-mframe-pointer=all -

Re: 13.2-BETA2: xz: illegal instruction

2023-02-23 Thread Jamie Landeg-Jones
Peter  wrote:

>  -target-cpu westmere
>
> But when building with CPTYPE?=native, the code works!

That's weird!

I notice the only difference between those 2 is that the "native" one
specifically sets (-target-feature +...) or unsets (-target-feature -...)
the features to use.

Presumably there is something enabled by default that shouldn't be
(for westmere), but the extra flags added with "native" fix that.

This is more a question for the clang folks, but if you're really 
interested, you could try (on your -march=westmere build)
disabling them in ever decreasing group sizes until you narrow
down the culprit!

This is what your native enables:

+64bit +cmov +crc32 +cx16 +cx8 +fxsr +mmx +popcnt +sahf +sse +sse2 +sse3 
+sse4.1 +sse4.2 +ssse3

And this is what it disables:

-adx -aes -amx-bf16 -amx-int8 -amx-tile -avx -avx2 -avx512bf16 -avx512bitalg 
-avx512bw -avx512cd -avx512dq -avx512er -avx512f -avx512fp16 -avx512ifma 
-avx512pf -avx512vbmi -avx512vbmi2 -avx512vl -avx512vnni -avx512vp2intersect 
-avx512vpopcntdq -avxvnni -bmi -bmi2 -cldemote -clflushopt -clwb -clzero 
-enqcmd -f16c -fma -fma4 -fsgsbase -gfni -hreset -invpcid -kl -lwp -lzcnt 
-movbe -movdir64b -movdiri -mwaitx -pclmul -pconfig -pku -prefetchwt1 -prfchw 
-ptwrite -rdpid -rdrnd -rdseed -rtm -serialize -sgx -sha -shstk -sse4a -tbm 
-tsxldtrk -uintr -vaes -vpclmulqdq -waitpkg -wbnoinvd -widekl -xop -xsave 
-xsavec -xsaveopt -xsaves

Cheers, Jamie



Re: 13.2-BETA2: xz: illegal instruction

2023-02-23 Thread Peter
On Thu, Feb 23, 2023 at 10:14:13PM +, Jamie Landeg-Jones wrote:
! Peter  wrote:
! 
! >  -target-cpu westmere
! >
! > But when building with CPTYPE?=native, the code works!
! 
! That's weird!

Ah. Hm...

! I notice the only difference between those 2 is that the "native" one
! specifically sets (-target-feature +...) or unsets (-target-feature -...)
! the features to use.
! 
! Presumably there is something enabled by default that shouldn't be
! (for westmere), but the extra flags added with "native" fix that.

Very likely so.

! This is more a question for the clang folks, but if you're really 
! interested, you could try (on your -march=westmere build)
! disabling them in ever decreasing group sizes until you narrow
! down the culprit!

Negative. I have a whole lot more of these little nasty bugs to
pursue. Bug number is 269792

Cheerio, and kind thanks for the helping hand!