Hey folks,
I am migrating our huge Android code base from GCC(Eclipse IDE) to clang(Android Studio).
Error: SIGILL (signal SIGILL: illegal instruction)
At a weird line in the code, I am getting this error. which points to a closing curly bracket of an if condition. After googling, I am assuming it is some kind of architecture flag issue. I am using same flags which were used for GCC.
Note: I am currently working on Arm build.
Here are the architecture flags for ARM7:
-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mtune=cortex-a8 -mthumb -DTARGET_THUMB2
Can anyone help me debug this issue? Is there any issue with the flags with clang?
Thanks,
Rohit Kumar
Glad to help. CCing ML for the record.
Hi,
foo() has undefined behavior if i==0 (lack of return statement)
6.6.3 para 2:
Flowing off the end of a function is equivalent to a return with no
value; this results in undefined behavior
in a value-returning function.
clang generates an invalid instruction for undefined behavior.
This is not ARM-specific.
Compiler Explorer’)),version:4
That ud2 instruction is the machine code for undefined behavior.
Csaba
Hi,
foo() has undefined behavior if i==0 (lack of return statement)
6.6.3 para 2:
Flowing off the end of a function is equivalent to a return with no
value; this results in undefined behavior
in a value-returning function.
clang generates an invalid instruction for undefined behavior.
This is not ARM-specific.
Note that this is C++-specific; it is only undefined behavior in C if the result is used by the caller.
John.
Thanks guys, the issue is resolved now. It was a more trivial fix. Gcc was not giving any error neither on compile time nor on run time. Clang was giving error on runtime.
It was an issue with a function which was supposed to return a Boolean but it wasn’t. I could not figure it out earlier because debugging was not working. But when I got it working I could pinpoint the function, someone from llvm-dev thread suggested to check for such a function. So, finally it got fixed.