用cmake构建AndroidManifest同级目录下的项目后(使用Ninja构建)
在CMakeFiles/main.dir/build.make
下找到编译命令:
09:37:06 ztn@ztn-laptop2 app ±|master ✗|→ tree CMakeFiles
CMakeFiles
├── 3.22.1
│ ├── CMakeCCompiler.cmake
│ ├── CMakeCXXCompiler.cmake
│ ├── CMakeDetermineCompilerABI_C.bin
│ ├── CMakeDetermineCompilerABI_CXX.bin
│ └── CMakeSystem.cmake
├── cmake.check_cache
├── CMakeDirectoryInformation.cmake
├── CMakeOutput.log
├── CMakeTmp
├── main.dir
│ ├── build.make
│ ├── cmake_clean.cmake
│ ├── compiler_depend.make
│ ├── compiler_depend.ts
│ ├── DependInfo.cmake
│ ├── depend.make
│ ├── flags.make
│ ├── link.txt
│ ├── progress.make
│ └── src
│ └── main
│ └── cpp
│ ├── main.cpp.o
│ └── main.cpp.o.d
├── Makefile2
├── Makefile.cmake
├── progress.marks
└── TargetDirectories.txt
6 directories, 23 files
09:37:17 ztn@ztn-laptop2 app ±|master ✗|→
CMakeFiles/main.dir/src/main/cpp/main.cpp.o: CMakeFiles/main.dir/flags.make
CMakeFiles/main.dir/src/main/cpp/main.cpp.o: src/main/cpp/main.cpp
CMakeFiles/main.dir/src/main/cpp/main.cpp.o: CMakeFiles/main.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/ztn/androidffmpeg5.0-demo/app/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/main.dir/src/main/cpp/main.cpp.o"
/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -MD -MT CMakeFiles/main.dir/src/main/cpp/main.cpp.o -MF CMakeFiles/main.dir/src/main/cpp/main.cpp.o.d -o CMakeFiles/main.dir/src/main/cpp/main.cpp.o -c /home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp
CMakeFiles/main.dir/src/main/cpp/main.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/main.dir/src/main/cpp/main.cpp.i"
/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp > CMakeFiles/main.dir/src/main/cpp/main.cpp.i
CMakeFiles/main.dir/src/main/cpp/main.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/main.dir/src/main/cpp/main.cpp.s"
/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp -o CMakeFiles/main.dir/src/main/cpp/main.cpp.s
提取后并采用 -###
参数查看clang具体命令
09:24:38 ztn@ztn-laptop2 app ±|master ✗|→ /home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot $CXX_DEFINES $CXX_INCLUDES $CXX_FLAGS -MD -MT CMakeFiles/main.dir/src/main/cpp/main.cpp.o -MF CMakeFiles/main.dir/src/main/cpp/main.cpp.o.d -o CMakeFiles/main.dir/src/main/cpp/main.cpp.o -c /home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp -###
Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn)
Target: aarch64-none-linux-android21
Thread model: posix
InstalledDir: /home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin
"/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++" "-cc1" "-triple" "aarch64-none-linux-android21" "-emit-obj" "-mrelax-all" "-mnoexecstack" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "generic" "-target-feature" "+neon" "-target-abi" "aapcs" "-mllvm" "-aarch64-fix-cortex-a53-835769=1" "-fallow-half-arguments-and-returns" "-dwarf-column-info" "-debug-info-kind=limited" "-dwarf-version=4" "-debugger-tuning=gdb" "-ffunction-sections" "-fdata-sections" "-coverage-notes-file" "/home/ztn/androidffmpeg5.0-demo/app/CMakeFiles/main.dir/src/main/cpp/main.cpp.gcno" "-resource-dir" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9" "-dependency-file" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o.d" "-sys-header-deps" "-MT" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-D" "main_EXPORTS" "-I" "/home/ztn/androidffmpeg5.0-demo/app/soLib/arm64-v8a/include" "-D" "ANDROID" "-D" "_FORTIFY_SOURCE=2" "-isysroot" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include" "-Wformat" "-Werror=format-security" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/ztn/androidffmpeg5.0-demo/app" "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "2" "-fno-signed-char" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-x" "c++" "/home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp"
09:24:49 ztn@ztn-laptop2 app ±|master ✗|→ "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++" "-cc1" "-triple" "aarch64-none-linux-android21" "-emit-obj" "-mrelax-all" "-mnoexecstack" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "generic" "-target-feature" "+neon" "-target-abi" "aapcs" "-mllvm" "-aarch64-fix-cortex-a53-835769=1" "-fallow-half-arguments-and-returns" "-dwarf-column-info" "-debug-info-kind=limited" "-dwarf-version=4" "-debugger-tuning=gdb" "-ffunction-sections" "-fdata-sections" "-coverage-notes-file" "/home/ztn/androidffmpeg5.0-demo/app/CMakeFiles/main.dir/src/main/cpp/main.cpp.gcno" "-resource-dir" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9" "-dependency-file" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o.d" "-sys-header-deps" "-MT" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-D" "main_EXPORTS" "-I" "/home/ztn/androidffmpeg5.0-demo/app/soLib/arm64-v8a/include" "-D" "ANDROID" "-D" "_FORTIFY_SOURCE=2" "-isysroot" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include" "-Wformat" "-Werror=format-security" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/ztn/androidffmpeg5.0-demo/app" "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "2" "-fno-signed-char" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-x" "c++" "/home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp"
09:24:56 ztn@ztn-laptop2 app ±|master ✗|→ clang++ "-cc1" "-triple" "aarch64-none-linux-android21" "-emit-obj" "-mrelax-all" "-mnoexecstack" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "generic" "-target-feature" "+neon" "-target-abi" "aapcs" "-mllvm" "-aarch64-fix-cortex-a53-835769=1" "-fallow-half-arguments-and-returns" "-dwarf-column-info" "-debug-info-kind=limited" "-dwarf-version=4" "-debugger-tuning=gdb" "-ffunction-sections" "-fdata-sections" "-coverage-notes-file" "/home/ztn/androidffmpeg5.0-demo/app/CMakeFiles/main.dir/src/main/cpp/main.cpp.gcno" "-resource-dir" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9" "-dependency-file" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o.d" "-sys-header-deps" "-MT" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-D" "main_EXPORTS" "-I" "/home/ztn/androidffmpeg5.0-demo/app/soLib/arm64-v8a/include" "-D" "ANDROID" "-D" "_FORTIFY_SOURCE=2" "-isysroot" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include" "-internal-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.9/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include" "-internal-externc-isystem" "/home/ztn/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include" "-Wformat" "-Werror=format-security" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/ztn/androidffmpeg5.0-demo/app" "-ferror-limit" "19" "-fmessage-length" "0" "-stack-protector" "2" "-fno-signed-char" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "CMakeFiles/main.dir/src/main/cpp/main.cpp.o" "-x" "c++" "/home/ztn/androidffmpeg5.0-demo/app/src/main/cpp/main.cpp"
error: unknown argument: '-mdisable-fp-elim'
error: unknown argument: '-masm-verbose'
error: unknown argument: '-munwind-tables'
error: unknown argument: '-fuse-init-array'
error: unknown argument: '-dwarf-column-info'
error: unknown argument: '-fmessage-length'
error: unknown argument: '-fdiagnostics-show-option'
09:25:11 ztn@ztn-laptop2 app ±|master ✗|→
可以看到,从官网下载的LLVM-CLANG工具链没有一些由NDK中clang工具链支持的编译器选项,故谷歌NDK是修改过的一条工具链,不过LLVM main stream 貌似直接支持 arm-cortex-m
这里是具体规格和信息
Supported Devices
LLVM Toolchain Technical-Specifications