Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Execution build: card.io-Android-source/card.io/src/main/obj/local/armeabi-v7a/objs/cardioRecognizer_tegra2/card.io-dmz/dmz_all.o] Error 1 #60

Closed
budikurniawan7 opened this issue Mar 17, 2016 · 9 comments

Comments

@budikurniawan7
Copy link

I have followed your steps in first build, but when I executed, I got these error:

/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-18fe4c.s: Assembler messages:
/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-18fe4c.s:38966: Error: r13 not allowed here -- sub.w sp,r2,#832' /var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-18fe4c.s:41459: Error: r13 not allowed here --sub.w sp,r2,#1296'
/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-18fe4c.s:41573: Error: r13 not allowed here -- sub.w sp,r2,#144' clang++: error: assembler command failed with exit code 1 (use -v to see invocation) make: *** [/Users/budi/Documents/card.io-Android-source/card.io/src/main/obj/local/armeabi-v7a/objs/cardioRecognizer_tegra2/card.io-dmz/dmz_all.o] Error 1 make: *** Waiting for unfinished jobs.... /var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s: Assembler messages: /var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:65504: Error: r13 not allowed here --sub.w sp,r2,#832'
/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:71284: Error: r13 not allowed here -- sub.w sp,r2,#1296' /var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:71398: Error: r13 not allowed here --sub.w sp,r2,#144'
/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:91752: Error: r13 not allowed here -- sub.w sp,r2,#720' /var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:97277: Error: r13 not allowed here --sub.w sp,r2,#496'
/var/folders/fy/2_ssmh6d7fqb96jqx_hy8c5w0000gp/T/dmz_all-4cd441.s:97391: Error: r13 not allowed here -- `sub.w sp,r2,#720'
clang++: error: assembler command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/budi/Documents/card.io-Android-source/card.io/src/main/obj/local/armeabi-v7a/objs/cardioRecognizer/card.io-dmz/dmz_all.o] Error 1
:card.io:buildNative FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':card.io:buildNative'.

    Process 'command '/Users/budi/Documents/android-sdk-macosx/ndk-bundle/ndk-build'' finished with non-zero exit value 2

The error occurred when I used latest Android SDK, before I updated Android SDK, the error did not occur.
what should i do to fix the error? Thank you so much for your help.

@braebot
Copy link
Member

braebot commented Mar 17, 2016

What ndk are you using? You mentioned it worked before - what version did you upgrade from? I saw this error before when adding 64 bit support. Be sure you've updated to the latest dmz submodule, if you've included this module as a submodule itself.

@budikurniawan7
Copy link
Author

I am using NDK rev 11. I just upgraded Android Support Library and Local Maven repository for Support Libraries, after upgrade I got the error. And I have followed your instruction for first build to update dmz submodule.

@giorgioscibilia
Copy link

Same problem here, giving the command " ./gradlew buildNative" results in this error:

[arm64-v8a] Install        : libopencv_core.so => libs/arm64-v8a/libopencv_core.so
/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/jni/card.io-dmz/Eigen/src/Core/util/Memory.h:224: error: undefined reference to 'posix_memalign'
/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/jni/card.io-dmz/Eigen/src/Core/util/Memory.h:224: error: undefined reference to 'posix_memalign'
/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/jni/card.io-dmz/Eigen/src/Core/util/Memory.h:224: error: undefined reference to 'posix_memalign'
/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/jni/card.io-dmz/Eigen/src/Core/util/Memory.h:224: error: undefined reference to 'posix_memalign'
[arm64-v8a] Install        : libopencv_imgproc.so => libs/arm64-v8a/libopencv_imgproc.so
[x86_64] Install        : libcardioDecider.so => libs/x86_64/libcardioDecider.so
[x86_64] Install        : libcardioRecognizer.so => libs/x86_64/libcardioRecognizer.so
[x86_64] Install        : libcardioRecognizer_tegra2.so => libs/x86_64/libcardioRecognizer_tegra2.so
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/obj/local/x86/libcardioRecognizer.so] Error 1
make: *** Waiting for unfinished jobs....
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-110d0b.s: Assembler messages:
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-110d0b.s:38966: Error: r13 not allowed here -- `sub.w sp,r2,#832'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-110d0b.s:41459: Error: r13 not allowed here -- `sub.w sp,r2,#1296'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-110d0b.s:41573: Error: r13 not allowed here -- `sub.w sp,r2,#144'
clang++: error: assembler command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/obj/local/armeabi-v7a/objs/cardioRecognizer_tegra2/card.io-dmz/dmz_all.o] Error 1
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s: Assembler messages:
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:65504: Error: r13 not allowed here -- `sub.w sp,r2,#832'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:71284: Error: r13 not allowed here -- `sub.w sp,r2,#1296'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:71398: Error: r13 not allowed here -- `sub.w sp,r2,#144'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:91752: Error: r13 not allowed here -- `sub.w sp,r2,#720'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:97277: Error: r13 not allowed here -- `sub.w sp,r2,#496'
/var/folders/7r/y8wr2lvd2mq00n7wt2mfdrt80000gn/T/dmz_all-79b4c1.s:97391: Error: r13 not allowed here -- `sub.w sp,r2,#720'
clang++: error: assembler command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/giorgio.scibilia/Documents/Progetti/Sandbox/card.io-Android-source/card.io/src/main/obj/local/armeabi-v7a/objs/cardioRecognizer/card.io-dmz/dmz_all.o] Error 1
:card.io:buildNative FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':card.io:buildNative'.
> Process 'command '/Users/giorgio.scibilia/Library/Android/sdk/ndk-bundle/build/ndk-build'' finished with non-zero exit value 2

I also recently updated to ndk rev11 but I didn't try to build card.io before that.

@braebot
Copy link
Member

braebot commented Mar 22, 2016

Looks like something changed in ndk 11. ndk r10e is the one I've been using. Is it just x86 that's failing? Have you tried removing that processor from Android.mk and building all the other processors?

@budikurniawan7
Copy link
Author

I think x86 and armeabi-v7a made the error, when I removed them I did not get the error. But I need armeabi-v7a since that processor is prolific usage in many devices.

@giorgioscibilia
Copy link

I managed to successfully build ( ./gradlew buildNative runs with no errors) but I had to remove:

  • armeabi-v7a and x86 from libcardioRecognizer.so (neon version)

# --- libcardioRecognizer.so --------------------------------------------------------
# (neon version)

ifeq (1,1)

include $(CLEAR_VARS)
#ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64))
ifneq (,$(filter $(TARGET_ARCH_ABI), arm64-v8a x86_64))
  • armeabi-v7a on libcardioRecognizer.so (neon version)

# build tegra compatible lib
# (no neon, limit to 16 VFP registers)

ifeq (1,1)

include $(CLEAR_VARS)
#ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64))
ifneq (,$(filter $(TARGET_ARCH_ABI),x86 arm64-v8a))

@ChrisZou
Copy link

I ran into this issue too, on Mac.Like @braebot said, it seems to be something wrong with the latest ndk version, r11b. After changing to r10e, it works fine now.

@m-schmoock
Copy link
Contributor

m-schmoock commented Apr 19, 2016

Its not something wrong, its just that a deprecated usage of a destination CPU register has been removed (r13, r15). It still works (on a obsolete basis) by using the old NDK. Register r13 is used as the stackpointer. So the new NDK just requires the stackpointer to be controlled by itself ont not by some inline assembler code.

So we really need to find out which part it is that generates ARM r13/r15 destination register usage and puts it into the dmz_all shared object. Maybe one of the dmz/cv asm volatile(...)instructions.

See: https://sourceware.org/ml/binutils/2010-06/msg00309.html

Update: I tested the asm stuff in the cv directory and the error is not caused by one of them.

@m-schmoock
Copy link
Contributor

m-schmoock commented Apr 20, 2016

The error is located within the complex Eigen header files in the DMZ sub repository.
The macro that creates the bad code is ei_declare_aligned_stack_constructed_variable that is defined in 'Eigen/src/Core/util/Memory.h:580'. The actual call of the macro that causes the error is in 'Eigen/src/Core/GeneralProduct.h:508` :

ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),
        DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());

