Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to generate compile_commands.json using bear #4463

Merged
merged 9 commits into from
Sep 8, 2023

Conversation

kamilrakoczy
Copy link
Contributor

Pre-PR to: #4228

This PR adds support for compile_commands.json to clang_check_attributes as well as automatically generates compile_commands.json using bear (if found).

src/Makefile.in Outdated
$(MAKE) -C obj_opt -j 1 TGT=../$@ -f ../Makefile_obj serial
$(MAKE) -C obj_opt TGT=../$@ -f ../Makefile_obj
$(RM_OBJ_OPT_COMPILE_COMMANDS)
$(BEAR_OBJ_OPT) $(MAKE) -C obj_opt -j 1 TGT=../$@ -f ../Makefile_obj serial
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if the submakes do nothing, does this break? #4228 (comment)

I'm not sure what you meant by this. Could you please elaborate?

If you meant that there will be wrong compile_commands.json file when bear will ran on already built target, I've fixed this case. We didn't need to remove compile_commands.json file before generating it again, as we pass --append flag to bear.

Copy link
Member

@wsnyder wsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, seems reasonable. Please make sure "lint-py" is clean (if you didn't already), and update docs/install.rst to mention installing bear for developers.

@wsnyder
Copy link
Member

wsnyder commented Sep 8, 2023

Also please merge in master to cleanup the test failure - sorry about that instability.

@gezalore
Copy link
Member

gezalore commented Sep 8, 2023

I'm curious why we use the opt build for the compile_commands.json? Generally the dbg build has "more stuff" in it, like assertions and debug checks, which are compiled out of the opt build. I have been using the commands from the dbg build for IDE use for a long time as it has the right defines for working on debug code as well.

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
@kamilrakoczy
Copy link
Contributor Author

Thanks, seems reasonable. Please make sure "lint-py" is clean (if you didn't already), and update docs/install.rst to mention installing bear for developers.

I've checked "lint-py" and it is clean. I've also added bear to install.rst.

I'm curious why we use the opt build for the compile_commands.json? Generally the dbg build has "more stuff" in it, like assertions and debug checks, which are compiled out of the opt build. I have been using the commands from the dbg build for IDE use for a long time as it has the right defines for working on debug code as well.

For our usage opt build had all necessary defines, but dbg have them too.
You are right that compile_commands.json from dbg build can be more useful for IDE/development, so I've moved generation of compile_commands.json to dbg.

@wsnyder wsnyder merged commit 6e977e1 into verilator:master Sep 8, 2023
40 checks passed
@kamilrakoczy kamilrakoczy deleted the kr/compile-commands branch September 15, 2023 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants