@@ -32,20 +32,13 @@ Here's how to build the StableHLO repo on Linux or macOS:
3232
3333 ``` sh
3434 # On Linux
35- sudo apt install cmake ninja-build lld
35+ sudo apt install cmake ninja-build lld ccache
3636
3737 # On macOS
38- brew install cmake ninja
38+ brew install cmake ninja ccache
3939 ```
4040
41- 2 . Set the ` LLVM_ENABLE_LLD ` shell variable depending on your preferences. We
42- recommend setting it to ` ON ` on Linux and to ` OFF ` on macOS.
43-
44- ``` sh
45- [[ " $( uname) " != " Darwin" ]] && LLVM_ENABLE_LLD=" ON" || LLVM_ENABLE_LLD=" OFF"
46- ```
47-
48- 3 . Clone the StableHLO repo and the LLVM repository:
41+ 2 . Clone the StableHLO repo and the LLVM repository:
4942
5043 ``` sh
5144 git clone https://github.com/openxla/stablehlo
@@ -57,78 +50,33 @@ Here's how to build the StableHLO repo on Linux or macOS:
5750
5851 Cloning the LLVM repository may take a few minutes.
5952
60- 4 . Make sure you check out the correct commit in the LLVM repository:
53+ 3 . Make sure you check out the correct commit in the LLVM repository:
6154
6255 ``` sh
6356 (cd llvm-project && git fetch && git checkout $( cat ../build_tools/llvm_version.txt) )
6457 ```
6558
6659 You need to do this every time ` llvm_version.txt ` changes.
6760
68- 5 . Configure and build MLIR :
61+ 4 . Build StableHLO as a standalone library :
6962
7063 ``` sh
71- MLIR_ENABLE_BINDINGS_PYTHON=OFF build_tools/build_mlir.sh ${PWD} /llvm-project/ ${PWD} /llvm -build
64+ cmake - -build --preset debug
7265 ```
7366
74- This will take a considerable amount of time. For example, on a MacBook Pro
75- with an M1 Pro chip, building MLIR took around 10 minutes at the moment
76- of writing.
77-
78- Again, you need to do this every time ` llvm_version.txt ` changes.
79-
80- 6 . Build StableHLO as a standalone library:
67+ 5 . Now you can make sure it works by running some tests:
8168
8269 ``` sh
83- mkdir -p build && cd build
84-
85- cmake .. -GNinja \
86- -DLLVM_ENABLE_LLD=" $LLVM_ENABLE_LLD " \
87- -DCMAKE_BUILD_TYPE=Release \
88- -DLLVM_ENABLE_ASSERTIONS=ON \
89- -DSTABLEHLO_ENABLE_BINDINGS_PYTHON=OFF \
90- -DMLIR_DIR=${PWD} /../llvm-build/lib/cmake/mlir
91-
92- cmake --build .
93- ```
94-
95- If you are actively developing StableHLO, you may want the following additional
96- CMake settings:
97-
98- ``` sh
99- cmake .. -GNinja \
100- -DSTABLEHLO_ENABLE_LLD=ON \
101- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
102- -DLLVM_ENABLE_ASSERTIONS=ON \
103- -DSTABLEHLO_ENABLE_BINDINGS_PYTHON=OFF \
104- -DSTABLEHLO_ENABLE_SPLIT_DWARF=ON \
105- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
106- -DCMAKE_C_COMPILER_LAUNCHER=ccache \
107- -DSTABLEHLO_ENABLE_SANITIZER=address \
108- -DMLIR_DIR=${PWD} /../llvm-build/lib/cmake/mlir
109-
110- cmake --build .
111- ```
112-
113- This will enable debug symbols and ccache, which can speed up incremental
114- builds. It also creates a GDB index file in the binary to speed up
115- debugging.
116-
117- If you build MLIR using the script above it should also set by default
118- ` LLVM_USE_SPLIT_DWARF ` which does the majority of the size saving for
119- the binary and should also be set.
120-
121- 7 . Now you can make sure it works by running some tests:
122-
123- ``` sh
124- ninja check-stablehlo-tests
70+ cmake --build --preset debug --target check-stablehlo-tests
12571 ```
12672
12773 You should see results like this:
12874
12975 ``` txt
130- Testing Time: 5.99s
131- Passed: 47
76+ Testing Time: 4.13s
77+
78+ Total Discovered Tests: 137
79+ Passed: 137 (100.00%)
13280 ```
13381
13482 This runs all the tests in ` stablehlo/tests/ ` .
0 commit comments