[SRU][J][PATCH 0/1] UBUNTU: [Packaging] Generate compile_commands.json (LP: #2119438).

Mehmet Basaran mehmet.basaran at canonical.com
Thu Aug 14 07:59:29 UTC 2025


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

SRU Justification

[Impact]

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 [2] does
this but requires compilation commands [1] 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.

[Fix]

After compilation run scripts/clang-tools/gen_compile_commands.py and
package compile_commands.json into linux-buildinfo package.

[Test Case]

Build tested. Compile commands are compressed and  included in the
linux-buildinfo package [3].


$ dpkg --contents linux-buildinfo-6.14.0-24-generic_6.14.0-24.24_amd64.deb

drwxr-xr-x root/root         0 2025-08-01 18:14 ./
drwxr-xr-x root/root         0 2025-08-01 18:14 ./usr/
drwxr-xr-x root/root         0 2025-08-01 18:10 ./usr/lib/
drwxr-xr-x root/root         0 2025-08-01 18:10 ./usr/lib/linux/
drwxr-xr-x root/root         0 2025-08-01 18:11 ./usr/lib/linux/6.14.0-24-generic/
-rw-r--r-- root/root   2373194 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/abi
-rw-r--r-- root/root     21582 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/canonical-certs.pem
-rw-r--r-- root/root     38606 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/canonical-revoked-certs.pem
-rw-r--r-- root/root    889358 2025-08-01 18:11 ./usr/lib/linux/6.14.0-24-generic/compile_commands.tgz
-rw-r--r-- root/root        38 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/compiler
-rw-r--r-- root/root    296789 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/config
-rw-r--r-- root/root     96802 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/fwinfo
-rw-r--r-- root/root         0 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/fwinfo.builtin
-rw-r--r-- root/root     77077 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/modules
-rw-r--r-- root/root      3065 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/modules.builtin
-rw-r--r-- root/root   2131941 2025-08-01 18:10 ./usr/lib/linux/6.14.0-24-generic/sources
drwxr-xr-x root/root         0 2025-08-01 18:14 ./usr/share/
drwxr-xr-x root/root         0 2025-08-01 18:14 ./usr/share/doc/
drwxr-xr-x root/root         0 2025-08-01 18:14 ./usr/share/doc/linux-buildinfo-6.14.0-24-generic/
-rw-r--r-- root/root    317265 2025-08-01 18:14 ./usr/share/doc/linux-buildinfo-6.14.0-24-generic/changelog.Debian.gz
-rw-r--r-- root/root      1292 2025-08-01 17:08 ./usr/share/doc/linux-buildinfo-6.14.0-24-generic/copyright


[Where things could go wrong]

Package may fail to build. Otherwise, there are no runtime complications.

[Other Notes]

[1] https://clang.llvm.org/docs/JSONCompilationDatabase.html
[2] https://clangd.llvm.org/
[3] See the tracking bug for the newly generated linux-buildinfo packages.


Mehmet Basaran (1):
  UBUNTU: [Packaging] Add compilation commands database to build info.

 debian/rules.d/2-binary-arch.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--
2.43.0



More information about the kernel-team mailing list