linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* selftests: hid: trouble building with clang due to missing header
@ 2023-08-22 20:33 Justin Stitt
  2023-08-22 20:44 ` Nick Desaulniers
  0 siblings, 1 reply; 14+ messages in thread
From: Justin Stitt @ 2023-08-22 20:33 UTC (permalink / raw)
  To: linux-kselftest
  Cc: bpf, linux-input, Linux Kernel Mailing List, Nathan Chancellor,
	Nick Desaulniers, Kees Cook

Hi, I'd like to get some help with building the kselftest target.

I am running into some warnings within the hid tree:
| progs/hid_bpf_helpers.h:9:38: error: declaration of 'struct
hid_bpf_ctx' will \
|       not be visible outside of this function [-Werror,-Wvisibility]
|     9 | extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx,
|       |                                      ^
| progs/hid.c:23:35: error: incompatible pointer types passing 'struct
hid_bpf_ctx *' \
|       to parameter of type 'struct hid_bpf_ctx *'
[-Werror,-Wincompatible-pointer-types]
|    23 |         __u8 *rw_data = hid_bpf_get_data(hid_ctx, 0 /*
offset */, 3 /* size */);

This warning, amongst others, is due to some symbol not being included.
In this case, `struct hid_bpf_ctx` is not being defined anywhere that I
can see inside of the testing tree itself.

Instead, `struct hid_bpf_ctx` is defined and implemented at
`include/linux/hid_bpf.h`. AFAIK, I cannot just include this header as
the tools directory is a separate entity from kbuild and these tests are
meant to be built/ran without relying on kernel headers. Am I correct in
this assumption? At any rate, the include itself doesn't work. How can I
properly include this struct definition and fix the warning(s)?

Please note that we cannot just forward declare the struct as it is
being dereferenced and would then yield a completely different
error/warning for an incomplete type. We need the entire implementation
for the struct included.

Other symbols also defined in `include/linux/hid_bpf.h` that we need are
`struct hid_report_type` and `HID_BPF_FLAG...`

Here's the invocation I am running to build kselftest:
`$ make LLVM=1 ARCH=x86_64 mrproper headers && make LLVM=1 ARCH=x86_64
-j128 V=1 -C tools/testing/selftests`

If anyone is currently getting clean builds of kselftest with clang,
what invocation works for you?



Link: https://github.com/ClangBuiltLinux/linux/issues/1698
Full-build-log:
https://gist.github.com/JustinStitt/b217f6e47c1d762e5e1cc6c3532f1bbb
(V=1)

Thanks.
Justin

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-08-25 18:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 20:33 selftests: hid: trouble building with clang due to missing header Justin Stitt
2023-08-22 20:44 ` Nick Desaulniers
2023-08-22 20:51   ` Benjamin Tissoires
2023-08-22 20:57     ` Justin Stitt
2023-08-22 21:06       ` Benjamin Tissoires
2023-08-22 21:14         ` Benjamin Tissoires
2023-08-22 21:26           ` Justin Stitt
2023-08-22 21:36             ` Benjamin Tissoires
2023-08-22 21:38               ` Justin Stitt
2023-08-22 21:42                 ` Justin Stitt
2023-08-25  8:08                   ` Benjamin Tissoires
2023-08-25 13:01                     ` Eduard Zingerman
2023-08-25 18:36                       ` Justin Stitt
2023-08-25 18:46                         ` Eduard Zingerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).