XNNPACK icon indicating copy to clipboard operation
XNNPACK copied to clipboard

How to build XNNPACK by Bazel 6.5

Open jfulem opened this issue 11 months ago • 2 comments

When I run bazel build :XNNPACK or bazel build //... I get:

xnnpack/MODULE.bazel:38:16: name 'use_repo_rule' is not defined ERROR: Error computing the main repository mapping: error executing MODULE.bazel file for <root>

When I run bazel build --config windows_x86_64 :XNNPACK I get: ERROR: Config value 'windows_x86_64' is not defined in any .rc file

So, how do I build XNNPACK by using bazel? By CMake, it's all clear.

Thank you very much.

jfulem avatar Jan 27 '25 08:01 jfulem

Hi, thanks for the question. As you referred to Windows, thats something I'm learning myself. From linux, I've used clangcl via lexan, which is --config=lexan_x86_64 and I've used wine or wine32 to test it.

But when building on Windows, as you say, cmake is easy. Although I mistakenly did it wrong, calling scripts/build-local.sh and it works anyway. But there is a .cmd script, which uses ninja but should be the same and gives an option for 32 bit x86.

I havent tried arm, but the 'local' approach works for me on riscv so i expect cmake on windows arm, for windows arm, would also work the same way.

For local builds using a default compiler

bazel build :all

That will be a 'fastbuild', and you can do optimized with

bazel build -c opt :all

So that should work on Window doing a local build for Windows, using Visual C. There are setup instructions that need to be done once to set up bazel.

For cross builds to other platforms, there is a config. e,g, --config=android_x86_64 Config names are being made more consistent, so its usually the OS and CPU, and hopefully the cpus have the same 'x86_64' naming going forward.

fbarchard avatar Jan 30 '25 19:01 fbarchard

Thank you!

jfulem avatar Jan 30 '25 20:01 jfulem