Menu

#108 undefined symbols when building libpng

1.4.0
closed
None
1
2023-04-09
2021-11-28
No

Originally reported to MacPorts, where it was observed for macOS on Apple Silicon (ARM 64-bit): https://trac.macports.org/ticket/64067. Other platforms with ARM Neon support may be affected.

If building TkImg 1.4.13 with a compiler supporting ARM Neon, there is an error when linking libpng:

/usr/bin/clang -dynamiclib -pipe -Os -arch arm64 -pipe  -Os -DNDEBUG -Wall -fno-common -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk  -DPNG_IMPEXP=MODULE_SCOPE -DPNG_EXTERN=MODULE_SCOPE  -Wl,-single_module -current_version 1.6.37 -compatibility_version 1.6.37   -o libpngtcl1.6.37.dylib pngtcl.o pngtclStubInit.o png.o pngerror.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o pngget.o pngtclStubLib.o -L/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_graphics_tkimg/tkimg/work/Img-1.4.13/zlib -lzlibtclstub1.2.11 -lm -L/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_graphics_tkimg/tkimg/work/Img-1.4.13/zlib -lzlibtclstub1.2.11  -L/opt/local/lib -ltclstub8.6 -L/opt/local/lib -ltkstub8.6 
Undefined symbols for architecture arm64:
  "_png_do_expand_palette_rgb8_neon", referenced from:
      _png_do_read_transformations in pngrtran.o
  "_png_do_expand_palette_rgba8_neon", referenced from:
      _png_do_read_transformations in pngrtran.o
  "_png_init_filter_functions_neon", referenced from:
      _png_read_filter_row in pngrutil.o
  "_png_riffle_palette_neon", referenced from:
      _png_do_read_transformations in pngrtran.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The libpng files pngrtran.c and pngrutil.c assume that if compiler support for ARM Neon is detected (via pngpriv.h), then the additional files in compat/libpng/arm/ will also be compiled. But the TkImg does not compile those files, causing the Undefined symbols error.

Attached is a patch to add the files in compat/libpng/arm/ to the TkImg-provided TEA configure script and Makefile. It is okay for those additional files to be compiled unconditionally: if ARM Neon support is unavailible or the building is for a non-ARM architecture, the respective output object files will have no symbols.

1 Attachments

Discussion

  • Paul Obermeier

    Paul Obermeier - 2022-08-21

    Applied your patch instead of disabling Neon support.
    Works fine for Windows, Linux and Intel Macs.
    Cannot test on ARM Macs.

     
  • Christopher Chavez

    I do not have access to an Apple Silicon Mac, however I confirmed that the MacPorts arm64 build of tkimg using my patch does build libpng with the NEON support functions, and that those still get used in relevant functions (which the Undefined symbols linking error previously indicated was the case).

     
  • Mika Eriksson

    Mika Eriksson - 2022-11-24

    Thanks a million for the patch!
    I managed to make this work on Asahi Linux Mac M1, this being the last missing dependency for linuxcnc-sim that I struggled with for a few days.
    I attach the PKGBUILD with this patch included from https://aur.archlinux.org/packages/tkimg that I used for building the package.

     
  • Paul Obermeier

    Paul Obermeier - 2023-04-09
    • status: open --> closed
    • assigned_to: Paul Obermeier
     
  • Paul Obermeier

    Paul Obermeier - 2023-04-09

    Patch seems to be working, so close.

     

Log in to post a comment.

MongoDB Logo MongoDB