Skip to content

Commit 3043f5e

Browse files
authored
[Build] Symlink compile_commands.json to root dir (#7305)
Symlink the `compile_commands.json` file from the build directory to the root repository directory. So we no longer need to elaborate in the README on where to find it. Everything just works out of the box for VSCode IntelliSense and Clangd.
1 parent e9671cd commit 3043f5e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,17 @@ Alternatively, follow these steps to build LLVM from source manually.
119119
Without this, every invocation of `pip install` uses a different symlink to
120120
cmake, and this forces ninja to rebuild most of the `.a` files.
121121

122-
- vscode intellisense has some difficulty figuring out how to build Triton's C++
123-
(probably because, in our build, users don't invoke cmake directly, but
124-
instead use setup.py). Teach vscode how to compile Triton as follows.
122+
- The build system creates a `compile_commands.json` file under the Triton repo
123+
directory. This file is used by VSCode IntelliSense and clangd to provide
124+
code completion and other features for C++ code.
125+
126+
If IntelliSense does not work, you can try the following steps:
125127

126128
- Do a local build. Run command `pip install -e .`
127129
- Get the full path to the `compile_commands.json` file produced by the build:
128130
`find ./build -name 'compile_commands.json' | xargs readlink -f`.
129131
You might get a full path similar to `/Users/{username}/triton/build/cmake.macosx-11.1-arm64-cpython-3.12/compile_commands.json`
130-
- In vscode, install the
132+
- In VSCode, install the
131133
[C/C++
132134
extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools),
133135
then open the command palette (`Shift + Command + P` on Mac, or `Shift +

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ def build_extension(self, ext):
525525
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=cmake_dir)
526526
subprocess.check_call(["cmake", "--build", ".", "--target", "mlir-doc"], cwd=cmake_dir)
527527

528+
update_symlink(Path(self.base_dir) / "compile_commands.json", cmake_dir / "compile_commands.json")
529+
528530

529531
def download_and_copy_dependencies():
530532
nvidia_version_path = os.path.join(get_base_dir(), "cmake", "nvidia-toolchain-version.json")

0 commit comments

Comments
 (0)