torch-mlir icon indicating copy to clipboard operation
torch-mlir copied to clipboard

Build doesn't work with `make`

Open dbabokin opened this issue 10 months ago • 1 comments

I'm trying to build with make on macOS and it fails, while exactly the same cmake recipe with Ninja works just fine. Building with make in single thread also works. This is reproducible for me with command from build instruction or by running python setup.py bdist_wheel.

My cmake config command:

cmake -Bbuild \
  -DCMAKE_BUILD_TYPE=Release \
  -DPython3_FIND_VIRTUALENV=ONLY \
  -DPython_FIND_VIRTUALENV=ONLY \
  -DLLVM_ENABLE_PROJECTS=mlir \
  -DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
  -DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
  -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
  -DLLVM_TARGETS_TO_BUILD=host \
  externals/llvm-project/llvm
> make -j8
...
make[2]: *** No rule to make target `tools/mlir/python/dialects/_affine_ops_gen.py', needed by `tools/torch-mlir/python_packages/torch_mlir/torch_mlir/dialects/_affine_ops_gen.py'.  Stop.
make[1]: *** [tools/torch-mlir/python/CMakeFiles/TorchMLIRPythonModules.sources.MLIRPythonSources.Dialects.affine.ops_gen.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** No rule to make target `tools/mlir/python/dialects/_bufferization_ops_gen.py', needed by `tools/torch-mlir/python_packages/torch_mlir/torch_mlir/dialects/_bufferization_ops_gen.py'.  Stop.
make[1]: *** [tools/torch-mlir/python/CMakeFiles/TorchMLIRPythonModules.sources.MLIRPythonSources.Dialects.bufferization.ops_gen.dir/all] Error 2
make[2]: *** No rule to make target `tools/mlir/python/dialects/_builtin_ops_gen.py', needed by `tools/torch-mlir/python_packages/torch_mlir/torch_mlir/dialects/_builtin_ops_gen.py'.  Stop.
make[1]: *** [tools/torch-mlir/python/CMakeFiles/TorchMLIRPythonModules.sources.MLIRPythonSources.Dialects.builtin.ops_gen.dir/all] Error 2
make: *** [all] Error 2

I'm not sure why Ninja handle dependencies correctly, while make doesn't. I'm not sure how to debug this. Any ideas?

If it's not fixed, we should probably use Ninja in setup.py as well.

dbabokin avatar Feb 07 '25 03:02 dbabokin

I'm not sure why Ninja handle dependencies correctly, while make doesn't.

In some cases Ninja just gets lucky. The missingdeps feature in Ninja can help spot some dependency graph issues: https://ninja-build.org/manual.html#:~:text=since%20Ninja%201.4.-,missingdeps,-given%20a%20list

ScottTodd avatar Feb 19 '25 16:02 ScottTodd