Hi,
I've been building nettle with Clang from a generated toolchain with the latest Android NDK (16b).
Form architecture with available assembler code (x86 in particular), compilation fails because the generated asm is not compatible with clang. So I use --disable-assembler, thinking it would fix the problem. But it still fails (see log below):
The workaround has been to entirely disable (comment) the asm rule in Makefile.in:
#.asm.$(OBJEXT): $(srcdir)/asm.m4 machine.m4 config.m4 # $(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$*.s # $(COMPILE) -c $*.s # @echo "$@ : $< $(srcdir)/asm.m4 machine.m4 config.m4" >$@.d
For some reason, this rule generates asm files even when --disable-assembler is specified and it gets in the way later in the build.
The proper fix would be to make sure this rule never kicks in with --disable-assembler. And also maybe force --disable-assembler when clang is the compiler, or update the asm generation macro (asm.m4) to produce .s files compatible with clang.
/////////
Version: nettle 3.4 Host type: x86-unknown-none ABI: standard Assembly files: none Install prefix: /home/bobbie/ffmpeg-android-3.4.1/toolchain-android Library directory: ${exec_prefix}/lib Compiler: /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot Static libraries: yes Shared libraries: no Public key crypto: yes Using mini-gmp: no Documentation: no
make install-here make[1]: Entering directory `/home/bobbie/ffmpeg-android-3.4.1/nettle-3.4' /bin/mkdir -p /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include/nettle /usr/bin/m4 ./asm.m4 machine.m4 config.m4 aes-decrypt-internal.asm
aes-decrypt-internal.s
/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-decrypt.o -MD -MP -MF aes-decrypt.o.d -c aes-decrypt.c \ && true for f in aes.h arcfour.h arctwo.h asn1.h blowfish.h base16.h base64.h bignum.h buffer.h camellia.h cast128.h cbc.h ccm.h cfb.h chacha.h chacha-poly1305.h ctr.h curve25519.h des.h des-compat.h dsa.h dsa-compat.h eax.h ecc-curve.h ecc.h ecdsa.h eddsa.h gcm.h gosthash94.h hmac.h knuth-lfib.h hkdf.h macros.h md2.h md4.h md5.h md5-compat.h memops.h memxor.h nettle-meta.h nettle-types.h pbkdf2.h pgp.h pkcs1.h pss.h pss-mgf1.h realloc.h ripemd160.h rsa.h salsa20.h sexp.h serpent.h sha.h sha1.h sha2.h sha3.h twofish.h umac.h yarrow.h poly1305.h nettle-stdint.h version.h ; do \ if [ -f "$f" ] ; then \ /usr/bin/install -c -m 644 "$f" /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include/nettle ; \ else \ /usr/bin/install -c -m 644 "./$f" /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include/nettle ; \ fi ; done /usr/bin/m4 ./asm.m4 machine.m4 config.m4 aes-encrypt-internal.asm
aes-encrypt-internal.s
/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-encrypt.o -MD -MP -MF aes-encrypt.o.d -c aes-encrypt.c \ && true /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-encrypt-table.o -MD -MP -MF aes-encrypt-table.o.d -c aes-encrypt-table.c \ && true /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-invert-internal.o -MD -MP -MF aes-invert-internal.o.d -c aes-invert-internal.c \ && true /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-set-key-internal.o -MD -MP -MF aes-set-key-internal.o.d -c aes-set-key-internal.c \ && true /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-decrypt-internal.o -MD -MP -MF aes-decrypt-internal.o.d -c aes-decrypt-internal.s /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-encrypt-internal.o -MD -MP -MF aes-encrypt-internal.o.d -c aes-encrypt-internal.s /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-set-encrypt-key.o -MD -MP -MF aes-set-encrypt-key.o.d -c aes-set-encrypt-key.c \ && true clang50/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes-set-decrypt-key.o -MD -MP -MF aes-set-decrypt-key.o.d -c aes-set-decrypt-key.c \ && true /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes128-set-encrypt-key.o -MD -MP -MF aes128-set-encrypt-key.o.d -c aes128-set-encrypt-key.c \ && true : warning: argument unused during compilation: '-D __ANDROID_API__=14' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-D HAVE_CONFIG_H' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MT aes-decrypt-internal.o' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MD' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MP' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MF aes-decrypt-internal.o.d' [-Wunused-command-line-argument] aes-decrypt-internal.s:67:10: error: unknown token in expression teq r3, #0 ^ aes-decrypt-internal.s:68:2: error: invalid instruction mnemonic 'beq' beq .Lend ^~~ aes-decrypt-internal.s:70:7: error: Unexpected '{' in expression push {r0,r1,r3, r4,r5,r6,r7,r8,r10,r11,lr} ^ clang50: warning: argument unused during compilation: '-D __ANDROID_API__=14' [-Wunused-command-line-argument] /home/bobbie/ffmpeg-android-3.4.1/toolchain-android/bin/i686-linux-android-clang --sysroot=/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/sysroot -I. -DHAVE_CONFIG_H -I/home/bobbie/ffmpeg-android-3.4.1/toolchain-android/include -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wpointer-arith -Wbad-function-cast -Wnested-externs -fpic -MT aes128-set-decrypt-key.o -MD -MP -MF aes128-set-decrypt-key.o.d -c aes128-set-decrypt-key.c \ && true clang50: warning: argument unused during compilation: '-D HAVE_CONFIG_H' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MT aes-encrypt-internal.o' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MD' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MP' [-Wunused-command-line-argument] clang50: warning: argument unused during compilation: '-MF aes-encrypt-internal.o.d' [-Wunused-command-line-argument] aes-decrypt-internal.s:71:10: error: unknown token in expression mov r0, #0x3fc ^ aes-decrypt-internal.s:75:13: error: expected ']' in brackets expression ldr r1, [sp, #+48] ^ aes-decrypt-internal.s:76:10: error: Unexpected '{' in expression ldm sp, {r10, r11} ^ aes-decrypt-internal.s:79:17: error: unknown token in expression ldrb r4, [r1], #+1
On Thu, 4 Jan 2018, blargh wrote:
Hi,
I've been building nettle with Clang from a generated toolchain with the latest Android NDK (16b).
Form architecture with available assembler code (x86 in particular), compilation fails because the generated asm is not compatible with clang. So I use --disable-assembler, thinking it would fix the problem. But it still fails (see log below):
The workaround has been to entirely disable (comment) the asm rule in Makefile.in:
#.asm.$(OBJEXT): $(srcdir)/asm.m4 machine.m4 config.m4 # $(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$*.s # $(COMPILE) -c $*.s # @echo "$@ : $< $(srcdir)/asm.m4 machine.m4 config.m4" >$@.d
For some reason, this rule generates asm files even when --disable-assembler is specified and it gets in the way later in the build.
The proper fix would be to make sure this rule never kicks in with --disable-assembler. And also maybe force --disable-assembler when clang is the compiler, or update the asm generation macro (asm.m4) to produce .s files compatible with clang.
The error messages you quoted below show an attempt of assembling arm assembly when targeting i686. This sounds like a case of not running "make distclean" in the nettle source repo before reconfiguring for a different target.
Once you've cleaned the build tree properly, you could maybe retry even without the hacks and without --disable-assembler to see if it works even without that.
// Martin
Thanks, you were right:
Using 'make distclean' fixes it. As you guessed, I was building for several archs and did just 'make clean' between builds.
I removed --disable-assembler and it compiled for x86. Although the assembler was not picked up. It turns out it is due to the host (from configure output):
... checking host system type... x86-unknown-none ...
This host type is not covered in configure.ac:
asm_path= if test "x$enable_assembler" = xyes ; then case "$host_cpu" in [i?86* | k[5-8]* | pentium* | athlon]) asm_path=x86 ;;
Adding x86-* fixed it:
asm_path= if test "x$enable_assembler" = xyes ; then case "$host_cpu" in [i?86* | k[5-8]* | pentium* | athlon | x86]) asm_path=x86 ;;
After this change nettle compiles fine with clang targeting x86 for Android, with asm.
On 04/01/2018 15:55, Martin Storsjö wrote:
On Thu, 4 Jan 2018, blargh wrote:
Hi,
I've been building nettle with Clang from a generated toolchain with the latest Android NDK (16b).
Form architecture with available assembler code (x86 in particular), compilation fails because the generated asm is not compatible with clang. So I use --disable-assembler, thinking it would fix the problem. But it still fails (see log below):
The workaround has been to entirely disable (comment) the asm rule in Makefile.in:
#.asm.$(OBJEXT): $(srcdir)/asm.m4 machine.m4 config.m4 # $(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$*.s # $(COMPILE) -c $*.s # @echo "$@ : $< $(srcdir)/asm.m4 machine.m4 config.m4" >$@.d
For some reason, this rule generates asm files even when --disable-assembler is specified and it gets in the way later in the build.
The proper fix would be to make sure this rule never kicks in with --disable-assembler. And also maybe force --disable-assembler when clang is the compiler, or update the asm generation macro (asm.m4) to produce .s files compatible with clang.
The error messages you quoted below show an attempt of assembling arm assembly when targeting i686. This sounds like a case of not running "make distclean" in the nettle source repo before reconfiguring for a different target.
Once you've cleaned the build tree properly, you could maybe retry even without the hacks and without --disable-assembler to see if it works even without that.
// Martin
On 04/01/2018 15:55, Martin Storsjö wrote:
On Thu, 4 Jan 2018, blargh wrote:
Hi,
I've been building nettle with Clang from a generated toolchain with the latest Android NDK (16b).
Form architecture with available assembler code (x86 in particular), compilation fails because the generated asm is not compatible with clang. So I use --disable-assembler, thinking it would fix the problem. But it still fails (see log below):
The workaround has been to entirely disable (comment) the asm rule in Makefile.in:
#.asm.$(OBJEXT): $(srcdir)/asm.m4 machine.m4 config.m4 # $(M4) $(srcdir)/asm.m4 machine.m4 config.m4 $< >$*.s # $(COMPILE) -c $*.s # @echo "$@ : $< $(srcdir)/asm.m4 machine.m4 config.m4" >$@.d
For some reason, this rule generates asm files even when --disable-assembler is specified and it gets in the way later in the build.
The proper fix would be to make sure this rule never kicks in with --disable-assembler. And also maybe force --disable-assembler when clang is the compiler, or update the asm generation macro (asm.m4) to produce .s files compatible with clang.
The error messages you quoted below show an attempt of assembling arm assembly when targeting i686. This sounds like a case of not running "make distclean" in the nettle source repo before reconfiguring for a different target.
Once you've cleaned the build tree properly, you could maybe retry even without the hacks and without --disable-assembler to see if it works even without that.
// Martin
blargh youp1one1@gmail.com writes:
Adding x86-* fixed it:
asm_path= if test "x$enable_assembler" = xyes ; then case "$host_cpu" in [i?86* | k[5-8]* | pentium* | athlon | x86]) asm_path=x86 ;;
Done, except that I added it at the front.
Did I understand you correctly, that this was needed for x86 android builds?
When building for multiple platforms, I recommend using a separate build directory per platform.
Regards, /Niels
nettle-bugs@lists.lysator.liu.se