Skip to content

Commit

Permalink
rust: Proper bindgen sources for BTF debug builds
Browse files Browse the repository at this point in the history
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 <yakoyoku@gmail.com>
  • Loading branch information
YakoYakoYokuYoku committed Jul 23, 2022
1 parent 856eb0e commit f6bb7cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/linux/compiler_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef __ASSEMBLY__

#if defined(CONFIG_DEBUG_INFO_BTF) && defined(CONFIG_PAHOLE_HAS_BTF_TAG) && \
__has_attribute(btf_type_tag)
__has_attribute(btf_type_tag) && !defined(__BINDGEN__)
# define BTF_TYPE_TAG(value) __attribute__((btf_type_tag(#value)))
#else
# define BTF_TYPE_TAG(value) /* nothing */
Expand Down
2 changes: 1 addition & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ else
bindgen_c_flags_lto = $(bindgen_c_flags)
endif

bindgen_c_flags_final = $(bindgen_c_flags_lto)
bindgen_c_flags_final = $(bindgen_c_flags_lto) -D__BINDGEN__

quiet_cmd_bindgen = BINDGEN $@
cmd_bindgen = \
Expand Down

0 comments on commit f6bb7cb

Please sign in to comment.