Created attachment 8881 [details] tls.h patch for the reported issue This error only shows up on x86 Android compiles: CC networking/tls_pstm_montgomery_reduce.o networking/tls_pstm_montgomery_reduce.c: In function 'pstm_montgomery_reduce': networking/tls_pstm_montgomery_reduce.c:66:1: error: 'asm' operand has impossible constraints asm( \ ^ networking/tls_pstm_montgomery_reduce.c:385:4: note: in expansion of macro 'INNERMUL' INNERMUL; ^ make[1]: *** [scripts/Makefile.build:198: networking/tls_pstm_montgomery_reduce.o] Error 1 make: *** [Makefile:744: networking] Error 2 But can be resolved by patching around the ASM code in question, which was intended for Linux i386, not Android x86. Patch attached.
THe asm code should be valid for Android i386 as well. Investigate what does it dislike about #define INNERMUL \ asm( \ "movl %5,%%eax \n\t" \ "mull %4 \n\t" \ "addl %1,%%eax \n\t" \ "adcl $0,%%edx \n\t" \ "addl %%eax,%0 \n\t" \ "adcl $0,%%edx \n\t" \ "movl %%edx,%1 \n\t" \ :"=g"(_c[LO]), "=r"(cy) \ :"0"(_c[LO]), "1"(cy), "g"(mu), "g"(*tmpm++) \ : "%eax", "%edx", "cc")
Sorry, I have no idea how to investigate that.. I do know it appears to build and work fine if we just patch around it as proposed. I'll be happy to try any commands or anything you can supply to dig into it further.
Replace INNERMUL define with this one: #define INNERMUL \ asm( \ "mull %4 \n\t" \ "addl %3,%%eax \n\t" \ "adcl $0,%%edx \n\t" \ "addl %%eax,%0 \n\t" \ "adcl $0,%%edx \n\t" \ :"=g"(_c[LO]), "=&d"(cy) \ :"0"(_c[LO]), "g"(cy), "g"(mu), "a"(*tmpm++) \ :"cc") and see whether it compiles.
That compiled with no errors!
Fixed in git, please confirm.
Cherry-picked your 2 TLS commits into 1.32.1 and it build with Android x86 NDK perfectly! Thanks for your effort figuring this one out Denys!
While your fix worked great on NDK gcc to compile for Android x86, I've just discovered it unfortunately still breaks compiles with NDK clang which has completely replaced gcc (i.e. gcc is removed) since NDK r18b (Sept 2018). [...] ./obj/local/x86/objs/busybox/util-linux/volume_id/volume_id.o ./obj/local/x86/objs/busybox/util-linux/volume_id/xfs.o ./obj/local/x86/libselinux.a ./obj/local/x86/libpcre2.a --build-id --no-undefined -z noexecstack --warn-shared-textrel --fatal-warnings -lc -lm -lstdc++ -lm --start-group -lgcc -lc --end-group "G:/android/android-ndk-r20b/build//../toolchains/llvm/prebuilt/windows/bin/../sysroot/usr/lib/i686-linux-android/21\\crtend_android.o" G:/android/android-ndk-r20b/build//../toolchains/llvm/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: fatal error: LLVM gold plugin: inline assembly requires more registers than available at line 2148562311 clang++: error: linker command failed with exit code 1 Avoiding the problematic ASM code as I had previously done still does successfully allow it to compile, so despite the vague linker error I have confirmed it's the same issue. Any way to reduce register pressure further so clang-built busybox can have this corrected as well? Thanks again for your time looking into this and everything!
(In reply to Chris Renshaw from comment #7) > While your fix worked great on NDK gcc to compile for Android x86, I've just discovered it unfortunately still breaks compiles with NDK clang which has completely replaced gcc (i.e. gcc is removed) since NDK r18b (Sept 2018). > [...] ./obj/local/x86/objs/busybox/util-linux/volume_id/volume_id.o ./obj/local/x86/objs/busybox/util-linux/volume_id/xfs.o ./obj/local/x86/libselinux.a ./obj/local/x86/libpcre2.a --build-id --no-undefined -z noexecstack --warn-shared-textrel --fatal-warnings -lc -lm -lstdc++ -lm --start-group -lgcc -lc --end-group "G:/android/android-ndk-r20b/build//../toolchains/llvm/prebuilt/windows/bin/../sysroot/usr/lib/i686-linux-android/21\\crtend_android.o" G:/android/android-ndk-r20b/build//../toolchains/llvm/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin\ld: fatal error: LLVM gold plugin: inline assembly requires more registers than available at line 2148562311 Which exactly asm statement fails to compile?
I was avoiding all the ASM with the following: diff --git a/networking/tls.h b/networking/tls.h index d4ac1bef8..07032477e 100644 --- a/networking/tls.h +++ b/networking/tls.h @@ -26,7 +26,7 @@ #undef USE_SEED /* pstm: multiprecision numbers */ #undef DISABLE_PSTM -#if defined(__GNUC__) && defined(__i386__) +#if defined(__GNUC__) && defined(__i386__) && !defined(__ANDROID__) /* PSTM_X86 works correctly. +25 bytes. */ # define PSTM_32BIT # define PSTM_X86 Not sure how to avoid specific ASM statements and still ensure it'll overall compile. Do I simply comment out one define at a time in the montgomery and comba files?
(In reply to Chris Renshaw from comment #7) > While your fix worked great on NDK gcc to compile for Android x86, I've just discovered it unfortunately still breaks compiles with NDK clang which has completely replaced gcc (i.e. gcc is removed) since NDK r18b (Sept 2018). I suggest opening a bug against clang. They have to fix it anyway, this should be affecting many other valid programs.
Resolved on latest NDK!