Kbuild fixes for v6.16

- Move warnings about linux/export.h from W=1 to W=2
 
  - Fix structure type overrides in gendwarfksyms
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmhO6/MVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsGoXMP/iVDFmVDE3qlMMmZQh+UBnfrkQ4j
 rhHMlCqUDcUWV26CgR5u7lRDIKK9sIIZq9a0EqZjabspQAMz5C/cxbICGu7r9Iji
 DLKJJ8g8nv3qORsDXBKcj5Ijz5QzyBoOJ5FtoS/RUQjMcl6+XeFFWcJSVF9WCM+S
 YuKP2/ILM9L77/2bLMM+3PLgp1FMWgiHql1QlQAHdv0ZiteGmdbwfbCdnfrx6TJc
 JTICUfrn9Me/nlJ2HAKJ+ExHEl0qQwNOGKDd2wwOcgMkCRCfK6bMjh0B2A1Elgpm
 BaDZVIHpjW6nH4Y14eC9b+Hj7aFSCfPxnmqcHNMM0965KuZhBnvJAXUooy2k57Eh
 TND8jyOSzX1zzHrxDZiFsmiPWmbv3KqSQomBy+Lt5Y3pf4ittdZOCCgLph2rHPtm
 xP7fWxxZ2i10KzZCHT5y/FevoZqozD4U4i+CwgSEAolPi7jmyrdgDfBIq/eM+EwG
 xFFbnJ6GDcNqrVGq8DMGZZcQzOFhFebibkh7d9QbW30FKg1vsUU7oQfKSYBwHi7i
 J5tOANXiL5AfDLgWQC7ugKSqAOBKxrYikguPZiY8cJsxYsphc+FFLm2N+O1x+ruV
 JOwT1qnF+KjCeJ0Ew969naEQ5lnFXgz6uyNGTIiI8bKhofHe0PgswAf3TnUmuGYP
 gl5dYNZzdX9Pdn5o
 =iO3g
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-fixes-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Move warnings about linux/export.h from W=1 to W=2

 - Fix structure type overrides in gendwarfksyms

* tag 'kbuild-fixes-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  gendwarfksyms: Fix structure type overrides
  kbuild: move warnings about linux/export.h from W=1 to W=2
This commit is contained in:
Linus Torvalds 2025-06-15 09:14:27 -07:00
commit 08215f5486
4 changed files with 33 additions and 64 deletions

View File

@ -1832,12 +1832,9 @@ rustfmtcheck: rustfmt
# Misc
# ---------------------------------------------------------------------------
# Run misc checks when ${KBUILD_EXTRA_WARN} contains 1
PHONY += misc-check
ifneq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
misc-check:
$(Q)$(srctree)/scripts/misc-check
endif
all: misc-check

View File

@ -216,24 +216,14 @@ int cache_get(struct cache *cache, unsigned long key);
void cache_init(struct cache *cache);
void cache_free(struct cache *cache);
static inline void __cache_mark_expanded(struct cache *cache, uintptr_t addr)
{
cache_set(cache, addr, 1);
}
static inline bool __cache_was_expanded(struct cache *cache, uintptr_t addr)
{
return cache_get(cache, addr) == 1;
}
static inline void cache_mark_expanded(struct cache *cache, void *addr)
{
__cache_mark_expanded(cache, (uintptr_t)addr);
cache_set(cache, (unsigned long)addr, 1);
}
static inline bool cache_was_expanded(struct cache *cache, void *addr)
{
return __cache_was_expanded(cache, (uintptr_t)addr);
return cache_get(cache, (unsigned long)addr) == 1;
}
/*

View File

@ -333,37 +333,11 @@ static void calculate_version(struct version *version,
cache_free(&expansion_cache);
}
static void __type_expand(struct die *cache, struct type_expansion *type,
bool recursive);
static void type_expand_child(struct die *cache, struct type_expansion *type,
bool recursive)
{
struct type_expansion child;
char *name;
name = get_type_name(cache);
if (!name) {
__type_expand(cache, type, recursive);
return;
}
if (recursive && !__cache_was_expanded(&expansion_cache, cache->addr)) {
__cache_mark_expanded(&expansion_cache, cache->addr);
type_expansion_init(&child);
__type_expand(cache, &child, true);
type_map_add(name, &child);
type_expansion_free(&child);
}
type_expansion_append(type, name, name);
}
static void __type_expand(struct die *cache, struct type_expansion *type,
bool recursive)
static void __type_expand(struct die *cache, struct type_expansion *type)
{
struct die_fragment *df;
struct die *child;
char *name;
list_for_each_entry(df, &cache->fragments, list) {
switch (df->type) {
@ -379,7 +353,12 @@ static void __type_expand(struct die *cache, struct type_expansion *type,
error("unknown child: %" PRIxPTR,
df->data.addr);
type_expand_child(child, type, recursive);
name = get_type_name(child);
if (name)
type_expansion_append(type, name, name);
else
__type_expand(child, type);
break;
case FRAGMENT_LINEBREAK:
/*
@ -397,12 +376,17 @@ static void __type_expand(struct die *cache, struct type_expansion *type,
}
}
static void type_expand(struct die *cache, struct type_expansion *type,
bool recursive)
static void type_expand(const char *name, struct die *cache,
struct type_expansion *type)
{
const char *override;
type_expansion_init(type);
__type_expand(cache, type, recursive);
cache_free(&expansion_cache);
if (stable && kabi_get_type_string(name, &override))
type_parse(name, override, type);
else
__type_expand(cache, type);
}
static void type_parse(const char *name, const char *str,
@ -416,8 +400,6 @@ static void type_parse(const char *name, const char *str,
if (!*str)
error("empty type string override for '%s'", name);
type_expansion_init(type);
for (pos = 0; str[pos]; ++pos) {
bool empty;
char marker = ' ';
@ -478,7 +460,6 @@ static void type_parse(const char *name, const char *str,
static void expand_type(struct die *cache, void *arg)
{
struct type_expansion type;
const char *override;
char *name;
if (cache->mapped)
@ -504,11 +485,7 @@ static void expand_type(struct die *cache, void *arg)
debug("%s", name);
if (stable && kabi_get_type_string(name, &override))
type_parse(name, override, &type);
else
type_expand(cache, &type, true);
type_expand(name, cache, &type);
type_map_add(name, &type);
type_expansion_free(&type);
free(name);
@ -518,7 +495,6 @@ static void expand_symbol(struct symbol *sym, void *arg)
{
struct type_expansion type;
struct version version;
const char *override;
struct die *cache;
/*
@ -532,10 +508,7 @@ static void expand_symbol(struct symbol *sym, void *arg)
if (__die_map_get(sym->die_addr, DIE_SYMBOL, &cache))
return; /* We'll warn about missing CRCs later. */
if (stable && kabi_get_type_string(sym->name, &override))
type_parse(sym->name, override, &type);
else
type_expand(cache, &type, false);
type_expand(sym->name, cache, &type);
/* If the symbol already has a version, don't calculate it again. */
if (sym->state != SYMBOL_PROCESSED) {

View File

@ -62,6 +62,15 @@ check_unnecessary_include_linux_export_h () {
xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2
}
check_tracked_ignored_files
check_missing_include_linux_export_h
check_unnecessary_include_linux_export_h
case "${KBUILD_EXTRA_WARN}" in
*1*)
check_tracked_ignored_files
;;
esac
case "${KBUILD_EXTRA_WARN}" in
*2*)
check_missing_include_linux_export_h
check_unnecessary_include_linux_export_h
;;
esac