From what I understand is that there is weird stack memory allocation done by using the stackpointer r13 register manually. (see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0435a/index.html (search for "C2076E: illegal write to SP")). What it does is that it uses the POSIX alloca function (http://man7.org/linux/man-pages/man3/alloca.3.html) to get dynamic runtime memory from the CPU stack. Manpage man alloca contains the following note:

Normally, gcc(1) translates calls to alloca() with inlined code. 

I suspect that these created ASM inlined sinppets are the root cause of the problem, since they are required to use the r13 stackpointer register. The reason why the stack allocator function is used is that the library can decide if to use stack or heap during runtime based on a threshold of the requested memory size.

Maybe we can fiddle around with the PreProcessor directives EIGEN_ALLOCA, EIGEN_ALIGNED_ALLOCA. Or otherwise fix that macro.

Update: undefining the preprocessor directive called EIGEN_ALLOCA makes the code compile again. But may result in a slightly slower performing Eigen compilation. I'm now working on a proper solution

m-schmoock added a commit to m-schmoock/card.io-dmz that referenced this issue Apr 20, 2016
card-io/card.io-Android-source#60

Using newer Android NDK versions (11+) to compile DMZ result in errors:
   - Eigen: inline assembler that is generated by using POSIX alloca function
            (artificially writing r13 stackpointer register is now forbidden)
   - Eigen: posix_memalign seems to be missing

I wrote pre-processor directives that bypass the issues on Android.
We can remove them once the Android NDK team fixes it.
Performance impact seems to be minimal.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants