Error when building using QNN

Andre11: <p>I get the following error when following the<br>
tutorial: <a href="https://pytorch.org/executorch/main/build-run-qualcomm-ai-engine-direct-backend.html" rel="noopener nofollow ugc">Building and Running ExecuTorch with Qualcomm AI Engine Direct Backend</a></p>
<p>I run:</p>
<pre><code class="lang-auto">cd $EXECUTORCH_ROOT
mkdir build_android
cd build_android
# build executorch &amp; qnn_executorch_backend
cmake .. \
    -DCMAKE_INSTALL_PREFIX=$PWD \
    -DEXECUTORCH_BUILD_SDK=ON \
    -DEXECUTORCH_BUILD_QNN=ON \
    -DQNN_SDK_ROOT=$QNN_SDK_ROOT \
    -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
    -DANDROID_ABI='arm64-v8a' \
    -DANDROID_NATIVE_API_LEVEL=23 \
    -B$PWD

cmake --build $PWD -j16 --target install
</code></pre>
<p>Then I get these errors:</p>
<pre><code class="lang-auto">executorch/third-party/flatcc/include/flatcc/portable/pprintint.h:262:6: error: [[]] attributes are a C23 extension [-Werror,-Wc23-extensions] 
</code></pre>
<p>My env is:</p>
<pre><code class="lang-auto">Collecting environment information...                                                                                                                                                                       
PyTorch version: 2.4.0.dev20240507+cpu                                                                                                                                                                      
Is debug build: False                                                                                                                                                                                       
CUDA used to build PyTorch: Could not collect                                                                                                                                                               
ROCM used to build PyTorch: N/A                                                                                                                                                                             
                                                                                                                                                                                                            
OS: Ubuntu 22.04.4 LTS (x86_64)                                                                                                                                                                             
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                                                                                                                                                          
Clang version: 14.0.0-1ubuntu1.1                                                                                                                                                                            
CMake version: version 3.27.2                                                                                                                                                                               
Libc version: glibc-2.35                                                                                                                                                                                    
                                                                                                                                                                                                            
Python version: 3.10.0 (default, Mar  3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime)                                                                                                                        
Python platform: Linux-5.15.0-113-generic-x86_64-with-glibc2.35                                                                                                                                             
Is CUDA available: False                                                                                                                                                                                    
CUDA runtime version: 11.8.89                                                                                                                                                                               
CUDA_MODULE_LOADING set to: N/A                                                                                                                                                                             
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090                                                                                                                                                
Nvidia driver version: 535.183.01                                                                                                                                                                           
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5                                                                                                                                                  
HIP runtime version: N/A                                                                                                                                                                                    
MIOpen runtime version: N/A                                                                                                                                                                                 
Is XNNPACK available: True                                                                                                                                                                                  
                                                                                                                                                                                                            
CPU:                                                                                                                                                                                                        
Architecture:                       x86_64                                                                                                                                                                  
CPU op-mode(s):                     32-bit, 64-bit                                                                                                                                                          
Address sizes:                      39 bits physical, 48 bits virtual                                                                                                                                       
Byte Order:                         Little Endian                                                                                                                                                           
CPU(s):                             12                                                                                                                                                                      
On-line CPU(s) list:                0-11                                                                                                                                                                    
Vendor ID:                          GenuineIntel                                                                                                                                                            
Model name:                         Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz                                                                                                                                
CPU family:                         6                                                                                                                                                                       
Model:                              158                                                                                                                                                                     
Thread(s) per core:                 2                                                                                                                                                                       
Core(s) per socket:                 6                                                                                                                                                                       
Socket(s):                          1                                                                                                                                                                       
Stepping:                           10                                                                                                                                                                      
CPU max MHz:                        4700.0000                                                                                                                                                               
CPU min MHz:                        800.0000                                                                                                                                                                
BogoMIPS:                           7399.70                                                                                                                                                                 
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art ar
ch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadli
ne_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 er
ms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities                        
Virtualization:                     VT-x
L1d cache:                          192 KiB (6 instances)
L1i cache:                          192 KiB (6 instances)
L2 cache:                           1.5 MiB (6 instances)
L3 cache:                           12 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-11
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Mitigation; PTI 
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                Mitigation; Microcode
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] executorch==0.3.0a0+1991346
[pip3] numpy==1.26.4
[pip3] onnx==1.12.0
[pip3] onnx-simplifier==0.4.8
[pip3] onnxruntime==1.12.1
[pip3] open-clip-torch==2.24.0
[pip3] torch==2.4.0.dev20240507+cpu
[pip3] torchao==0.1
[pip3] torchaudio==2.2.0.dev20240507+cpu
[pip3] torchsr==1.0.4
[pip3] torchvision==0.19.0.dev20240507+cpu
[pip3] triton==2.2.0
[conda] executorch                0.3.0a0+a3ff00d          pypi_0    pypi
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] open-clip-torch           2.24.0                   pypi_0    pypi
[conda] torch                     2.4.0.dev20240507+cpu          pypi_0    pypi
[conda] torchao                   0.1                      pypi_0    pypi
[conda] torchaudio                2.2.0.dev20240507+cpu          pypi_0    pypi
[conda] torchsr                   1.0.4                    pypi_0    pypi
[conda] torchvision               0.19.0.dev20240507+cpu          pypi_0    pypi
[conda] triton                    2.2.0                    pypi_0    pypi
</code></pre>

dbort: <p>Thanks for reporting this issue. It sounds like a C++ version problem. We have logic that tries to handle this at <a href="https://github.com/pytorch/executorch/blob/main/runtime/platform/compiler.h#L62" class="inline-onebox" rel="noopener nofollow ugc">executorch/runtime/platform/compiler.h at main · pytorch/executorch · GitHub</a>, but your compiler must behave differently than we expect.</p>
<p>Since this does sound like an issue worth fixing, please create a <a href="https://github.com/pytorch/executorch/issues/new?assignees=&amp;labels=&amp;projects=&amp;template=bug-report.yml" rel="noopener nofollow ugc">Github bug</a> with the details you described.</p>