Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Implement --enable-debuginfo to permit us to force building with debuginfo #392

Closed
wants to merge 3 commits into from

Conversation

ryao
Copy link
Contributor

@ryao ryao commented Sep 23, 2014

There are two commits here. The second implements --enable-debuginfo for distributions that build modules without debuginfo. The first is a refactor of --enable-debug based on an observation made during the development of the first that --enable-debug=true would paradoxically become --disable-debug. The order is reversed to make cherry picking easier should anyone want to backport only the change to --enable-debug's argument semantics.

This is the SPL version of openzfs/zfs#2734.

Currently, bogus options to --enable-debug become --disable-debug. That
means that passing --enable-debug=true is analogous to --disable-debug,
but the result is counterintuitive. We switch to AS_CASE to allow us to
fail when given a bogus option.

Also, we modify the text printed to clarify that --enable-debug enables
assertions.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Inspection of a Ubuntu 14.04 x64 system revealed that the config file
used to build the kernel image differs from the config file used to
build kernel modules by the presence of CONFIG_DEBUG_INFO=y:

root@zfs-dev:~# grep -E 'CONFIG_.*=' /boot/config-$(uname -r) | sort > /tmp/d1
root@zfs-dev:~# grep -E 'CONFIG_.*=' /usr/src/linux-headers-$(uname -r)/include/config/auto.conf | sort > /tmp/d2
root@zfs-dev:~# diff /tmp/d1 /tmp/d2
1017d1016
< CONFIG_DEBUG_INFO=y

This in itself is insufficient to show that the kernel is built with
debuginfo, but a cursory analysis of the debuginfo provided and the size
of the kernel strongly suggests that it was built with
CONFIG_DEBUG_INFO=y while the modules were not. Installing
linux-image-$(uname -r)-dbgsym had no obvious effect on the debuginfo
provided by either the modules or the kernel.

The consequence is that issue reports from distributions such as Ubuntu
and its derivatives build kernel modules without debuginfo contain
nonsensical backtraces. It is therefore desireable to force generation
of debuginfo, so we implement --enable-debuginfo. Since the build system
can build both userspace components and kernel modules, the generic
--enable-debuginfo option will force debuginfo for both. However, it
also supports --enable-debuginfo=kernel and --enable-debuginfo=user for
finer grained control.

Enabling debuginfo for the kernel modules works by injecting
CONFIG_DEBUG_INFO=y into the make environment. This is enables
generation of debuginfo by the kernel build systems on all Linux
kernels, but the build environment is slightly different int hat
CONFIG_DEBUG_INFO has not been in the CPP. Adding -DCONFIG_DEBUG_INFO
would fix that, but it would also cause build failures on kernels where
CONFIG_DEBUG_INFO=y is already set. That would complicate its use in
DKMS environments that support a range of kernels and is therefore
undesireable. We could write a compatibility shim to enable
CONFIG_DEBUG_INFO only when it is explicitly disabled, but we forgo
doing that because it is unnecessary. Nothing in ZoL or the kernel uses
CONFIG_DEBUG_INFO in the CPP at this time and that is unlikely to
change.

Enabling debuginfo for the userspace components is done by injecting -g
into CPPFLAGS. This is not necessary because the build system honors the
environment's CPPFLAGS by appending them to the actual CPPFLAGS used,
but it is supported for consistency.

Signed-off-by: Richard Yao <ryao@gentoo.org>
@behlendorf behlendorf added this to the 0.6.5 milestone Feb 5, 2015
@behlendorf
Copy link
Contributor

Closing as unnecessary until I hear otherwise.

@behlendorf behlendorf closed this Jun 18, 2015
@ryao
Copy link
Contributor Author

ryao commented Jul 14, 2017

@behlendorf I am using this at my new job now. It is definitely something useful.

@ryao ryao reopened this Jul 14, 2017
@behlendorf
Copy link
Contributor

Closing. Won't merge. The SPL is being moved in to the ZFS tree so this will no longer be needed. The counterpart ZFS patches have been applied to master.

@behlendorf behlendorf closed this Aug 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants