Advertisement

ASM thumb error when compiling on ARM

Started by May 06, 2015 11:17 AM
2 comments, last by WitchLord 9 years, 6 months ago

Hi. I tried compiling AS on Jetson Tegra K1 which uses ARM processor. I used the gnuc makefile and everything compiles except as_callfunc_arm.cpp.s. It returns error about THUMB instruction not being in IT block. The whole log:

ubuntu@tegra-ubuntu:~/Downloads/sdk (2)/angelscript/projects/gnuc$ make
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_atomic.o -c ../../source/as_atomic.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_builder.o -c ../../source/as_builder.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_bytecode.o -c ../../source/as_bytecode.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc.o -c ../../source/as_callfunc.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_arm.o -c ../../source/as_callfunc_arm.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_mips.o -c ../../source/as_callfunc_mips.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_ppc.o -c ../../source/as_callfunc_ppc.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_ppc_64.o -c ../../source/as_callfunc_ppc_64.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_sh4.o -c ../../source/as_callfunc_sh4.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_x86.o -c ../../source/as_callfunc_x86.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_x64_gcc.o -c ../../source/as_callfunc_x64_gcc.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_x64_mingw.o -c ../../source/as_callfunc_x64_mingw.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_compiler.o -c ../../source/as_compiler.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_context.o -c ../../source/as_context.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_configgroup.o -c ../../source/as_configgroup.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_datatype.o -c ../../source/as_datatype.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_generic.o -c ../../source/as_generic.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_gc.o -c ../../source/as_gc.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_globalproperty.o -c ../../source/as_globalproperty.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_memory.o -c ../../source/as_memory.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_module.o -c ../../source/as_module.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_objecttype.o -c ../../source/as_objecttype.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_outputbuffer.o -c ../../source/as_outputbuffer.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_parser.o -c ../../source/as_parser.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_restore.o -c ../../source/as_restore.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_scriptcode.o -c ../../source/as_scriptcode.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_scriptengine.o -c ../../source/as_scriptengine.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_scriptfunction.o -c ../../source/as_scriptfunction.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_scriptnode.o -c ../../source/as_scriptnode.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_scriptobject.o -c ../../source/as_scriptobject.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_string.o -c ../../source/as_string.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_string_util.o -c ../../source/as_string_util.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_thread.o -c ../../source/as_thread.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_tokenizer.o -c ../../source/as_tokenizer.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_typeinfo.o -c ../../source/as_typeinfo.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_variablescope.o -c ../../source/as_variablescope.cpp
g++ -Wall -fPIC -fno-strict-aliasing -DAS_MAX_PORTABILITY -o obj/as_callfunc_arm_gcc.o -c ../../source/as_callfunc_arm_gcc.S
../../source/as_callfunc_arm_gcc.S: Assembler messages:
../../source/as_callfunc_arm_gcc.S:309: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:311: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:313: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:315: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:386: Error: thumb conditional instruction should be in IT block -- `ldrge r0,[r6]'
../../source/as_callfunc_arm_gcc.S:388: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:389: Error: thumb conditional instruction should be in IT block -- `movlt r1,r5'
../../source/as_callfunc_arm_gcc.S:391: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:392: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:394: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:395: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:396: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:476: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:478: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:479: Error: thumb conditional instruction should be in IT block -- `movlt r2,r5'
../../source/as_callfunc_arm_gcc.S:481: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:482: Error: thumb conditional instruction should be in IT block -- `movlt r3,r5'
../../source/as_callfunc_arm_gcc.S:483: Error: thumb conditional instruction should be in IT block -- `movlt r5,#0'
../../source/as_callfunc_arm_gcc.S:487: Error: thumb conditional instruction should be in IT block -- `ldrge r7,[r6,#12]'
../../source/as_callfunc_arm_gcc.S:488: Error: thumb conditional instruction should be in IT block -- `strge r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:493: Error: thumb conditional instruction should be in IT block -- `movge r5,#4'
../../source/as_callfunc_arm_gcc.S:564: Error: thumb conditional instruction should be in IT block -- `ldrge r1,[r6]'
../../source/as_callfunc_arm_gcc.S:566: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:568: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:570: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:642: Error: thumb conditional instruction should be in IT block -- `ldrge r2,[r6]'
../../source/as_callfunc_arm_gcc.S:644: Error: thumb conditional instruction should be in IT block -- `ldrge r3,[r6,#4]'
../../source/as_callfunc_arm_gcc.S:646: Error: thumb conditional instruction should be in IT block -- `movge r11,#4'
../../source/as_callfunc_arm_gcc.S:648: Error: thumb conditional instruction should be in IT block -- `movge r11,#8'
../../source/as_callfunc_arm_gcc.S:649: Error: thumb conditional instruction should be in IT block -- `ldrlt r7,[r6,#8]'
../../source/as_callfunc_arm_gcc.S:650: Error: thumb conditional instruction should be in IT block -- `strlt r7,[r6,#12]'
make: *** [obj/as_callfunc_arm_gcc.o] Error 1

You can also see I tried compiling with -DAS_MAX_PORTABILITY with the idea it will not use the ASM at all, but it still compiled it and threw the error. Is there some kind of flag I need to change? The ASM has defined blocks for THUMB1, THUMB2 and ARM, so techniclly I could disable THUMB and fallback to ARM?

Compiler:

For some reason I cannot post the whole g++ -v here. So I posted it here: http://pastebin.com/n4uXrVXb


The as_callfunc_arm_gnuc.S is missing a #ifndef AS_MAX_PORTABILITY condition. I'll have this added.

When compiling with max portability this code is not needed, you can simply remove as_callfunc_arm_gnuc.S from the makefile if you prefer using AS_MAX_PORTABILITY.

I'm not sure why the compilation fails though. Unfortunately my little BeagleBone Black with Angström Linux uses the soft-float ABI, and I haven't been able to make it compile with hard-float ABI yet so I'm not able to verify the assembler code for the hard-float ABI (which is where you're getting compiler errors).

Still, the same assembler instructions that the compiler is complaining about in your case are present in the soft-float ABI too, and I don't get any errors.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Do you also compile with the thumb instructions or the regular arm? My gcc has defined "--with-mode=thumb". When I added the "#ifndef AS_MAX_PORTABILITY" I got it to compile. But when I launch the project it segfaults on AS functions. It manages to create the engine, but the next function which is registering the error callback crashes (quite ironic). At first I thought it was because of asCALL_CDECL, because at that point I was running the AS_MAX_PORTABILITY flag. So I changed it into asCALL_GENERIC and same thing. I posted both of the segfaults. The callstack doesn't go any deeper than this. The whole backtrace only shows the path until it calls this function.

//With CDECL
Program received signal SIGSEGV, Segmentation fault.
0x0002e900 in as::as_engine_create ()
at NodeVision_System/scripting/angelscript_wrapper.cpp:94
94 int r = engine->SetMessageCallback(asFUNCTION(as::MessageCallback), 0, asCALL_CDECL); assert( r >= 0 ); //For errors reports

//With Generic
Program received signal SIGSEGV, Segmentation fault.
0x0002e900 in as::as_engine_create ()
at NodeVision_System/scripting/angelscript_wrapper.cpp:94
94 int r = engine->SetMessageCallback(asFUNCTION(as::MessageCallback), 0, asCALL_GENERIC); assert( r >= 0 ); //For errors reports

Then I tried removing it, just to see if it would go further. But the next function is RegisterStdString, which then calls RegisterStdStringGeneric and crashes.

It also compiled when I removed the AS_MAX_PORTABILITY and instead added the -marm flag (which is the same as --with-mode=arm). In that case everything is the same. It crashes at SetMessageCallback and when I remove it, it calls RegisterStdString, which then calls RegisterStdStringNative and crashes. Here is the full backtrace for both:

//Native
Program received signal SIGSEGV, Segmentation fault.
0x0004204a in RegisterStdString_Native (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:537
537 r = engine->RegisterObjectType("string", sizeof(string), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
(gdb) bt
#0 0x0004204a in RegisterStdString_Native (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:537
#1 0x0004527e in RegisterStdString (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:1043
#2 0x0002ecd2 in as::as_engine_create ()
at NodeVision_System/scripting/angelscript_wrapper.cpp:95
#3 0x0001c1aa in novi::NodeSystem::NodeSystem (
this=0x1c8588 <novi::master_nsystem>)
at NodeVision_System/node_system.h:57
#4 0x0001bbae in __static_initialization_and_destruction_0 (
__initialize_p=1, __priority=65535)
at NodeVision_System/node_system.cpp:35
#5 0x0001bbde in _GLOBAL__sub_I__ZN4novi10master_ndbE ()
at NodeVision_System/node_system.cpp:556
#6 0x0014535a in __

//Generic
Program received signal SIGSEGV, Segmentation fault.
0x00043ed6 in RegisterStdString_Generic (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:972
972 r = engine->RegisterObjectType("string", sizeof(string), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); assert( r >= 0 );
(gdb) bt
#0 0x00043ed6 in RegisterStdString_Generic (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:972
#1 0x00044e9e in RegisterStdString (engine=0x0)
at include/AngelScript/add_on/scriptstdstring/scriptstdstring.cpp:1041
#2 0x0002e8fa in as::as_engine_create ()
at NodeVision_System/scripting/angelscript_wrapper.cpp:95
#3 0x0001bdd2 in novi::NodeSystem::NodeSystem (
this=0x171560 <novi::master_nsystem>)
at NodeVision_System/node_system.h:57
#4 0x0001b7d6 in __static_initialization_and_destruction_0 (
__initialize_p=1, __priority=65535)
at NodeVision_System/node_system.cpp:35
#5 0x0001b806 in _GLOBAL__sub_I__ZN4novi10master_ndbE ()
at NodeVision_System/node_system.cpp:556
#6 0x000f086a in __libc_csu_init ()
#7 0xb5ed55ee in __libc_start_main (main=0x10909 <main()>, argc=1,
argv=0xbe7ff0e4, init=0xf083d <__libc_csu_init>,
fini=0xf087d <__libc_csu_fini>, rtld_fini=0xb67ea4c5 <_dl_fini>,
stack_end=0xbe7ff0e4) at libc-start.c:246
#8 0x0000c290 in _start ()
(gdb)

Everything works fine on Windows x86 and x64. I'm using the 2.30 version of AS.

I don't use thumb mode. Though I'll give it a try as soon as I can to see if works (probably not, since I haven't prepared the soft-float ABI for thumb mode).

From your backtraces the program crashes because the engine pointer is null. Apparently the asCreateScriptEngine() call didn't work, and returned null. Have you tried stepping into this function in the debugger to understand why it is not creating the engine instance?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement