Repository: pytorch
Issue: [Pytorch Mobile] Error running build_pytorch_android.sh
Labels: module: android,oncall: mobile

## 🐛 Bug

I'm following [Pytorch Vulkan backend user workflow](https://pytorch.org/tutorials/prototype/vulkan_workflow.html#android-java-api) in order to build a libtorch binary that includes Vulkan backend for Android. I've also followed the steps from this Pytorch's official [repo](https://github.com/pytorch/pytorch/tree/master/android#building-pytorch-android-from-source) before running the script. 

## To Reproduce

Steps to reproduce the behavior:

1. Clone pytorch repo
```
git clone https://github.com/pytorch/pytorch.git
cd pytorch
git submodule update --init --recursive
```
2. Specify ```ANDROID_HOME```, ```ANDROID_NDK```, ```GRADLE_HOME``` and  ```JAVA_HOME``` as environment variables.
3. Run ```USE_VULKAN=1 sh ./scripts/build_pytorch_android.sh``` inside Pytorch's root folder.

## Output 
```
-- 
-- ******** Summary ********
-- General:
--   CMake version         : 3.20.1
--   CMake command         : /opt/homebrew/Cellar/cmake/3.20.1/bin/cmake
--   System                : Android
--   C++ compiler          : /Users/sergiosanchez/Library/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
--   C++ compiler id       : Clang
--   C++ compiler version  : 11.0.5
--   Using ccache if found : ON
--   Found ccache          : CCACHE_PROGRAM-NOTFOUND
--   CXX flags             : -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -frtti -fexceptions  -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_VULKAN_WRAPPER -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN -DUSE_VULKAN_API -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -g0
--   Build type            : Release
--   Compile definitions   : 
--   CMAKE_PREFIX_PATH     : /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages;/Users/sergiosanchez/Library/Android/sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/darwin-x86_64
--   CMAKE_INSTALL_PREFIX  : /Users/sergiosanchez/pytorch/build_android_armeabi-v7a/install
-- 
--   TORCH_VERSION         : 1.9.0
--   CAFFE2_VERSION        : 1.9.0
--   BUILD_CAFFE2          : ON
--   BUILD_CAFFE2_OPS      : OFF
--   BUILD_CAFFE2_MOBILE   : OFF
--   BUILD_STATIC_RUNTIME_BENCHMARK: OFF
--   BUILD_TENSOREXPR_BENCHMARK: OFF
--   BUILD_BINARY          : OFF
--   BUILD_CUSTOM_PROTOBUF : OFF
--     Protobuf compiler   : 
--     Protobuf includes   : 
--     Protobuf libraries  : 
--   BUILD_DOCS            : OFF
--   BUILD_PYTHON          : OFF
--   BUILD_SHARED_LIBS     : OFF
--   CAFFE2_USE_MSVC_STATIC_RUNTIME     : ON
--   BUILD_TEST            : OFF
--   BUILD_JNI             : OFF
--   BUILD_MOBILE_AUTOGRAD : OFF
--   BUILD_LITE_INTERPRETER: OFF
--   INTERN_BUILD_MOBILE   : ON
--   USE_BLAS              : 1
--     BLAS                : 
--   USE_LAPACK            : 
--   USE_ASAN              : OFF
--   USE_CPP_CODE_COVERAGE : OFF
--   USE_CUDA              : OFF
--   USE_ROCM              : OFF
--   USE_EIGEN_FOR_BLAS    : ON
--   USE_FBGEMM            : OFF
--     USE_FAKELOWP          : OFF
--   USE_KINETO            : OFF
--   USE_FFMPEG            : OFF
--   USE_GFLAGS            : OFF
--   USE_GLOG              : OFF
--   USE_LEVELDB           : OFF
--   USE_LITE_PROTO        : OFF
--   USE_LMDB              : OFF
--   USE_METAL             : OFF
--   USE_PYTORCH_METAL     : OFF
--   USE_FFTW              : OFF
--   USE_MKL               : 
--   USE_MKLDNN            : OFF
--   USE_NCCL              : OFF
--   USE_NNPACK            : ON
--   USE_NUMPY             : ON
--   USE_OBSERVERS         : OFF
--   USE_OPENCL            : OFF
--   USE_OPENCV            : OFF
--   USE_OPENMP            : OFF
--   USE_TBB               : OFF
--   USE_VULKAN            : ON
--     USE_VULKAN_FP16_INFERENCE    : OFF
--     USE_VULKAN_RELAXED_PRECISION : OFF
--     USE_VULKAN_SHADERC_RUNTIME   : OFF
--   USE_PROF              : OFF
--   USE_QNNPACK           : OFF
--   USE_PYTORCH_QNNPACK   : ON
--   USE_REDIS             : OFF
--   USE_ROCKSDB           : OFF
--   USE_ZMQ               : OFF
--   USE_DISTRIBUTED       : OFF
--   USE_DEPLOY           : OFF
--   Public Dependencies  : Threads::Threads
--   Private Dependencies : eigen_blas;pthreadpool;cpuinfo;pytorch_qnnpack;nnpack;XNNPACK;VulkanWrapper;fp16;log;fmt::fmt-header-only;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sergiosanchez/pytorch/build_android_armeabi-v7a
Will install headers and libs to /Users/sergiosanchez/pytorch/build_android_armeabi-v7a/install for further Android project usage.
[  0%] Building CXX object CMakeFiles/VulkanWrapper.dir/Users/sergiosanchez/Library/Android/sdk/ndk/22.1.7171670/sources/third_party/vulkan/src/common/vulkan_wrapper.cpp.o
[  0%] Building C object confu-deps/cpuinfo/deps/clog/CMakeFiles/clog.dir/src/clog.c.o
[  0%] Generating ../aten/src/ATen/CPUFunctions.h, ../aten/src/ATen/CompositeExplicitAutogradFunctions.h, ../aten/src/ATen/CompositeImplicitAutogradFunctions.h, ../aten/src/ATen/Declarations.yaml, ../aten/src/ATen/Functions.cpp, ../aten/src/ATen/Functions.h, ../aten/src/ATen/MetaFunctions.h, ../aten/src/ATen/NativeFunctions.h, ../aten/src/ATen/RedispatchFunctions.cpp, ../aten/src/ATen/RedispatchFunctions.h, ../aten/src/ATen/RegisterBackendSelect.cpp, ../aten/src/ATen/RegisterCPU.cpp, ../aten/src/ATen/RegisterCompositeExplicitAutograd.cpp, ../aten/src/ATen/RegisterCompositeImplicitAutograd.cpp, ../aten/src/ATen/RegisterQuantizedCPU.cpp, ../aten/src/ATen/RegisterSchema.cpp, ../aten/src/ATen/RegistrationDeclarations.h, ../aten/src/ATen/core/ATenOpList.cpp, ../aten/src/ATen/core/TensorBody.h, ../aten/src/ATen/core/TensorMethods.cpp
[  0%] Building C object confu-deps/pthreadpool/CMakeFiles/pthreadpool.dir/src/legacy-api.c.o
[  0%] Building CXX object CMakeFiles/eigen_blas.dir/third_party/eigen/blas/single.cpp.o
[  0%] Building C object confu-deps/pthreadpool/CMakeFiles/pthreadpool.dir/src/portable-api.c.o
[  0%] Building CXX object third_party/fmt/CMakeFiles/fmt.dir/src/format.cc.o
[  0%] Building CXX object c10/CMakeFiles/c10.dir/core/Allocator.cpp.o
[  0%] Linking C static library ../../../../lib/libclog.a
[  0%] Linking CXX static library lib/libVulkanWrapper.a
[  0%] Building C object confu-deps/pthreadpool/CMakeFiles/pthreadpool.dir/src/memory.c.o
[  0%] Built target VulkanWrapper
[  0%] Built target clog
[  0%] Building CXX object third_party/fmt/CMakeFiles/fmt.dir/src/os.cc.o
[  0%] Building CXX object CMakeFiles/eigen_blas.dir/third_party/eigen/blas/double.cpp.o
[  0%] Building C object confu-deps/cpuinfo/CMakeFiles/cpuinfo_internals.dir/src/init.c.o
[  0%] Building C object confu-deps/cpuinfo/CMakeFiles/cpuinfo_internals.dir/src/api.c.o
```
...

```
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-vrnd/gen/vrndz-neonv8-x8.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/math/roundd-neonv8.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/math/roundne-neonv8.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/math/roundz-neonv8.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/math/roundu-neonv8.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/1x8c4-minmax-neondot.c.o
[ 66%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/1x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/4x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/4x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/6x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/6x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/8x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/8x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-gemm/gen/12x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/1x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/1x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/4x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/4x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/6x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/8x8c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/6x16c4-minmax-neondot.c.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/8x16c4-minmax-neondot.c.o
[ 67%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/4x4-minmax-aarch32-vfp-ld64.S.o
[ 67%] Building C object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/qs8-igemm/gen/12x8c4-minmax-neondot.c.o
[ 67%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/4x4-aarch32-vfp-ld64.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/4x8-minmax-aarch32-neon-cortex-a55.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/4x8-minmax-aarch32-neon-cortex-a53.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/gen/4x8-minmax-aarch32-neon-cortex-a7.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/gen/4x8-minmax-aarch32-neon-cortex-a75.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/gen/4x8-minmax-aarch32-neon-pld-cortex-a75.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-gemm/gen/4x8-minmax-aarch32-neon-ld64.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/4x8-minmax-aarch32-neon-cortex-a53.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/4x8-minmax-aarch32-neon-cortex-a55.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/gen/4x8-minmax-aarch32-neon-cortex-a7.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/gen/4x8-minmax-aarch32-neon-cortex-a75.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/gen/4x8-minmax-aarch32-neon-ld64.S.o
[ 68%] Building ASM object confu-deps/XNNPACK/CMakeFiles/XNNPACK.dir/src/f32-igemm/gen/4x8-minmax-aarch32-neon-pld-cortex-a75.S.o
[ 68%] Linking C static library ../../lib/libXNNPACK.a
[ 68%] Built target XNNPACK
make: *** [all] Error 2
```

## Expected behavior

Successful build and generation of aar file.

## Environment

 - PyTorch Version: 1.9.0 ([47d2edd](47d2edd5975ecfc047916fa769307d00d50c02b6))
 - OS: macOS Big Sur 11.2 (Apple M1)
 - How you installed PyTorch: ```git clone https://github.com/pytorch/pytorch.git```
 - Python version: 3.9
 - Any other relevant information: I followed the same steps on Ubuntu; same output, different error. If anyone is interested I can post it too.