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

Stefan Bader stefan.bader at canonical.com
Fri Aug 15 09:40:50 UTC 2025


On 14.08.25 10:00, Mehmet Basaran wrote:
> 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 74927753e04d..64e6f1bd88d1 100644
> --- a/debian/rules.d/2-binary-arch.mk
> +++ b/debian/rules.d/2-binary-arch.mk
> @@ -463,6 +463,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

Just two little things I am wondering about:

- This is just a single file, does that have to be a tar archive? Or 
could it be just a gzip?

- Would deleting the file not be better in a clean: section? Then it 
would be possible to grab it after compilation if one does so locally...

> +
>   ifeq ($(do_lib_rust),true)
>   	# Generate Rust lib files
>   	install -d -m755 $(rustdir)
> @@ -759,4 +765,3 @@ endif
>   .PHONY: binary-arch
>   binary-arch: $(binary-arch-deps-true)
>   	@echo Debug: $@
> -
> --
> 2.43.0
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xE8675DEECBEECEA3.asc
Type: application/pgp-keys
Size: 48643 bytes
Desc: OpenPGP public key
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20250815/395a6107/attachment-0001.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20250815/395a6107/attachment-0001.sig>


More information about the kernel-team mailing list