LLVM ERROR: Cannot select: intrinsic %llvm.bpf.load.byte

Dear Readers,

I am trying to compile kernel/samples/bpf/ module using clang-14 compiler and noticed below error during build phase of below bpf sample code.
{{
CLANG-bpf /kernel/…/kernel/linux-5.4/samples/bpf/tracex1_kern.o
CLANG-bpf /kernel/…/kernel/linux-5.4/samples/bpf/tracex2_kern.o
LLVM ERROR: Cannot select: intrinsic %llvm.bpf.load.byte
CLANG-bpf /kernel/…/kernel/linux-5.4/samples/bpf/tracex3_kern.o
CLANG-bpf /kernel/…/kernel/linux-5.4/samples/bpf/tracex4_kern.o

CLANG-bpf kernel/…/kernel/linux-5.4/samples/bpf/spintest_kern.o
Aborted (core dumped)
kernel/…/kernel/linux-5.4/samples/bpf/Makefile:289: recipe for target ‘/kernel/…/kernel/linux-5.4/samples/bpf/sockex1_kern.o’ failed
make[5]: *** [kernel/…/kernel/linux-5.4/samples/bpf/sockex1_kern.o] Error 134
make[5]: *** Waiting for unfinished jobs…
LLVM ERROR: Cannot select: intrinsic %llvm.bpf.load.byte
LLVM ERROR: Cannot select: intrinsic %llvm.bpf.load.half
LLVM ERROR: Cannot select: intrinsic %llvm.bpf.load.byte
Aborted (core dumped)
kernel/…/kernel/linux-5.4/samples/bpf/Makefile:289: recipe for target ’ …/kernel/linux-5.4/samples/bpf/tcbpf1_kern.o’ failed
make[5]: *** […/kernel/linux-5.4/samples/bpf/tcbpf1_kern.o] Error 134
Aborted (core dumped)

}}
can you please let me know how to get rid of this build error?
i am using clang-14.0.6/llvm-14.0.6 version compiler for building above kernel bpf samples/bpf modules code.

Regards
Koti

You are apparently not the first one:

Dear Tschuett,

Thank you for your reply. i had gone through above link before raising my query itself . As there is no fix proposed in above link and in fact , in the bugzilla, they tested on ‘bpf’ target , where as i am building for target 'x86_64 bit architecutre.

Regards
koti

That is maybe the issue : llvm.bpf.load.byte is probably for bpf and not Intel.

Dear tschuett

Understood . Can you let me know how to change it so that llvm selects intel specific x86_64 ?

Regards
Koti

Hi

Thank you for input. replaced bpf with x86 string and build is OK.

Regards
Koti