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

Mehmet Basaran mehmet.basaran at canonical.com
Thu Aug 14 08:01:02 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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 41985338064a..b5c3d845753c 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -497,6 +497,12 @@ endif
 	# Strip .so files (e.g., rust/libmacros.so) to reduce size even more
 	find $(hdrdir) -name libmacros.so -exec strip -s {} \;

+	# 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
+
 ifeq ($(do_lib_rust),true)
 	# Generate Rust lib files
 	install -d -m755 $(rustdir)
@@ -800,4 +806,3 @@ endif
 .PHONY: binary-arch
 binary-arch: $(binary-arch-deps-true)
 	@echo Debug: $@
-
--
2.43.0



More information about the kernel-team mailing list