]> git.proxmox.com Git - zfsonlinux.git/blame - zfs-patches/0005-Implement-enable-debuginfo-to-force-debuginfo.patch
update ZFS submodule to debian/0.7.9-2
[zfsonlinux.git] / zfs-patches / 0005-Implement-enable-debuginfo-to-force-debuginfo.patch
CommitLineData
75b07eca
FG
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Richard Yao <richard.yao@clusterhq.com>
3Date: Tue, 23 Sep 2014 14:29:30 -0400
4Subject: [PATCH] Implement --enable-debuginfo to force debuginfo
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Inspection of a Ubuntu 14.04 x64 system revealed that the config file
10used to build the kernel image differs from the config file used to
11build kernel modules by the presence of CONFIG_DEBUG_INFO=y:
12
13This in itself is insufficient to show that the kernel is built with
14debuginfo, but a cursory analysis of the debuginfo provided and the
15size of the kernel strongly suggests that it was built with
16CONFIG_DEBUG_INFO=y while the modules were not. Installing
17linux-image-$(uname -r)-dbgsym had no obvious effect on the debuginfo
18provided by either the modules or the kernel.
19
20The consequence is that issue reports from distributions such as Ubuntu
21and its derivatives build kernel modules without debuginfo contain
22nonsensical backtraces. It is therefore desireable to force generation
23of debuginfo, so we implement --enable-debuginfo. Since the build system
24can build both userspace components and kernel modules, the generic
25--enable-debuginfo option will force debuginfo for both. However, it
26also supports --enable-debuginfo=kernel and --enable-debuginfo=user for
27finer grained control.
28
29Enabling debuginfo for the kernel modules works by injecting
30CONFIG_DEBUG_INFO=y into the make environment. This is enables
31generation of debuginfo by the kernel build systems on all Linux
32kernels, but the build environment is slightly different int hat
33CONFIG_DEBUG_INFO has not been in the CPP. Adding -DCONFIG_DEBUG_INFO
34would fix that, but it would also cause build failures on kernels where
35CONFIG_DEBUG_INFO=y is already set. That would complicate its use in
36DKMS environments that support a range of kernels and is therefore
37undesireable. We could write a compatibility shim to enable
38CONFIG_DEBUG_INFO only when it is explicitly disabled, but we forgo
39doing that because it is unnecessary. Nothing in ZoL or the kernel uses
40CONFIG_DEBUG_INFO in the CPP at this time and that is unlikely to
41change.
42
43Enabling debuginfo for the userspace components is done by injecting -g
44into CPPFLAGS. This is not necessary because the build system honors the
45environment's CPPFLAGS by appending them to the actual CPPFLAGS used,
46but it is supported for consistency.
47
48Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
49Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
50Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
51Closes #2734
52(cherry picked from commit 834815e9f767c9c5e7220ff84f29b1f069822a4d)
53Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
54---
55 configure.ac | 1 +
56 config/zfs-build.m4 | 33 ++++++++++++++++++++++++++++++++-
57 2 files changed, 33 insertions(+), 1 deletion(-)
58
59diff --git a/configure.ac b/configure.ac
60index 0c7977ef8..e145aa370 100644
61--- a/configure.ac
62+++ b/configure.ac
63@@ -55,6 +55,7 @@ ZFS_AC_LICENSE
64 ZFS_AC_PACKAGE
65 ZFS_AC_CONFIG
66 ZFS_AC_DEBUG
67+ZFS_AC_DEBUGINFO
68
69 AC_CONFIG_FILES([
70 Makefile
71diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
72index 78a87aef7..a8609b829 100644
73--- a/config/zfs-build.m4
74+++ b/config/zfs-build.m4
75@@ -38,12 +38,43 @@ AC_DEFUN([ZFS_AC_DEBUG], [
76 [ZFS_AC_DEBUG_DISABLE],
77 [AC_MSG_ERROR([Unknown option $enable_debug])])
78
79- AC_SUBST(DEBUG_CFLAGS)
80 AC_SUBST(DEBUG_STACKFLAGS)
81 AC_SUBST(DEBUG_ZFS)
82 AC_MSG_RESULT([$enable_debug])
83 ])
84
85+AC_DEFUN([ZFS_AC_DEBUGINFO_KERNEL], [
86+ KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS CONFIG_DEBUG_INFO=y"
87+])
88+
89+AC_DEFUN([ZFS_AC_DEBUGINFO_USER], [
90+ DEBUG_CFLAGS="$DEBUG_CFLAGS -g"
91+])
92+
93+AC_DEFUN([ZFS_AC_DEBUGINFO], [
94+ AC_MSG_CHECKING([whether debuginfo support will be forced])
95+ AC_ARG_ENABLE([debuginfo],
96+ [AS_HELP_STRING([--enable-debuginfo],
97+ [Force generation of debuginfo @<:@default=no@:>@])],
98+ [],
99+ [enable_debuginfo=no])
100+
101+ AS_CASE(["x$enable_debuginfo"],
102+ ["xyes"],
103+ [ZFS_AC_DEBUGINFO_KERNEL
104+ ZFS_AC_DEBUGINFO_USER],
105+ ["xkernel"],
106+ [ZFS_AC_DEBUGINFO_KERNEL],
107+ ["xuser"],
108+ [ZFS_AC_DEBUGINFO_USER],
109+ ["xno"],
110+ [],
111+ [AC_MSG_ERROR([Unknown option $enable_debug])])
112+
113+ AC_SUBST(DEBUG_CFLAGS)
114+ AC_MSG_RESULT([$enable_debuginfo])
115+])
116+
117 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
118 ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE
119 ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE
120--
1212.14.2
122