Compiling src/amalgam/gen/neonfp16arith.c failed: (Exit 70): clang failed: error executing command (from target @XNNPACK//:neonfp16arith_amalgam_microkernels) external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang '-D__ANDROID_API__=26' -isystemexternal/androidndk/ndk/sysroot/usr/include/arm-linux-androideabi -target ... (remaining 71 arguments skipped)
I was able to reproduce this issue with TF2.13 and master branch as well.  

@pkgoogle Could you please check this issue?

Thanks.

<img width="562" alt="Screenshot 2023-08-24 at 11 42 14 AM" src="https://github.com/tensorflow/tensorflow/assets/118897289/22eac763-6f5e-43fa-aefe-0ea32d287dcf">
 Hi @B-JackMao, 

I'm actually getting a different error:
```
INFO: Found applicable config definition build:dynamic_kernels in file /usr/local/google/home/xxxxxx/tensorflow/.bazelrc: --define=dynamic_loaded_kernels=true --copt=-DAUTOLOAD_DYNAMIC_KERNELS
ERROR: /usr/local/google/home/xxxxxx/tensorflow/tensorflow/lite/java/BUILD:297:16: While resolving toolchains for target //tensorflow/lite/java:tensorflowlite_gpu_impl: no matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type
ERROR: Analysis of target '//tensorflow/lite/java:tensorflow-lite-gpu' failed; build aborted: 
INFO: Elapsed time: 24.188s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (51 packages loaded, 242 targets configured)
```
can you please provide exact steps. I.e. are you using the configure script? If so, what options did you specify? Are you following this [resource](https://www.tensorflow.org/lite/android/lite_build) at all? or any other resource? Are you using the docker file or something else?

Preferably write the steps as you would edit a Dockerfile or a shell script.
example:
```sh
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git switch r2.13
git pull
bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a  --host_crosstool_top=@bazel_tools//tools/cpp:toolchain  //tensorflow/lite/java:tensorflow-lite-gpu
``` # install python and prerequisites sudo apt install python-dev python-pip pip install -U --user pip six numpy wheel mock pip install -U --user keras_applications==1.0.6 --no-deps pip install -U --user keras_preprocessing==1.0.5 --no-deps # install openjdk-8 sudo apt-get install openjdk-8-jdk 


# install bazel 6.1.0
# install the prerequisites sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python chmod +x bazel-6.1.0-installer-linux-x86_64.sh ./bazel-6.1.0-installer-linux-x86_64.sh --user # setup environment export PATH="$PATH:$HOME/bin"


##Android
mkdir ~/Android cd Android #NDK  use ndk r19c unzip android-ndk-r19c-linux-x86_64.zip mkdir Sdk mv android-ndk-r19c Sdk/ndk-bundle #SDK wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip unzip sdk-tools-linux-4333796.zip  mv tools/ Sdk/ # Platform tools wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip unzip platform-tools-latest-linux.zip  mv platform-tools Sdk/ # Using sdkmanager to install tools cd Sdk chmod a+x tools/bin/sdkmanager ./tools/bin/sdkmanager "platform-tools" "platforms;android-27" "platforms;android-28" "platforms;android-29" "platforms;android-30" "build-tools;30.0.0" "build-tools;29.0.3"  



 download tensorflow code git clone https://github.com/tensorflow/tensorflow.git cd tensorflow ./configure


about"y/N",only "WORKSPACES"choose y,other choose "N",Choose the default configuration for the rest


run command “bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a ***@***.***_tools//tools/cpp:toolchain //tensorflow/lite/java:tensorflow-lite-gpu” and want to build "tensorflow-lite-gpu.aar"  




and error occurred.






------------------&nbsp;原始邮件&nbsp;------------------
发件人: ***@***.***&gt;; 
发送时间: 2023年8月25日(星期五) 凌晨1:31
收件人: ***@***.***&gt;; 
抄送: ***@***.***&gt;; ***@***.***&gt;; 
主题: Re: [tensorflow/tensorflow] Compiling src/amalgam/gen/neonfp16arith.c failed: (Exit 70): clang failed: error executing command (from target @XNNPACK//:neonfp16arith_amalgam_microkernels) external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang &#39;-D__ANDROID_API__=26&#39; -isystemexternal/androidndk/ndk/sysroot/usr/include/arm-linux-androideabi -target ... (remaining 71 arguments skipped) (Issue #61655)





 
Hi @B-JackMao,
 
I'm actually getting a different error:
 INFO: Found applicable config definition build:dynamic_kernels in file /usr/local/google/home/xxxxxx/tensorflow/.bazelrc: --define=dynamic_loaded_kernels=true --copt=-DAUTOLOAD_DYNAMIC_KERNELS ERROR: /usr/local/google/home/xxxxxx/tensorflow/tensorflow/lite/java/BUILD:297:16: While resolving toolchains for target //tensorflow/lite/java:tensorflowlite_gpu_impl: no matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type ERROR: Analysis of target '//tensorflow/lite/java:tensorflow-lite-gpu' failed; build aborted:  INFO: Elapsed time: 24.188s INFO: 0 processes. FAILED: Build did NOT complete successfully (51 packages loaded, 242 targets configured)  
can you please provide exact steps. I.e. are you using the configure script? If so, what options did you specify? Are you following this resource at all? or any other resource? Are you using the docker file or something else?
 
Preferably write the steps as you would edit a Dockerfile or a shell script.
 example:
 git clone https://github.com/tensorflow/tensorflow.git cd tensorflow git switch r2.13 git pull bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a  ***@***.***_tools//tools/cpp:toolchain  //tensorflow/lite/java:tensorflow-lite-gpu
 
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***&gt; I am able to reproduce with the following modifications:

Set API level = 30 when asked during configuration, the final command for reproducibility was:
```sh
bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain //tensorflow/lite/java:tensorflow-lite-gpu
```

```sh
ERROR: /usr/local/google/home/xxxxxx/.cache/bazel/_bazel_xxxxxx/caf3a5af5fd2180c9e3e5a21b39f1c0d/external/XNNPACK/BUILD.bazel:3046:19: Compiling src/amalgam/gen/neonfp16arith.c failed: (Exit 70): clang failed: error executing command (from target @XNNPACK//:neonfp16arith_amalgam_microkernels) 
  (cd /usr/local/google/home/xxxxxx/.cache/bazel/_bazel_xxxxxx/caf3a5af5fd2180c9e3e5a21b39f1c0d/execroot/org_tensorflow && \
  exec env - \
    ANDROID_BUILD_TOOLS_VERSION=30.0.3 \
    ANDROID_NDK_API_LEVEL=26 \
    ANDROID_NDK_HOME=/usr/local/google/home/xxxxxx/Android/Sdk/ndk/android-ndk-r19c \
    ANDROID_SDK_API_LEVEL=30 \
    ANDROID_SDK_HOME=/usr/local/google/home/xxxxxx/Android/Sdk \
    LD_LIBRARY_PATH=/usr/lib/mesa-diverted/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/x86_64-linux-gnu/gallium-pipe \
    PATH=/usr/local/google/home/xxxxxx/.cache/bazelisk/downloads/bazelbuild/bazel-6.1.0-linux-x86_64/bin:/usr/local/google/home/xxxxxxx/miniconda3/envs/61655/bin:/usr/local/google/home/xxxxxx/miniconda3/condabin:/usr/local/google/home/xxxxxx/.local/bin:/usr/lib/google-golang/bin:/usr/local/buildtools/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/usr/local/google/home/xxxxxx/miniconda3/envs/61655/bin/python3 \
    PYTHON_LIB_PATH=/usr/local/google/home/xxxxxxx/miniconda3/envs/61655/lib/python3.11/site-packages \
    TF2_BEHAVIOR=1 \
  external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang '-D__ANDROID_API__=26' -isystemexternal/androidndk/ndk/sysroot/usr/include/arm-linux-androideabi -target armv7-none-linux-androideabi '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' -gcc-toolchain external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -fpic -no-canonical-prefixes -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -funwind-tables -fstack-protector-strong -fno-addrsig '-Werror=return-type' '-Werror=int-to-pointer-cast' '-Werror=pointer-to-int-cast' '-Werror=implicit-function-declaration' -mthumb -Os -g -DNDEBUG -MD -MF bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK/_objs/neonfp16arith_amalgam_microkernels/neonfp16arith.pic.d '-frandom-seed=bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK/_objs/neonfp16arith_amalgam_microkernels/neonfp16arith.pic.o' -fPIC '-DBAZEL_CURRENT_REPOSITORY="XNNPACK"' -iquote external/XNNPACK -iquote bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK -isystem external/XNNPACK/include -isystem bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK/include -isystem external/XNNPACK/src -isystem bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK/src -Wno-all -Wno-extra -Wno-deprecated -Wno-deprecated-declarations -Wno-ignored-attributes -Wno-array-bounds -Wunused-result '-Werror=unused-result' -Wswitch '-Werror=switch' '-Wno-error=unused-but-set-variable' -DAUTOLOAD_DYNAMIC_KERNELS -Iinclude -Isrc -marm '-march=armv8.2-a+fp16' '-mfpu=neon-fp-armv8' '-std=c99' -O2 '--sysroot=external/androidndk/ndk/platforms/android-26/arch-arm' -isystem external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include -isystem external/androidndk/ndk/sources/cxx-stl/llvm-libc++abi/include -isystem external/androidndk/ndk/sources/android/support/include -isystemexternal/androidndk/ndk/sysroot/usr/include -c external/XNNPACK/src/amalgam/gen/neonfp16arith.c -o bazel-out/android-armeabi-v7a-opt/bin/external/XNNPACK/_objs/neonfp16arith_amalgam_microkernels/neonfp16arith.pic.o)
# Configuration: ee5ef3675746c4253f216a2d59070e2657d7f9037448cc2d2289ec75605ec73c
# Execution platform: @local_execution_config_platform//:platform
warning: unknown warning option '-Werror=unused-but-set-variable'; did you mean '-Werror=unused-const-variable'? [-Wunknown-warning-option]
fatal error: error in backend: Cannot select: 0x65727a8: v8f16 = bitcast 0x656f438, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:28
  0x656f438: v8i16,ch = ARMISD::VLD1DUP<(load 2 from %ir.17)> 0x68b7628, 0x6572608, Constant:i32<2>, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:50
    0x6572608: i32 = add nuw 0x656fcc0, Constant:i32<2>, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:50
      0x656fcc0: i32,ch = load<(load 4 from %fixed-stack.0, align 8)> 0x68b7628, FrameIndex:i32<-7>, undef:i32
        0x656fc58: i32 = FrameIndex<-7>
        0x656f778: i32 = undef
      0x65725a0: i32 = Constant<2>
    0x65725a0: i32 = Constant<2>
In function: xnn_f16_avgpool_minmax_ukernel_9p8x__neonfp16arith_c8
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android (5058415 based on r339409) clang version 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec746213857d083c0e8b0abb568790) (https://android.googlesource.com/toolchain/llvm 7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: armv7-none-linux-android
Thread model: posix
InstalledDir: external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/neonfp16arith-2b5d8a.c
clang: note: diagnostic msg: /tmp/neonfp16arith-2b5d8a.sh
clang: note: diagnostic msg: 

********************
Target //tensorflow/lite/java:tensorflow-lite-gpu failed to build
INFO: Elapsed time: 3.274s, Critical Path: 2.56s
INFO: 288 processes: 175 internal, 113 local.
FAILED: Build did NOT complete successfully
```

Hi @miaout17, can you please take a look? Thanks.
### Issue type

Build/Install

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

2.13

### Custom code

Yes

### OS platform and distribution

Ubuntu18.04

### Mobile device

pixel 4

### Python version

3.6

### Bazel version

6.1.0

### GCC/compiler version

null

### CUDA/cuDNN version

null

### GPU model and memory

null

### Current behavior?

I run the following command “bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a   --host_crosstool_top=@bazel_tools//tools/cpp:toolchain   //tensorflow/lite/java:tensorflow-lite-gpu” and want to build "tensorflow-lite-gpu.aar",But the following error occurred.

### Standalone code to reproduce the issue

```shell
I run the following command “bazel build -c opt --fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a   --host_crosstool_top=@bazel_tools//tools/cpp:toolchain   //tensorflow/lite/java:tensorflow-lite-gpu” and want to build "tensorflow-lite-gpu.aar",But the following error occurred.
```


### Relevant log output

```shell
ERROR: /home/ferey/.cache/bazel/_bazel_ferey/b105c31c70ad75e6928e90fd6d84ab22/external/XNNPACK/BUILD.bazel:3480:19: Compiling src/amalgam/gen/neonfp16arith.c failed: (Exit 70): clang failed: error executing command (from target @XNNPACK//:neonfp16arith_amalgam_microkernels) external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang '-D__ANDROID_API__=26' -isystemexternal/androidndk/ndk/sysroot/usr/include/arm-linux-androideabi -target ... (remaining 71 arguments skipped)
warning: unknown warning option '-Werror=unused-but-set-variable'; did you mean '-Werror=unused-const-variable'? [-Wunknown-warning-option]
fatal error: error in backend: Cannot select: 0x5e9cd18: v8f16 = bitcast 0x5e999a8, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:28
  0x5e999a8: v8i16,ch = ARMISD::VLD1DUP<(load 2 from %ir.17)> 0x5e16428, 0x5e9cb78, Constant:i32<2>, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:50
    0x5e9cb78: i32 = add nuw 0x5e9a230, Constant:i32<2>, external/XNNPACK/src/amalgam/gen/neonfp16arith.c:51:50
      0x5e9a230: i32,ch = load<(load 4 from %fixed-stack.0, align 8)> 0x5e16428, FrameIndex:i32<-7>, undef:i32
        0x5e9a1c8: i32 = FrameIndex<-7>
        0x5e99ce8: i32 = undef
      0x5e9cb10: i32 = Constant<2>
    0x5e9cb10: i32 = Constant<2>
In function: xnn_f16_avgpool_minmax_ukernel_9p8x__neonfp16arith_c8
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android (5058415 based on r339409) clang version 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec746213857d083c0e8b0abb568790) (https://android.googlesource.com/toolchain/llvm 7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: armv7-none-linux-android
Thread model: posix
InstalledDir: external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/neonfp16arith-376495.c
clang: note: diagnostic msg: /tmp/neonfp16arith-376495.sh
clang: note: diagnostic msg: 

********************
Target //tensorflow/lite/java:tensorflow-lite-gpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 224.110s, Critical Path: 19.33s
INFO: 335 processes: 3 internal, 332 local.
FAILED: Build did NOT complete successfully
```
