Hi Sam, Thank you for your suggestions! Regarding the bear tool, I am currently using version 3.1.3, which is the one provided with Ubuntu 24.04. I will proceed with trying to upgrade bear to a newer version as a next step. Separately, I've noticed something unexpected with the generated compilation database (the JSON file). It seems that files located within the GCC directory, such as fold-const-call.cc, are not included. This is curious because these specific files are not typically compiled directly by xgcc or xg++, yet one might expect them to be captured if they are part of the overall build process being tracked by bear. For now I only have less than 50 lines. Best regards, Yuao
________________________________ From: Sam James <s...@gentoo.org> Sent: Wednesday, May 14, 2025 10:32 To: Yuao Ma via Gcc <gcc@gcc.gnu.org> Cc: Yuao Ma <c...@outlook.com> Subject: Re: Generating compile_commands.json for GCC source code Yuao Ma via Gcc <gcc@gcc.gnu.org> writes: > Hello GCC developers, > I am trying to generate a compile_commands.json file for the GCC source code. > This file is very useful for various development tools and IDE integrations. > Since GCC uses a Makefile-based build system, I attempted to use bear > (https://github.com/rizsotto/Bear) to capture the compilation commands. My > workflow was as follows: What version of bear did you use? You'll need >=3.1.6 as that contains https://github.com/rizsotto/Bear/commit/c18c8eef1e74bd253302d57dbcf908394566d93b. > > ../configure --enable-languages=c,c++,fortran --disable-bootstrap > --disable-multilib > bear -- make -j$(nproc) > > > However, this approach did not produce the expected compile_commands.json > file with the correct compilation commands for the source files. Did you get one generated at all? If so, what was missing, or what was wrong with it?