Vscode-cpptools: undefined identifier "__builtin_neon_vst1_v" for NDK-r21b arm64-v8a platform

Created on 12 Nov 2020  ·  4Comments  ·  Source: microsoft/vscode-cpptools

Type: LanguageService
I'd like to use VSCode for developing Android NDK projects, containing arm neon intrinsics in my snippet.

I can use Ctrl+Mouse to go to arm neon intrinsics macros definition, but in my source code, IntelliSense just gives red wavy curves.

No more red wavy curves for arm neon intrinsics marcos is expected.

Describe the bug

  • OS and Version: Windows10 (10.0.19041.572)
  • VS Code Version: 1.52.0(insider)
  • C/C++ Extension Version: v1.1.1
  • Other extensions you installed (and if the issue persists after disabling them): ARM by dan-c-underwood
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

This is a single project with only one C++ source file main.cpp.
The project is equipted with CMakeLists.txt and a build script yanking cmake with ndk-r21b and ninja.

Steps to reproduce

  1. prepare ndk-r21b, cmake, ninja. Ensure cmake and ninja callable from cmd.exe

  2. prepare code:

src/main.cpp:

#include <arm_neon.h>
#include <iostream>
using namespace std;

static void print_uint8x8(uint8x8_t data) {
    static uint8_t p[8];

    // void vst1_u8 (uint8_t * ptr, uint8x8_t val)
    vst1_u8(p, data);
    for (int i=0; i<8; i++) {
        printf("%2d ", p[i]);
    }
    printf("\n");
}

int main() {
    uint8x8_t data1 = vdup_n_u8(255);
    print_uint8x8(data1);

    return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)

project(demo)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_executable(demo
    src/main.cpp
)

build/build-android-arm64.bat:

@echo off

set ANDROID_NDK=E:/soft/Android/ndk-r21b
set TOOLCHAIN=%ANDROID_NDK%/build/cmake/android.toolchain.cmake

set BUILD_DIR=arm64-v8a
if not exist %BUILD_DIR% md %BUILD_DIR%
cd %BUILD_DIR%

cmake -G Ninja ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_TOOLCHAIN_FILE=%TOOLCHAIN% ^
    -DANDROID_LD=lld ^
    -DANDROID_ABI="arm64-v8a" ^
    -DANDROID_PLATFORM=android-24 ^
    ../..

ninja

cd ..
  1. open cmd.exe, change directory to build folder under this project, run build-android-arm64.bat

  2. Create .vscode/c_cpp_properties.json with content:

{
    "configurations": [
        {
            "name": "NDK-r21b",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "clang-arm64",
            "compileCommands": "${workspaceFolder}/build/arm64-v8a/compile_commands.json"
        }
    ],
    "version": 4
}
  1. Go to main.cpp, will see red wavy curves for vst1q_u8:
    image

  2. Use ctrl+mouse click on vst1q_u8, go to its definition is OK, like this:
    image

Expected behavior

No more red wavy curves for arm neon intrinsics vst1q_u8 marcos is expected.

  1. Logs from the command C/C++: Log Diagnostics
-------- Diagnostics - 2020/11/12 下午4:45:10
Version: 1.1.1
Current Configuration:
{
    "name": "NDK-r21b",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "cStandard": "c11",
    "cppStandard": "c++11",
    "intelliSenseMode": "clang-arm64",
    "compileCommands": "${workspaceFolder}/build/arm64-v8a/compile_commands.json",
    "compilerArgs": [],
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "compilerPathIsExplicit": true,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ E:\dbg\zz\pixel\neon_intro\src\main.cpp ]:
    E:\DBG\ZZ\PIXEL\NEON_INTRO\SRC\MAIN.CPP
    E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\LIB64\CLANG\9.0.8\INCLUDE\ARM_NEON.H
Translation Unit Configurations:
[ E:\dbg\zz\pixel\neon_intro\src\main.cpp ]:
    Process ID: 22112
    Memory Usage: 157 MB
    Compiler Path: E:\soft\Android\ndk-r21b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
    Includes:
        E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\SYSROOT\USR\INCLUDE\C++\V1
        E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\SYSROOT\USR\LOCAL\INCLUDE
        E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\LIB64\CLANG\9.0.8\INCLUDE
        E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\SYSROOT\USR\INCLUDE\AARCH64-LINUX-ANDROID
        E:\SOFT\ANDROID\NDK-R21B\TOOLCHAINS\LLVM\PREBUILT\WINDOWS-X86_64\SYSROOT\USR\INCLUDE
    Defines:
        ANDROID
        _FORTIFY_SOURCE=2
        NDEBUG
    Standard Version: c++11
    IntelliSense Mode: clang-arm64
    Other Flags:
        --clang
        --clang_version=90008
    compile_commands.json entry:
        directory: E:/dbg/zz/pixel/neon_intro/build/arm64-v8a
        file: E:/dbg/zz/pixel/neon_intro/src/main.cpp
        command: E:\soft\Android\ndk-r21b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android24 --gcc-toolchain=E:/soft/Android/ndk-r21b/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=E:/soft/Android/ndk-r21b/toolchains/llvm/prebuilt/windows-x86_64/sysroot -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   -O2 -DNDEBUG  -fPIE -o CMakeFiles\demo.dir\src\main.cpp.o -c E:\dbg\zz\pixel\neon_intro\src\main.cpp
Total Memory Usage: 157 MB
Browse Paths from compile_commands.json, from workspace folder: E:\dbg\zz\pixel\neon_intro
    E:\DBG\ZZ\PIXEL\NEON_INTRO\SRC

------- Workspace parsing diagnostics -------
Number of folders and files enumerated: 1977
Number of files discovered (not excluded): 1885
  1. Logs from the language server
    -->

    Logs
文件排除: **/.git
文件排除: **/.svn
文件排除: **/.hg
文件排除: **/CVS
文件排除: **/.DS_Store
文件排除: **/.vscode
搜索排除: **/node_modules
搜索排除: **/bower_components
搜索排除: **/*.code-search
搜索排除: **/.vscode
填充包含完成缓存。
正在发现文件...
  正在处理文件夹(递归): E:/SOFT/LLVM11/LIB/CLANG/11.0.0/INCLUDE/
  正在处理文件夹(递归): E:/DBG/ZZ/PIXEL/NEON_INTRO/SRC/
  正在处理文件夹(递归): E:/SOFT/ANDROID/NDK-R21B/TOOLCHAINS/LLVM/PREBUILT/WINDOWS-X86_64/LIB64/CLANG/9.0.8/INCLUDE/
  正在处理文件夹(递归): E:/SOFT/ANDROID/NDK-R21B/TOOLCHAINS/LLVM/PREBUILT/WINDOWS-X86_64/SYSROOT/USR/INCLUDE/
  正在处理文件夹(递归): E:/SOFT/ANDROID/NDK-R21B/TOOLCHAINS/LLVM/PREBUILT/WINDOWS-X86_64/SYSROOT/USR/LOCAL/INCLUDE/
  正在发现文件: 已处理 1885 个文件
  已从数据库中删除 0 个文件
“发现文件”操作已完成。
正在分析打开的文件...
正在分析剩余的文件...
  正在分析: 已处理 0 个文件
“分析剩余文件”操作已完成。
“分析打开的文件”操作已完成。

Screenshots

Additional context

Language Service Visual Studio bug embedded parser

Most helpful comment

__fp16 support hasn't been implemented yet. I've filed a bug on VS (our shared parser) at https://developercommunity.visualstudio.com/content/problem/1257543/c-intellisense-doesnt-support-fp16-in-clang-mode.html .

There might be additional arm neon intrinsic issues though.

All 4 comments

To be precise, this squirrel is due to IntelliSense errors in arm_neon.h. It can't recognize __fp16:

image
image

__fp16 support hasn't been implemented yet. I've filed a bug on VS (our shared parser) at https://developercommunity.visualstudio.com/content/problem/1257543/c-intellisense-doesnt-support-fp16-in-clang-mode.html .

There might be additional arm neon intrinsic issues though.

__qsub intrinsic has the same problem too, even with
"intelliSenseMode": "gcc-arm"

Hi, tested on more platforms:

  • MacOSX, vscode cpptools v1.1.3, using default c_cpp_properties.json (only specify compile_commands.json), no red squirrels
  • Linux (ubuntu 20.04), vscode cpptools v1.1.3, default c_cpp_properties.json (only specify compile_commands.json), or creating new clang-arm64 config like the previously pasted, still sufferring red squirrels
Was this page helpful?
0 / 5 - 0 ratings