使用 android-ndk 独立工具链时发生未知指令 .altmacro 错误
Unknown directive .altmacro error happens when using android-ndk standalone toolchain
我正在使用 NDK 独立工具链在 Mac OS.
上构建动态库 (.so)
我只是将 C 语言编译器从 GCC 迁移到 clang.When 使用 GCC 过程都正常,因此文件生成成功。但是当使用 clang 时,当 issue ./configure.The 错误如下时会发生一些错误。
图片错误日志:
文本错误日志,与上图错误日志相同:
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 编译器也有这个 problem.The 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
谁能给我一些提示?
从 GCC 切换到 Clang 时的汇编程序问题通常已通过 -fno-integrated-as
修复。 Clang 有一个内置的汇编器,它用于汇编生成的代码,该代码与 GNU 的汇编器不是 100% 兼容。如果您有任何内联程序集,您将需要更新该程序集以与 LLVM 的汇编程序兼容,或者传递 -fno-integrated-as
以指示 Clang 改用 GNU。
我正在使用 NDK 独立工具链在 Mac OS.
上构建动态库 (.so)我只是将 C 语言编译器从 GCC 迁移到 clang.When 使用 GCC 过程都正常,因此文件生成成功。但是当使用 clang 时,当 issue ./configure.The 错误如下时会发生一些错误。
图片错误日志:
文本错误日志,与上图错误日志相同:
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 编译器也有这个 problem.The 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
谁能给我一些提示?
从 GCC 切换到 Clang 时的汇编程序问题通常已通过 -fno-integrated-as
修复。 Clang 有一个内置的汇编器,它用于汇编生成的代码,该代码与 GNU 的汇编器不是 100% 兼容。如果您有任何内联程序集,您将需要更新该程序集以与 LLVM 的汇编程序兼容,或者传递 -fno-integrated-as
以指示 Clang 改用 GNU。