compiling for arm-v7a

1,344 views
Skip to first unread message

Steven Merel

unread,
Jul 10, 2012, 1:53:25 PM7/10/12
to andro...@googlegroups.com
I develop a software library which is distributed as two static libraries, one built for armeabi and one for armeabi-v7a.  The armeabi-v7a version also uses some NEON optimizations, but only uses them if the cpufeatures library says that NEON is available.

A user has reported that his app crashes at startup on his device, apparently due to an illegal instruction:
signal 4 (SIGILL), code 1 (ILL_ILLOPC)
His device is an Acer A200 which uses a Tegra 2 processor.  This processor supports armv7a but not NEON.  The app works fine on the emulator.

I'm compiling the armeabi-v7a library with these flags:
      -march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=vfp -mfpu=neon

I was under the impression that the compiler would only generate NEON instructions when I had explicitly coded them using intrinsics and/or assembly, but is it possible that it is generating them elsewhere, causing the crash?  If so, can I leave off the -mfpu=neon and still use NEON intrinsics?

thanks!
-steve

Andrew Hsieh

unread,
Jul 10, 2012, 2:33:57 PM7/10/12
to andro...@googlegroups.com
Are you using NDK r7b?  There is a bug in NDK r7b summarized as the following snippet from NDK r7c release. 

Important bug fixes:
  • Fixed GNU STL armeabi-v7a binaries to not crash on non-NEON devices. The files provided with NDK r7b were not configured properly, resulting in crashes on Tegra2-based devices and others when trying to use certain floating-point functions (e.g., cosfsinfexpf).

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/c_IWa_PZGekJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

sjmerel

unread,
Jul 10, 2012, 10:44:25 PM7/10/12
to andro...@googlegroups.com
I was using r7b in the version in which this was reported, though I didn't think that was the problem since it didn't seem to be crashing in a function call.  I gave him some new builds built with r8, so I'll see if those crash as well.
-steve

David Turner

unread,
Jul 11, 2012, 4:40:54 AM7/11/12
to andro...@googlegroups.com
Unfortunately, -mfpu=neon also affects non-NEON code, and there is no known GCC flag to disable this. Which means you should never use it for anything that may need to run on non-NEON-capable hardware.

This only affects C/C++ sources though. I.e. you can have NEON-related assembler sources and build them without -mfpu=neon.
However, I believe you will need -mfpu=neon for C/C++ sources that include inline assembly though.

B.Arunkumar

unread,
Jul 11, 2012, 8:30:59 AM7/11/12
to android-ndk, awsnetwor...@gmail.com
Hi,

Actually we have a similar problem. We have compiled ffmpeg for
neon optimization as per the instrutions given in this link:
http://www.roman10.net/how-to-build-ffmpeg-for-android/

We have used the flags for ARMv7+Neon (Cortex-A8).

And my Android.mk is as follows:

LOCAL_PATH := $(call my-dir)

FFMPEG:= /home/arun/ffmpegneon1103/android/armv7-a/lib

include $(CLEAR_VARS)

LOCAL_MODULE := OnVRView
LOCAL_SRC_FILES := OnVRView.cpp

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS := -DHAVE_NEON=1
LOCAL_MODULE := OnVRView
LOCAL_SRC_FILES += VideoDecoder.cpp.neon
LOCAL_ARM_NEON := true
endif

LOCAL_C_INCLUDES := /home/arun/ffmpegneon1103/android/armv7-a/include

LOCAL_ARM_MODE := arm

LOCAL_STATIC_LIBRARIES := cpufeatures


LOCAL_LDLIBS := -llog -L$(FFMPEG) -lswresample -lavformat -
lavcodec -lswscale -lavutil -Werror

include $(BUILD_SHARED_LIBRARY)

$(call import-module,cpufeatures)

But we find crash at avcodec_decode_video2 in our wrapper class in
debug mode every now and then. I had mailed to android developers
forum that we were experiencing this crash and somebody had replied
using the flag -malign-double. Here is the link to this reply.

http://www.mail-archive.com/android-d...@googlegroups.com/msg212206.html

I am yet to try out this variation. If somebody can give some pointers
to my query, it would also be helpful.

Thank you,
B.Arunkumar

On Jul 11, 1:40 pm, David Turner <di...@android.com> wrote:

sjmerel

unread,
Jul 16, 2012, 3:13:42 PM7/16/12
to andro...@googlegroups.com
So I can compile all my sources without -mfpu-neon, except for the one containing my NEON code (which is inline assembly) which I compile -fmfpu=neon?

I don't have one of these non-NEON armv7 devices; Is there any way to disable NEON in the emulator?

-steve

On Wednesday, July 11, 2012 1:40:54 AM UTC-7, Digit wrote:


thanks!
-steve
To unsubscribe from this group, send email to android-ndk+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages