Skip to content

Commit

Permalink
PR openxla#8306: Add instructions to generate compile_commands.json
Browse files Browse the repository at this point in the history
Imported from GitHub PR openxla#8306

Copybara import of the project:

--
ef2ff97 by Andrey Portnoy <aportnoy@nvidia.com>:

Add instructions to generate compile_commands.json

--
21916c7 by Andrey Portnoy <aportnoy@nvidia.com>:

Remove defensive phrasing from LSP instructions

Merging this change closes openxla#8306

COPYBARA_INTEGRATE_REVIEW=openxla#8306 from andportnoy:aportnoy/compile-commands-documentation 21916c7
PiperOrigin-RevId: 598964502
  • Loading branch information
andportnoy authored and copybara-github committed Jan 16, 2024
1 parent ddf0296 commit e4fc329
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ then read [Code reviews](code_reviews.md).
- [Operation semantics](operation_semantics.md)
- [Shapes and layout](shapes.md)
- [Tiled layout](tiled_layout.md)
- [Setting up LSP with clangd](lsp.md)
20 changes: 20 additions & 0 deletions docs/lsp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Setting up LSP with clangd

## Background

Editors such as Emacs, Vim, or VS Code support features like code navigation,
code completion, inline compiler error messages, and others, through
[LSP](https://en.wikipedia.org/wiki/Language_Server_Protocol), the Language
Server Protocol. A common language server with LSP support is
[clangd](https://clangd.llvm.org), which relies on the presence of
`compile_commands.json`, a JSON file with a record of the compile commands for
each file in a project.

## How do I generate `compile_commands.json` for XLA source code?

Use the
[build_tools/lint/generate_compile_commands.py](https://github.com/openxla/xla/blob/main/build_tools/lint/generate_compile_commands.py)
script. The following invocation from XLA repo root generates a
`compile_commands.json` file in place: `bash bazel aquery "mnemonic(CppCompile,
//xla/...)" --output=jsonproto | \ python3
build_tools/lint/generate_compile_commands.py`

0 comments on commit e4fc329

Please sign in to comment.