]> git.proxmox.com Git - zfsonlinux.git/blob - zfs-patches/0005-Implement-enable-debuginfo-to-force-debuginfo.patch
bump ZFS version to 0.7.7-pve2~bpo9
[zfsonlinux.git] / zfs-patches / 0005-Implement-enable-debuginfo-to-force-debuginfo.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Richard Yao <richard.yao@clusterhq.com>
3 Date: Tue, 23 Sep 2014 14:29:30 -0400
4 Subject: [PATCH] Implement --enable-debuginfo to force debuginfo
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Inspection of a Ubuntu 14.04 x64 system revealed that the config file
10 used to build the kernel image differs from the config file used to
11 build kernel modules by the presence of CONFIG_DEBUG_INFO=y:
12
13 This in itself is insufficient to show that the kernel is built with
14 debuginfo, but a cursory analysis of the debuginfo provided and the
15 size of the kernel strongly suggests that it was built with
16 CONFIG_DEBUG_INFO=y while the modules were not. Installing
17 linux-image-$(uname -r)-dbgsym had no obvious effect on the debuginfo
18 provided by either the modules or the kernel.
19
20 The consequence is that issue reports from distributions such as Ubuntu
21 and its derivatives build kernel modules without debuginfo contain
22 nonsensical backtraces. It is therefore desireable to force generation
23 of debuginfo, so we implement --enable-debuginfo. Since the build system
24 can build both userspace components and kernel modules, the generic
25 --enable-debuginfo option will force debuginfo for both. However, it
26 also supports --enable-debuginfo=kernel and --enable-debuginfo=user for
27 finer grained control.
28
29 Enabling debuginfo for the kernel modules works by injecting
30 CONFIG_DEBUG_INFO=y into the make environment. This is enables
31 generation of debuginfo by the kernel build systems on all Linux
32 kernels, but the build environment is slightly different int hat
33 CONFIG_DEBUG_INFO has not been in the CPP. Adding -DCONFIG_DEBUG_INFO
34 would fix that, but it would also cause build failures on kernels where
35 CONFIG_DEBUG_INFO=y is already set. That would complicate its use in
36 DKMS environments that support a range of kernels and is therefore
37 undesireable. We could write a compatibility shim to enable
38 CONFIG_DEBUG_INFO only when it is explicitly disabled, but we forgo
39 doing that because it is unnecessary. Nothing in ZoL or the kernel uses
40 CONFIG_DEBUG_INFO in the CPP at this time and that is unlikely to
41 change.
42
43 Enabling debuginfo for the userspace components is done by injecting -g
44 into CPPFLAGS. This is not necessary because the build system honors the
45 environment's CPPFLAGS by appending them to the actual CPPFLAGS used,
46 but it is supported for consistency.
47
48 Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
49 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
50 Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
51 Closes #2734
52 (cherry picked from commit 834815e9f767c9c5e7220ff84f29b1f069822a4d)
53 Signed-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
59 diff --git a/configure.ac b/configure.ac
60 index 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
71 diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
72 index 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 --
121 2.14.2
122