使用android-ndk独立工具链

时间:2017-12-22 09:00:25

标签: c android-ndk llvm-clang toolchain ndk-build

我正在使用NDK独立工具链在Mac OS上构建动态库(.so)。

我只是将C语言编译器从GCC迁移到clang。当使用GCC时,进程都正常,因此文件生成成功。但是当使用clang时,在发出./configure问题时会发生一些错误。错误如下。

图片错误日志:

configure errors

文本错误日志,与上面的图片错误日志相同:

check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
    1   .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
/var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S:1:1: error: unknown directive
.altmacro
^
check_gas using 'arm-linux-androideabi-clang' as AS
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
    1   .macro m n, y:vararg=0
    2   \n: .int \y
    3   .endm
    4   m x
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
    1   .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
arm-linux-androideabi-clang -D_ISOC99_SOURCE -Dstrtod=avpriv_strtod -I$(SRC_PATH)/compat/float -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.DIksqWpw.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
/var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.t5WIvSJ0.S:1:1: error: unknown directive
.altmacro
^
GNU assembler not found, install/update gas-preprocessor

配置文件中的工具链配置:

  # toolchain
  ar_default="ar"
  cc_default="clang"
  cxx_default="clang++"
  host_cc_default="clang"
  cp_f="cp -f"
  doxygen_default="doxygen"
  install="install"
  ln_s_default="ln -s -f"
  nm_default="nm -g"
  objformat="elf"
  pkg_config_default=pkg-config
  ranlib_default="ranlib"
  strip_default="strip"
  version_script='--version-script'
  yasmexe_default="yasm"
  windres_default="windres"

NDK版本是r14b,而clang版本是:

  Android clang version 3.8.275480  (based on LLVM 3.8.275480)
  Target: x86_64-apple-darwin17.2.0
  Thread model: posix

我知道错误不是由“gas-preprocessor”引起的,因为GCC编译器也有这个问题.GCC记录没有错误:

check_cc
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
    1   unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -std=c11 -fomit-frame-pointer -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.51pLIKDT.c
gas-preprocessor.pl -arch arm -as-type gas -- arm-linux-androideabi-gcc -v
./configure: line 883: gas-preprocessor.pl: command not found
check_gas using 'arm-linux-androideabi-gcc' as AS
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
    1   .macro m n, y:vararg=0
    2   \n: .int \y
    3   .endm
    4   m x
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
check_as
BEGIN /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
    1   .altmacro
END /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S
arm-linux-androideabi-gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -O3 -Wall -pipe -std=c99 -ffast-math -fstrict-aliasing -Werror=strict-aliasing -Wno-psabi -Wa,--noexecstack -DANDROID -DNDEBUG -I/Users/zexu/github/ijkplayer/android/contrib/build/openssl-armv7a/output/include -march=armv7-a -mcpu=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -mthumb -mcpu=cortex-a8 -fPIC -c -o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.bcyz1Buv.o /var/folders/k6/bsgr75lj6j99fl0q8ygrr7840000gn/T//ffconf.QeTKRayl.S

任何人都可以给我一些提示吗?

1 个答案:

答案 0 :(得分:1)

从GCC切换到Clang时汇编程序的问题通常用-fno-integrated-as修复。 Clang有一个内置的汇编程序,它用于组装生成代码,与GNU的汇编程序不是100%兼容。如果您有任何内联汇编,您将需要更新该汇编以与LLVM的汇编程序兼容,或者传递-fno-integrated-as以指示Clang使用GNU作为替代。