macos-arm64.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Based on https://github.com/vespakoen/libpng to work around until
  2. https://github.com/glennrp/libpng/pull/354 is resolved.
  3. also added patch from PS2.4 (PNG.pach) in pngrutil.c
  4. ---
  5. CMakeLists.txt | 28 ++++++++++++++++++++--------
  6. pngrutil.c | 7 -------
  7. 2 files changed, 20 insertions(+), 15 deletions(-)
  8. diff --git a/CMakeLists.txt b/CMakeLists.txt
  9. index 4db9bb87d..9099d1edf 100644
  10. --- a/CMakeLists.txt
  11. +++ b/CMakeLists.txt
  12. @@ -82,10 +82,22 @@ option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
  13. set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
  14. set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
  15. +# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
  16. +# based upon the OS architecture, not the target architecture. As such, we need
  17. +# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
  18. +# enable. Note that this will fail if you attempt to build a universal binary in
  19. +# a single cmake invokation.
  20. +if (APPLE AND CMAKE_OSX_ARCHITECTURES)
  21. + set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES})
  22. +else()
  23. + set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
  24. +endif()
  25. +
  26. +
  27. if(PNG_HARDWARE_OPTIMIZATIONS)
  28. # set definitions and sources for arm
  29. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
  30. - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
  31. +if(TARGET_ARCH MATCHES "^arm" OR
  32. + TARGET_ARCH MATCHES "^aarch64")
  33. set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
  34. set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
  35. check: (default) use internal checking code;
  36. @@ -114,8 +126,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
  37. endif()
  38. # set definitions and sources for powerpc
  39. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
  40. - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
  41. +if(TARGET_ARCH MATCHES "^powerpc*" OR
  42. + TARGET_ARCH MATCHES "^ppc64*" )
  43. set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
  44. set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
  45. off: disable the optimizations.")
  46. @@ -138,8 +150,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
  47. endif()
  48. # set definitions and sources for intel
  49. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
  50. - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
  51. +if(TARGET_ARCH MATCHES "^i?86" OR
  52. + TARGET_ARCH MATCHES "^x86_64*" )
  53. set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
  54. set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
  55. off: disable the optimizations")
  56. @@ -162,8 +174,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
  57. endif()
  58. # set definitions and sources for MIPS
  59. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
  60. - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
  61. +if(TARGET_ARCH MATCHES "mipsel*" OR
  62. + TARGET_ARCH MATCHES "mips64el*" )
  63. set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
  64. set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
  65. off: disable the optimizations")
  66. diff --git a/pngrutil.c b/pngrutil.c
  67. index 7001f1976..91930f1f2 100644
  68. --- a/pngrutil.c
  69. +++ b/pngrutil.c
  70. @@ -422,13 +422,6 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
  71. png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
  72. }
  73. -#if ZLIB_VERNUM >= 0x1290 && \
  74. - defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
  75. - if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
  76. - /* Turn off validation of the ADLER32 checksum in IDAT chunks */
  77. - ret = inflateValidate(&png_ptr->zstream, 0);
  78. -#endif
  79. -
  80. if (ret == Z_OK)
  81. png_ptr->zowner = owner;
  82. --
  83. 2.33.0.windows.1