Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while compiling: error: r7 cannot be used in asm here #2387

Closed
bramvdbogaerde opened this issue Jul 24, 2015 · 7 comments
Closed

Error while compiling: error: r7 cannot be used in asm here #2387

bramvdbogaerde opened this issue Jul 24, 2015 · 7 comments

Comments

@bramvdbogaerde
Copy link

Full log:

[  1%] Built target jsoncpp
[  5%] Built target zlib
[ 11%] Built target lua
[ 12%] Built target tolualib
[ 13%] Built target tolua
[ 14%] Built target sqlite
[ 15%] Built target SQLiteCpp
[ 16%] Built target expat
[ 16%] Built target luaexpat
[ 21%] Built target event
[ 26%] Built target event_core
[ 31%] Built target event_extra
[ 34%] Built target OSSupport
[ 35%] Built target Noise
[ 36%] Building C object lib/polarssl/library/CMakeFiles/mbedtls.dir/bignum.c.o
/root/cuberite/lib/polarssl/library/bignum.c: In function ‘mpi_mul_hlp’:
/root/cuberite/lib/polarssl/library/bignum.c:1131:1: error: r7 cannot be used in asm here
 }
 ^
lib/polarssl/library/CMakeFiles/mbedtls.dir/build.make:192: recipe for target 'lib/polarssl/library/CMakeFiles/mbedtls.dir/bignum.c.o' failed
make[2]: *** [lib/polarssl/library/CMakeFiles/mbedtls.dir/bignum.c.o] Error 1
CMakeFiles/Makefile2:690: recipe for target 'lib/polarssl/library/CMakeFiles/mbedtls.dir/all' failed
make[1]: *** [lib/polarssl/library/CMakeFiles/mbedtls.dir/all] Error 2
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2

Platform: armv7l
OS: Ubuntu 14.10

@zackp30
Copy link
Contributor

zackp30 commented Jul 24, 2015

https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here

If site ever goes down:

Platform
ARM (Thumb assembly)

What
Depending on the GCC compiler options used, you can receive an error:

error: r7 cannot be used in asm here
Reason
The assembly code in bn_mul.h is optimized for the ARM platform and uses some registers, including r7 to efficiently do an operation. GCC also uses r7 as the frame pointer under ARM Thumb assembly.

Solution
Add -fomit-frame-pointer to your GCC compiler options.

If you have already added -O, -O2, etc you do not need to add -fomit-frame-pointer as the optimization options already include it on most systems by default.

@bramvdbogaerde
Copy link
Author

I tried that before but I added the flag in the wrong place.
It compiles now.
Thanks.

@madmaxoft
Copy link
Member

@bramvdbogaerde so what exactly did you change? Something in the PolarSSL cmakelist?

@bramvdbogaerde
Copy link
Author

I added the following line in "SetFlags.cmake" in the macro "set_flags":
add_flags_cxx("-fomit-frame-pointer")

@madmaxoft
Copy link
Member

I'll need someone more Linux-educated. @worktycho ?
Is it safe to include that flag for all builds on all platforms? Should we add it as-is, or inside a conditional block?

@worktycho
Copy link
Member

The only reason it is turned off by default is that it can reduce the debug experience. I'd suggest wrapping in a flag to only be added on ARM in debug mode.

@madmaxoft
Copy link
Member

Sounds reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants