MegEngine / mperf

mperf是一个面向移动/嵌入式平台的算子性能调优工具箱
Apache License 2.0
170 stars 27 forks source link

cmake error with NDK r25c, WSL ubuntu 20.04 #3

Closed ysh329 closed 1 year ago

ysh329 commented 1 year ago

env:

  1. android-ndk-r25c
  2. WSL Ubuntu 20.04
$ ./android_build.sh -g mali
the SRC_DIR val is /home/stayua01/code/mperf
build with gpu:mali
NDK_ROOT: /mnt/c/wsl/software/android-ndk-r25c/
strip remove old build
build dir: /home/stayua01/code/mperf/build-arm64-v8a/
build ARCH: arm64-v8a
build ABI: arm64-v8a
build native level: 21
BUILD MAKEFILE_TYPE: Ninja
cmake install prefix: /usr/local
create build dir
CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeOutput.log".

So, I install ninja-build: sudo apt install ninja-build.

$ ./android_build.sh -g mali
the SRC_DIR val is /home/stayua01/code/mperf
build with gpu:mali
NDK_ROOT: /mnt/c/wsl/software/android-ndk-r25c/
strip remove old build
build dir: /home/stayua01/code/mperf/build-arm64-v8a/
build ARCH: arm64-v8a
build ABI: arm64-v8a
build native level: 21
BUILD MAKEFILE_TYPE: Ninja
cmake install prefix: /usr/local
create build dir
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is unknown
-- Found assembler: /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - broken
CMake Error at /home/stayua01/software/miniconda3/lib/python3.9/site-packages/cmake/data/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/ninja cmTC_71f46 && [1/2] Building C object CMakeFiles/cmTC_71f46.dir/testCCompiler.c.o
    FAILED: CMakeFiles/cmTC_71f46.dir/testCCompiler.c.o
    /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang   -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -o CMakeFiles/cmTC_71f46.dir/testCCompiler.c.o -c /home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeTmp/testCCompiler.c
    /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: 1: clang-14: not found
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)

-- Configuring incomplete, errors occurred!
See also "/home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeOutput.log".
See also "/home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeError.log".

More infos:

$ cat  /home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeOutput.log
The target system is: Android - 1 - aarch64
The host system is: Linux - 5.10.102.1-microsoft-standard-WSL2 - x86_64

$ cat /home/stayua01/code/mperf/build-arm64-v8a/CMakeFiles/CMakeError.log                                                                                               Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.                                                                                                                                 Compiler: /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang                                                                                                                   Build flags: -g;-DANDROID;-fdata-sections;-ffunction-sections;-funwind-tables;-fstack-protector-strong;-no-canonical-prefixes;-D_FORTIFY_SOURCE=2;-Wformat;-Werror=format-security;                              Id flags: -c;--target=aarch64-none-linux-android21                                                                                                                                                                                                                                                                                                                                                                                The output was:                                                                                                                                                                                                  127
/mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: 1: clang-14: not found

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
Build flags: -g;-DANDROID;-fdata-sections;-ffunction-sections;-funwind-tables;-fstack-protector-strong;-no-canonical-prefixes;-D_FORTIFY_SOURCE=2;-Wformat;-Werror=format-security;
Id flags:

The output was:
127
/mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: 1: clang-14: not found

However, I can find clang:

(base) stayua01@100013000760:~/code/mperf$ ls /mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
/mnt/c/wsl/software/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
youzhedian commented 1 year ago

thanks for the bug report, we will fix it ASAP.

youzhedian commented 1 year ago

我在开发机上 ndk r25c ubuntu20.04 在最新的master上编译是ok的: image

但你是在WSL的ubuntu虚拟机里面,不清楚为什么会引入报错(看上面的报错日志,可能是软链关系就不对,clang软链没有找到clang-14),你方便更换一个非虚拟机的ubuntu环境吗?

ysh329 commented 1 year ago

我这里还没非WSL环境,看起来确实是环境的问题,另外是我自己解压的NDK,没改动,根据报错看起来像是软连接,因而删了clang,搞了个软连接到clang-14,但是发现:

  1. 错误从 Run Build Command(s):/usr/bin/ninja cmTC_71f46 && [1/2]
  2. 变为: Run Build Command(s):/usr/bin/ninja cmTC_71f46 && [2/2]

我再试试搞个其他环境

youzhedian commented 1 year ago

我们也在wsl环境中尝试了一下,应该是wsl对unzip支持的不好,导致在wsl环境中unzip解压出来的android_ndk中软链接关系都无了,试验了可以在wsl之外的环境使用unzip解压android_ndk再mount到wsl环境中(另,还发现unzip之后用tar打包,在wsl环境中用tar解压缩也是不破坏软链接关系的)

ysh329 commented 1 year ago

Fixed. After NDK download, unzip in WSL enviroment.