Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't try to use nonexistent libpng optimizations #1339

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

taylordotfish
Copy link

Fixes #1094.

The embedded copy of libpng in juce_graphics/image_formats doesn't contain code for processor-specific hardware optimizations, but it may still try to use them in some cases, resulting in linker errors.

juce_PNGLoader.cpp already sets PNG_ARM_NEON_OPT to 0 to disable optimizations on ARM, but this should be done for all architectures, especially PowerPC, where builds currently fail (#1094):

Linker failure on ppc64le
$ cmake .. -DJUCE_BUILD_HELPER_TOOLS=ON
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1") 
-- Checking for module 'alsa'
--   Found alsa, version 1.2.10
-- Checking for module 'freetype2'
--   Found freetype2, version 26.1.20
-- Checking for module 'gl'
--   Found gl, version 1.2
-- Checking for module 'libcurl'
--   Found libcurl, version 8.4.0
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
--   Package 'webkit2gtk-4.0', required by 'virtual:world', not found
-- Configuring done (1.5s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/JUCE/build
$ make -j20
[ 12%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_graphics/juce_graphics.cpp.o
[ 25%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_gui_basics/juce_gui_basics.cpp.o
[ 50%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/juce_build_tools/juce_build_tools.cpp.o
[ 62%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_core/juce_core.cpp.o
[ 62%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_events/juce_events.cpp.o
[ 75%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/__/__/__/modules/juce_data_structures/juce_data_structures.cpp.o
[ 87%] Building CXX object extras/Build/juceaide/CMakeFiles/juceaide.dir/Main.cpp.o
/tmp/JUCE/extras/Build/juceaide/Main.cpp: In lambda function:
/tmp/JUCE/extras/Build/juceaide/Main.cpp:581:5: warning: control reaches end of non-void function [-Wreturn-type]
  581 |     });
      |     ^
[100%] Linking CXX executable juceaide_artefacts/juceaide
/usr/bin/ld: CMakeFiles/juceaide.dir/__/__/__/modules/juce_graphics/juce_graphics.cpp.o: in function `juce::pnglibNamespace::png_init_filter_functions(juce::pnglibNamespace::png_struct_def*)':
juce_graphics.cpp:(.text+0x8304c): undefined reference to `juce::pnglibNamespace::png_init_filter_functions_vsx(juce::pnglibNamespace::png_struct_def*, unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [extras/Build/juceaide/CMakeFiles/juceaide.dir/build.make:194: extras/Build/juceaide/juceaide_artefacts/juceaide] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: extras/Build/juceaide/CMakeFiles/juceaide.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

On x86, this isn't strictly necessary, because libpng optimizations are opt-in for x86, rather than opt-out as with all other architectures, but for completeness and robustness it is also included here.

The macros to disable optimizations on other platforms come straight from libpng's own build files; this is how it disables optimizations when compiled without support for them. PNG_ARM_NEON_OPT is already one of those macros; this PR simply adds the other three.

The embedded copy of libpng doesn't contain code for processor-specific
hardware optimizations, but it may still try to use them in some cases,
resulting in linker errors.

juce_PNGLoader.cpp already sets `PNG_ARM_NEON_OPT` to 0 to disable
optimizations on ARM, but this should be done for all architectures,
especially PowerPC, where builds currently fail.

On x86, this isn't strictly necessary, because libpng optimizations are
opt-in for x86, rather than opt-out as with all other architectures, but
for completeness and robustness it is also included here.

The macros to disable optimizations on other platforms come straight
from libpng's own build files; this is how it disables optimizations
when compiled without support for them. `PNG_ARM_NEON_OPT` is already
one of those macros; this commit simply adds the other three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant