Skip to content

Commit 50ab9a6

Browse files
Villemoesmichal42
authored andcommitted
kbuild: include core debug info when DEBUG_INFO_REDUCED
With CONFIG_DEBUG_INFO_REDUCED, we do get quite a lot of debug info (around 22.7 MB for a defconfig+DEBUG_INFO_REDUCED). However, the "basenames must match" rule used by -femit-struct-debug-baseonly option means that we miss some core data structures, such as struct {device, file, inode, mm_struct, page} etc. We can easily get these included as well, while still getting the benefits of CONFIG_DEBUG_INFO_REDUCED (faster build times and smaller individual object files): All it takes is a dummy translation unit including a few strategic headers and compiled with a flag overriding -femit-struct-debug-baseonly. This increases the size of .debug_info by ~0.3%, but these 90 KB contain some rather useful info. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent cc84753 commit 50ab9a6

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎lib/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ CFLAGS_kobject.o += -DDEBUG
4545
CFLAGS_kobject_uevent.o += -DDEBUG
4646
endif
4747

48+
obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o
49+
CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any)
50+
4851
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
4952
obj-$(CONFIG_GENERIC_PCI_IOMAP) += pci_iomap.o
5053
obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o

‎lib/debug_info.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* This file exists solely to ensure debug information for some core
3+
* data structures is included in the final image even for
4+
* CONFIG_DEBUG_INFO_REDUCED. Please do not add actual code. However,
5+
* adding appropriate #includes is fine.
6+
*/
7+
#include <stdarg.h>
8+
9+
#include <linux/cred.h>
10+
#include <linux/crypto.h>
11+
#include <linux/dcache.h>
12+
#include <linux/device.h>
13+
#include <linux/fs.h>
14+
#include <linux/fscache-cache.h>
15+
#include <linux/io.h>
16+
#include <linux/kallsyms.h>
17+
#include <linux/kernel.h>
18+
#include <linux/kobject.h>
19+
#include <linux/mm.h>
20+
#include <linux/module.h>
21+
#include <linux/net.h>
22+
#include <linux/sched.h>
23+
#include <linux/slab.h>
24+
#include <linux/types.h>
25+
#include <net/addrconf.h>
26+
#include <net/sock.h>
27+
#include <net/tcp.h>

0 commit comments

Comments
 (0)