[SERVER-67681] Create specific target for compile commands Created: 29/Jun/22  Updated: 29/Oct/23  Resolved: 28/Oct/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.1, 5.0.14, 6.0.3, 6.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Juan Gu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File error-vim.png     PNG File image-2022-10-14-15-19-11-217.png     PNG File image-2022-10-24-18-30-49-165.png     PNG File warning-vim.png    
Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.1, v6.0, v5.0
Participants:

 Description   

Can we get a target specifically for generating compile_commands.json? I always recommend having a dedicated config for it anyway. In particular, it should use clang, not use icecc or ccache, enable flags that maximize enabled code to improve find-references (especially --dbg=on but there are a few others), and --disable-warnings-as-errors (this plays nicer with its usage inside of IDEs/editors).



 Comments   
Comment by Githook User [ 28/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands

(cherry picked from commit 5678e6188e7d3a6401b4bdc6aa3b46db949f2235)
(cherry picked from commit 3a31638a3c0bc80fe03faf0bafba5aefaefc2b84)
Branch: v5.0
https://github.com/mongodb/mongo/commit/3962df8de03706b5bd55a4343bdc6d827756a1a1

Comment by Githook User [ 28/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands

(cherry picked from commit 3a31638a3c0bc80fe03faf0bafba5aefaefc2b84)
Branch: v6.0
https://github.com/mongodb/mongo/commit/ea921842b91b81bce3508c131576ac3d6a9d111f

Comment by Githook User [ 28/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands

(cherry picked from commit 5678e6188e7d3a6401b4bdc6aa3b46db949f2235)
Branch: v6.0
https://github.com/mongodb/mongo/commit/740e0237131f2f599cb58a7e4c24db085b5c5fca

Comment by Githook User [ 27/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands

(cherry picked from commit 3a31638a3c0bc80fe03faf0bafba5aefaefc2b84)
Branch: v6.1
https://github.com/mongodb/mongo/commit/9775ef6d331f7855820450e23ecbb03c319431e3

Comment by Githook User [ 27/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands

(cherry picked from commit 5678e6188e7d3a6401b4bdc6aa3b46db949f2235)
Branch: v6.1
https://github.com/mongodb/mongo/commit/33a8f0450dc85f19c8d4921a889b8b0e8fa96864

Comment by Githook User [ 27/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands
Branch: master
https://github.com/mongodb/mongo/commit/3a31638a3c0bc80fe03faf0bafba5aefaefc2b84

Comment by Githook User [ 25/Oct/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-67681 Create specific target for compile commands
Branch: master
https://github.com/mongodb/mongo/commit/5678e6188e7d3a6401b4bdc6aa3b46db949f2235

Comment by Mathias Stearn [ 24/Oct/22 ]

I'm using nvim + coc + clangd rather than vscode. At least with my setup, warnings get yellow rather than red squiggles. I thought vscode does something similar, but I'm not sure. And in the past, I've found that clang tends to "give up" once it sees errors, but doesn't for warnings. So it is nice when editing if transient warnings like unused vars (eg, because I haven't yet written the code that will consume it) don't mask actual errors in the code I'm currently typing.


Have you verified that the compile_commands.json file doesn't have any -Werror flags in it? If your are seeing red squiggles, it might be worth double checking.

Note that I've recently added the following to my ~/.config/clangd/config.yaml, so it isn't an issue for me personally anymore, but I think we should try to give a nicer OOTB experience for people who don't know to do this:

CompileFlags:
  Add:
    - -Wno-error

Edit: I forgot that I made unused warnings specifically give grey squiggles because they can be very noisy sometimes, in particular in some other languages and codebases. But other warnings do have yellow squiggles. 

Comment by Juan Gu [ 14/Oct/22 ]

I am doing tests with --disable-warnings-as-errors = configure/source/None, All of three different options give me red squiggles and messages from VSCode like the screen capture below.

Could you share more details on how does --disable-warnings-as-errors plays nicer inside IDEs/editors

Generated at Thu Feb 08 06:08:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.