We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4173 - Error when compiling SDL_image for arm64-v8a with android
Summary: Error when compiling SDL_image for arm64-v8a with android
Status: RESOLVED FIXED
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.3
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-24 01:46 UTC by tupan
Modified: 2018-10-17 06:45 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tupan 2018-05-24 01:46:06 UTC
Hi, I'm trying to compile SDL and all its extensions for some arm architecture. It worked well for arm7 but for arm64 it is throwing the following error:

/tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libpng.a(pngrutil.o): In function `png_init_filter_functions':
tmp/tmp.cTucoeURHX/jni/SDL_image/external/libpng-1.6.32/pngrutil.c:4113: undefined reference to `png_init_filter_functions_neon'


The command I think is responsible is this one:

/workspace/android/android-ndk-r17/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -Wl,-soname,libSDL2_image.so -shared --sysroot=/workspace/android/android-ndk-r17/platforms/android-21/arch-arm64 /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_bmp.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_gif.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_jpg.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_lbm.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_pcx.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_png.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_pnm.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_svg.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_tga.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_tif.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_webp.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_WIC.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_xcf.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_xpm.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_xv.o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/objs/SDL2_image/IMG_xxx.o -Wl,--whole-archive /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libwebpdecoder_static.a -Wl,--no-whole-archive /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libpng.a /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libwebp.a /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libcpufeatures.a -lgcc -Wl,--exclude-libs,libgcc.a -latomic -Wl,--exclude-libs,libatomic.a /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libSDL2.so  -gcc-toolchain /workspace/android/android-ndk-r17/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -target aarch64-none-linux-android -no-canonical-prefixes   -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings  -L/workspace/android/android-ndk-r17/platforms/android-21/arch-arm64/usr/lib -lz -ldl -lc -lm -o /tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libSDL2_image.so
make: *** [/tmp/tmp.cTucoeURHX/obj/local/arm64-v8a/libSDL2_image.so] Error 1



I checked the file and it has this where the error is found:

  4104 #ifdef PNG_FILTER_OPTIMIZATIONS
  4105    /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to
  4106     * call to install hardware optimizations for the above functions; simply
  4107     * replace whatever elements of the pp->read_filter[] array with a hardware
  4108     * specific (or, for that matter, generic) optimization.
  4109     *
  4110     * To see an example of this examine what configure.ac does when
  4111     * --enable-arm-neon is specified on the command line.
  4112     */
  4113    PNG_FILTER_OPTIMIZATIONS(pp, bpp);
  4114 #endif


Anyone here has any idea what I'm doing wrong or how to fix this issue?

Thanks in advance!
Comment 1 Ryan C. Gordon 2018-05-24 02:39:04 UTC
My guess is that when libpng.a was built, it was built without libpng-1.6.32/arm/arm_init.c, but I can't untangle the build script to see why, or if I'm right.

(Alternately: it built it, but PNG_ARM_NEON_OPT was 0 or undefined?)

--ryan.
Comment 2 Sylvain 2018-05-24 10:18:27 UTC
Hi,

If you want to disable neon for libpng you can patch the file external/libpng-1.6.32/Android.mk

by adding: 

LOCAL_CFLAGS += -DPNG_ARM_NEON_OPT=0


I run a few benchmarks and saw no improvement by using neon with arm64-v8a.


But, if you really want to compile with NEON, you can add that to the previous file : 


ifneq (,$(filter $(TARGET_ARCH),arm arm64))
    $(warning ** Try to compile with NEON for TARGET_ARCH= $(TARGET_ARCH))
      LOCAL_CFLAGS += -DPNG_ARM_NEON_CHECK_SUPPORTED -DPNG_ARM_NEON_FILE=\"contrib/arm-neon/android-ndk.c\"
      common_SRC_FILES += arm/arm_init.c arm/filter_neon_intrinsics.c arm/filter_neon.S 
      LOCAL_STATIC_LIBRARIES := cpufeatures
endif

LOCAL_STATIC_LIBRARIES := cpufeatures

$(call import-module,android/cpufeatures)
Comment 3 tupan 2018-05-24 12:39:01 UTC
(In reply to Ryan C. Gordon from comment #1)
> My guess is that when libpng.a was built, it was built without
> libpng-1.6.32/arm/arm_init.c, but I can't untangle the build script to see
> why, or if I'm right.
> 
> (Alternately: it built it, but PNG_ARM_NEON_OPT was 0 or undefined?)
> 
> --ryan.

How can I check this?
Comment 4 tupan 2018-05-24 12:39:55 UTC
(In reply to Sylvain from comment #2)
> Hi,
> 
> If you want to disable neon for libpng you can patch the file
> external/libpng-1.6.32/Android.mk
> 
> by adding: 
> 
> LOCAL_CFLAGS += -DPNG_ARM_NEON_OPT=0
> 
> 
> I run a few benchmarks and saw no improvement by using neon with arm64-v8a.
> 
> 
> But, if you really want to compile with NEON, you can add that to the
> previous file : 
> 
> 
> ifneq (,$(filter $(TARGET_ARCH),arm arm64))
>     $(warning ** Try to compile with NEON for TARGET_ARCH= $(TARGET_ARCH))
>       LOCAL_CFLAGS += -DPNG_ARM_NEON_CHECK_SUPPORTED
> -DPNG_ARM_NEON_FILE=\"contrib/arm-neon/android-ndk.c\"
>       common_SRC_FILES += arm/arm_init.c arm/filter_neon_intrinsics.c
> arm/filter_neon.S 
>       LOCAL_STATIC_LIBRARIES := cpufeatures
> endif
> 
> LOCAL_STATIC_LIBRARIES := cpufeatures
> 
> $(call import-module,android/cpufeatures)

It worked by adding the LOCAL_CFLAGS to the Android.mk! Thanks!

I wonder how this happened, though...
Comment 5 Sylvain 2018-10-17 06:45:25 UTC
Was fixed by https://hg.libsdl.org/SDL_image/rev/ed8961044eba