[SRU][J][PATCH 1/1] UBUNTU: [Packaging] Add compilation commands database to build info.

Mehmet Basaran mehmet.basaran at canonical.com
Thu Aug 14 08:01:13 UTC 2025


BugLink: https://bugs.launchpad.net/bugs/2119438

Other source code tagging utilities (such as gtags) index the whole
code base. However, in practice quite a bit of code base is disabled
(either through macro definitions or makefiles where some sources
are kept out of compilation).

When inspecting a crash on certain architecture, it would help a lot
to search thought only the active source code. Language servers does
this but requires compilation commands to parse the code exactly as
it was compiled. Linux has a script to generate compile_commands.json
but it is not used by our builds.

Users can build the sources themselves and generate this file. However,
this requires compilation first and it takes quite a bit of time. Since
we already compile the code, it takes at most a couple seconds more
to generate this file.

Signed-off-by: Mehmet Basaran <mehmet.basaran at canonical.com>
---
 debian/rules.d/2-binary-arch.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index ff6a26e91599..330fcd3fe8c4 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -380,7 +380,7 @@ endif
 	#
 	# Remove files which are generated at installation by postinst,
 	# except for modules.order and modules.builtin
-	# 
+	#
 	# NOTE: need to keep this list in sync with postrm
 	#
 	mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
@@ -550,6 +550,12 @@ endif
 	# List of source files used for this build
 	install -m644 $(builddir)/build-$*/sources.list $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/sources
 
+	# Export compilation commands for language servers
+	scripts/clang-tools/gen_compile_commands.py
+	tar -a -jcf compile_commands.tgz compile_commands.json
+	install -m644 compile_commands.tgz $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/compile_commands.tgz
+	rm compile_commands.tgz compile_commands.json
+
 ifneq ($(full_build),false)
 	# Clean out this flavours build directory.
 	rm -rf $(builddir)/build-$*
@@ -863,4 +869,3 @@ binary-arch-deps-$(do_flavour_header_package) += binary-headers
 endif
 binary-arch: $(binary-arch-deps-true)
 	@echo Debug: $@
-
-- 
2.43.0




More information about the kernel-team mailing list