Skip to content

Commit

Permalink
installation: add mechanism for symlinking mlir-opt when creating venv (
Browse files Browse the repository at this point in the history
#3660)

For the last couple of years, I've had a custom-built llvm bin folder in
my path. This has mostly been OK but sometimes resulted in weird build
errors. With this mechanism, we can have the best of both worlds, with
having a normal mlir-opt in the path except for when the venv is
activated:

```
~/Developer/xdslproject/xdsl sasha/misc/env *129 !1 ❯ which mlir-opt           
/opt/homebrew/opt/llvm/bin/mlir-opt
~/Developer/xdslproject/xdsl sasha/misc/env *129 ❯ uv run which mlir-opt  
/Users/sasha/Developer/xdslproject/xdsl/.venv/bin/mlir-opt
```
  • Loading branch information
superlopuh authored Dec 24, 2024
1 parent bec3c07 commit e84ebda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ uv-installed:
.PHONY: ${VENV_DIR}/
${VENV_DIR}/: uv-installed
XDSL_VERSION_OVERRIDE="0+dynamic" uv sync ${VENV_EXTRAS}
@if [ ! -z "$(XDSL_MLIR_OPT_PATH)" ]; then \
ln -sf $(XDSL_MLIR_OPT_PATH) ${VENV_DIR}/bin/mlir-opt; \
fi

# make sure `make venv` also works correctly
.PHONY: venv
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ cd xdsl
make venv
```

To make a custom mlir-opt available in the virtual environment, set the `XDSL_MLIR_OPT_PATH` variable when running `make venv`, like so:

``` bash
XDSL_MLIR_OPT_PATH=/PATH/TO/LLVM/BUILD/bin/mlir-opt make venv
```

#### If you can't use `uv`

For some systems and workflows, changing to a new dependency management system
Expand Down

0 comments on commit e84ebda

Please sign in to comment.