<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15147</bug_id>
          
          <creation_ts>2023-06-20 08:36:38 +0000</creation_ts>
          <short_desc>Feature request: Make devtool create compile_commands.json files for clangd</short_desc>
          <delta_ts>2026-08-12 19:12:06 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>5.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jan Claussen">jan.claussen10</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>adrian.freihofer</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>95749</commentid>
    <comment_count>0</comment_count>
    <who name="Jan Claussen">jan.claussen10</who>
    <bug_when>2023-06-20 08:36:38 +0000</bug_when>
    <thetext>This feature would be great for developers that rely on clangd or use Vim as their main development environment. Usually after running make you can create a compile_commands.json file using bear or compiledb

https://github.com/rizsotto/Bear
https://github.com/nickdiego/compiledb

The kernel also provides its own script for this

https://github.com/torvalds/linux/blob/master/scripts/clang-tools/gen_compile_commands.py

and CMake supports it as well

https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html

The problem is that in order to get these commands, the code have been fully built, so the location of all libraries are known. It is easy to do this manually for small applications. Just check out the workspace with devtool, source the toolchain, compile and generate the compile_commands.json. For more complex programs like the kernel, which can need defconfig and .scc files etc. from the meta-layer, this can get quite complex. 

So it would be nice if this could be automated by devtool somehow. Bitbake knows where all the libraries and config files are located and with its help the compile_commands.json could be generated and copied into the workspace.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95796</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-06-22 14:35:40 +0000</bug_when>
    <thetext>An interesting idea but rather specific to the tools involved. Nice to have but not urgent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95888</commentid>
    <comment_count>2</comment_count>
    <who name="Jan Claussen">jan.claussen10</who>
    <bug_when>2023-07-06 11:50:39 +0000</bug_when>
    <thetext>Sure, this has no priority. I would try implementing it myself if you could give me some ideas where to start off. I tried playing around with the make command in the do_compile.log, but did not have any success. 

I think it would also be good to do this with an installed SDK and use its headers, because afaik otherwise the workdirs are being cleaned up after a package is successfully built and with it all the header files, aren&apos;t they?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96803</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-10-24 14:24:21 +0000</bug_when>
    <thetext>Bulk move from 4.99 or 0.00 to 5.99</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106505</commentid>
    <comment_count>4</comment_count>
    <who name="Adrian Freihofer">adrian.freihofer</who>
    <bug_when>2026-08-12 19:12:06 +0000</bug_when>
    <thetext>This is solved for some use cases. meson always did that by default. cmake does this as well since a few Yocto releases: https://git.openembedded.org/openembedded-core/tree/meta/classes-recipe/cmake.bbclass#n261.

This leads to the question if devtool is the best place for this feature. Probably not, because devtool should be needed to setup the SDK and then the build-tool should provide what ever is needed for the development workflow, just what meson and cmake do.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>