build errors - SSE & 'pclmulqdq' not a recognized feature
Context
Odin: dev-2022-10:ee070c9b
OS: Windows 10 Professional (version: 21H2), build 19044.2006
CPU: AMD Ryzen 9 3950X 16-Core Processor
RAM: 32686 MiB
Behavior
import "core:simd/x86" causes the following warnings:
PS C:\odin> odin build . --debug
'pclmulqdq' is not a recognized feature for this target (ignoring feature) <-- repeats x3
LLVM ERROR: SSE register return with SSE disabled
Note: I cannot get the llvm error to reproduce on the minimal case, but removing the core/simd import resolves the sse error in my larger project.
Steps to Reproduce
package sse_issue
import "core:simd/x86"
main :: proc() {
cycle_count := x86._rdtsc()
}
C:\odin> odin build . --debug
same thing on linux
Odin: dev-2022-10:9bdbb455
OS: Linux Mint 20.3, Linux 5.4.0-125-generic
CPU: AMD Ryzen 5 3600 6-Core Processor
RAM: 15993 MiB
the error output seems different though
'pclmulqdq' is not a recognized feature for this target (ignoring feature)
'pclmulqdq' is not a recognized feature for this target (ignoring feature)
'pclmulqdq' is not a recognized feature for this target (ignoring feature)
error: <unknown>:0:0: in function __gnu_h2f_ieee float (i16): SSE register return with SSE disabled
in my case removing the pclmulqdq.odin file the error output is only
error: <unknown>:0:0: in function __gnu_h2f_ieee float (i16): SSE register return with SSE disabled
Running into the same issue. Additional context:
LLVM Version: 14 (LLVM17 is not out on standard arch packages yet, can't test on newer LLVM versions)
$ lscpu (output trimmed)
Flags:
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat p
se36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdp
e1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xto
pology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds
_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x
2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lah
f_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tp
r_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2
smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts vnmi md_cl
ear flush_l1d
These are the things LLVM reports to us about our current CPU:
llvm cpu name: haswell
llvm features: -avx512pf,-tsxldtrk,+cx16,+sahf,-tbm,-avx512ifma,-sha,+crc32,-fma4,-vpclmulqdq,-prfchw,+bmi2,-cldemote,+fsgsbase,-ptwrite,-amx-tile,-uintr,-gfni,+popcnt,-widekl,+aes,-avx512bitalg,-movdiri,-xsaves,-avx512er,-avxvnni,-avx512fp16,-avx512vnni,-amx-bf16,-avx512vpopcntdq,-pconfig,-clwb,-avx512f,-xsavec,-clzero,-pku,+mmx,-lwp,-rdpid,-xop,-rdseed,-waitpkg,-kl,-movdir64b,-sse4a,-avx512bw,-clflushopt,+xsave,-avx512vbmi2,+64bit,-avx512vl,-serialize,-hreset,+invpcid,-avx512cd,+avx,-vaes,-avx512bf16,+cx8,+fma,-rtm,+bmi,-enqcmd,+rdrnd,-mwaitx,+sse4.1,+sse4.2,+avx2,+fxsr,-wbnoinvd,+sse,+lzcnt,+pclmul,-prefetchwt1,+f16c,+ssse3,-sgx,-shstk,+cmov,-avx512vbmi,-amx-int8,+movbe,-avx512vp2intersect,+xsaveopt,-avx512dq,+sse2,-adx,+sse3
Also to note the last part of the error message is tiny bit different, now it says the error is in internal.odin:
error: internal.odin:881:2: in function __gnu_h2f_ieee float (i16): SSE register return with SSE disabled
There's two issues here:
'pclmulqdq' is not a recognized feature for this target (ignoring feature): Wrong target feature is being enabled (LLVM wantspclmul)error: <unknown>:0:0: in function __gnu_h2f_ieee float (i16): SSE register return with SSE disabled: Ah, thellvm_featuresget trampled if theenable_target_featureattribute is used.
Judging from you sending llvm17 binaries to me yesterday I assume this problem still occurs on llvm17?
Judging from you sending llvm17 binaries to me yesterday I assume this problem still occurs on llvm17?
Indeed, because the enable_target_feature attribute ends up mis-configuring LLVM. My branch fixes it in the "compiles no longer fail the moment the package is imported" sense, but I haven't had time to take the actual intrinsics for a test drive.