microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.32k stars 6.45k forks source link

[libpng] No hardware optimisation enabled for PowerPC architecture #38232

Open runlevel5 opened 7 months ago

runlevel5 commented 7 months ago

Describe the bug I ran into errors when compiling my Raytracing demo app. Please refer to Failure logs section for more details

Environment

To Reproduce Steps to reproduce the behavior:

$ git clone https://github.com/GPSnoopy/RayTracingInVulkan.git
$ cd RayTracingInVulkan
$ mkdir -p build
$ cd build
$ git clone https://github.com/Microsoft/vcpkg.git vcpkg.linux
$ cd vcpkg.linux
$ vcpkg install \
    boost-exception:ppc64le-linux \
    boost-program-options:ppc64le-linux \
    boost-stacktrace:ppc64le-linux \
    glfw3:ppc64le-linux \
    glm:ppc64le-linux \
    imgui[core,freetype,glfw-binding,vulkan-binding]:ppc64le-linux \
    stb:ppc64le-linux \
    tinyobjloader:ppc64le-linux
$ cd ../..
$ mkdir --parents build/linux
$ cd build/linux
$ cmake -D CMAKE_MAKE_PROGRAM=make -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++  -D CMAKE_BUILD_TYPE=Release -D VCPKG_TARGET_TRIPLET=ppc64le-linux -D CMAKE_TOOLCHAIN_FILE=../vcpkg.linux/scripts/buildsystems/vcpkg.cmake ../..
$ make -j32

Expected behavior No error

Failure logs

[ 94%] Building CXX object src/CMakeFiles/RayTracer.dir/ModelViewController.cpp.o
[ 95%] Building CXX object src/CMakeFiles/RayTracer.dir/RayTracer.cpp.o
[ 98%] Building CXX object src/CMakeFiles/RayTracer.dir/UserInterface.cpp.o
[ 98%] Building CXX object src/CMakeFiles/RayTracer.dir/SceneList.cpp.o
[100%] Linking CXX executable ../bin/RayTracer
/usr/bin/ld: /home/tle/Work/RayTracingInVulkan/build/vcpkg.linux/installed/ppc64le-linux/lib/libpng16.a(pngrutil.c.o): in function `png_read_filter_row':
pngrutil.c:(.text+0x8a08): undefined reference to `png_init_filter_functions_vsx'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/RayTracer.dir/build.make:931: bin/RayTracer] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: src/CMakeFiles/RayTracer.dir/all] Error 2
make: *** [Makefile:91: all] Error

Additional context

That is likely caused by the lacking of VSX support. From what I could tell is that libpng does opt-in the VSX optimisation option, please refer to codes

However it's seems to me it is not the case.

I guess the vcpkg port might have to handle that logic instead... (though I am not sold of that idea)

My ugly pseudocodes are kinda like this:

if(PPC64LE OR PPC64)
  add_definitions(-DPNG_POWERPC_VSX_OPT=2) # enabled
else()
  add_definitions(-DPNG_POWERPC_VSX_OPT=0) # disabled
endif()
dg0yt commented 7 months ago

Might be an upstream issue, cf. https://github.com/microsoft/vcpkg/pull/38250#discussion_r1570513595

runlevel5 commented 7 months ago

@dg0yt it is plausible though I do not think it is an issue upstream. For example in Fedora Linux, the RPM spec file does not do anything special with configure and make part (ref https://src.fedoraproject.org/rpms/libpng/blob/rawhide/f/libpng.spec#_71) so the logic of upstream CMakeList must be correct. One way to verify that is that I use the /usr/lib64/libpng16.a (belongs to libpng-static package on Fedora 40 ppc64le) and the app does not complain anymore.

dg0yt commented 7 months ago

For example in Fedora Linux, the RPM spec file does not do anything special with configure and make part (ref https://src.fedoraproject.org/rpms/libpng/blob/rawhide/f/libpng.spec#_71) so the logic of upstream CMakeList must be correct.

No. Fedora (and the "additional context" in your initial post) use autotools/configure/make. This is independent of CMake. And that might explain why nobody on linux noticed the problem.

github-actions[bot] commented 1 month ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

runlevel5 commented 1 month ago

Don't close this @github-actions