/usr/bin/aarch64-linux-gnu-as:无效选项 -- 'B'

/usr/bin/aarch64-linux-gnu-as:无效选项 -- 'B'

我正在尝试交叉编译这个代码使用 aarch64 编译器,我收到此错误:

/usr/bin/aarch64-linux-gnu-as: invalid option -- 'B'
make[2]: *** [third_party/boringssl-with-bazel/CMakeFiles/crypto.dir/build.make:63: third_party/boringssl-with-bazel/CMakeFiles/crypto.dir/linux-aarch64/crypto/chacha/chacha-armv8.S.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3931: third_party/boringssl-with-bazel/CMakeFiles/crypto.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

该 build.make 文件的第 63 行是:

cd /home/a/Documents/third_party/grpc/build_arm/third_party/boringssl-with-bazel && /usr/bin/aarch64-linux-gnu-as $(ASM_DEFINES) $(ASM_INCLUDES) $(ASM_FLAGS) -o CMakeFiles/crypto.dir/linux-aarch64/crypto/chacha/chacha-armv8.S.o -c /home/a/Documents/third_party/grpc/third_party/boringssl-with-bazel/linux-aarch64/crypto/chacha/chacha-armv8.S

我的工具链.cmake 是:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(TARGET_ABI "linux-gnu")
# specify the cross compiler
SET(CMAKE_C_COMPILER   aarch64-${TARGET_ABI}-gcc)
SET(CMAKE_CXX_COMPILER aarch64-${TARGET_ABI}-g++)

# To build the tests, we need to set where the target environment containing
# the required library is. On Debian-like systems, this is
# /usr/aarch64-linux-gnu.
SET(CMAKE_FIND_ROOT_PATH "/usr/aarch64-${TARGET_ABI}")
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# Set additional variables.
# If we don't set some of these, CMake will end up using the host version.
# We want the full path, however, so we can pass EXISTS and other checks in
# the our CMake code.
find_program(GCC_FULL_PATH aarch64-${TARGET_ABI}-gcc)
if (NOT GCC_FULL_PATH)
  message(FATAL_ERROR "Cross-compiler aarch64-${TARGET_ABI}-gcc not found")
endif ()
get_filename_component(GCC_DIR ${GCC_FULL_PATH} PATH)
SET(CMAKE_LINKER       ${GCC_DIR}/aarch64-${TARGET_ABI}-ld      CACHE FILEPATH "linker")
SET(CMAKE_ASM_COMPILER ${GCC_DIR}/aarch64-${TARGET_ABI}-as      CACHE FILEPATH "assembler")
SET(CMAKE_OBJCOPY      ${GCC_DIR}/aarch64-${TARGET_ABI}-objcopy CACHE FILEPATH "objcopy")
SET(CMAKE_STRIP        ${GCC_DIR}/aarch64-${TARGET_ABI}-strip   CACHE FILEPATH "strip")
SET(CMAKE_CPP          ${GCC_DIR}/aarch64-${TARGET_ABI}-cpp     CACHE FILEPATH "cpp")

这是什么错误?

答案1

当编译器找不到as.

我通过运行strace g++和分析输出找到了它。

你可以运行as目标平台(即你的情况下的arm)吗?

相关内容