Skip to content

Commit f6bb7cb

Browse files
rust: Proper bindgen sources for BTF debug builds
As Clang 14 supports the btf_type_tag attribute and building with PAHOLE_HAS_BTF_TAG defines BTF_TYPE_TAG(value) to be __attribute__((btf_type_tag(#value))). Because of this bindgen might get confused and discards constness of attributed function parameters that are indeed const pointers (like const char __user * -> char *). This patch fixes that by passing a BINDGEN_RUN definition to bindgen that causes BTF_TYPE_TAG(value) to be defined as nothing, thus generating proper definitions for functions like write in the file_operations struct. Signed-off-by: Martin Rodriguez Reboredo <[email protected]>
1 parent 856eb0e commit f6bb7cb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/linux/compiler_types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef __ASSEMBLY__
66

77
#if defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
8-
__has_attribute(btf_type_tag)
8+
__has_attribute(btf_type_tag) && !defined(__BINDGEN__)
99
# define BTF_TYPE_TAG(value) __attribute__((btf_type_tag(#value)))
1010
#else
1111
# define BTF_TYPE_TAG(value) /* nothing */

rust/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ else
297297
bindgen_c_flags_lto = $(bindgen_c_flags)
298298
endif
299299

300-
bindgen_c_flags_final = $(bindgen_c_flags_lto)
300+
bindgen_c_flags_final = $(bindgen_c_flags_lto) -D__BINDGEN__
301301

302302
quiet_cmd_bindgen = BINDGEN $@
303303
cmd_bindgen = \

0 commit comments

Comments
 (0)