This is what was causing the libpng crash in png_longjmp() on
Windows 10 in MSVC 2022 release builds.
See #451: libpng errors crash due to libpng setjmp/longjmp (Windows 10, release builds only)
Reported by @Masamune3210.
PNG_LIB_NAME was removed from CMakeLists.txt in v1.6.40, which was added
in rom-properties 2.2. No one seems to have noticed its absence, though...
Affects: v2.2 - v2.4.1
The APNG patch for v1.6.47 isn't out yet, so I hacked in some changes
to get the APNG code to build in pngrutil.c. In particular, the PNGv3
chromacity changes also modified pngrutil.c to use table-based dispatch
instead of an if/else. png_read_frame_head() doesn't use this yet, so
the APNG functions in pngrutil.c haven't been marked static yet, but
they do now return png_handle_result_code.
TODO: Rebase using the APNG patch once it's rebased for v1.6.47.
NOTE: PNGv3 apparently makes APNG part of the specification, so
libpng "should" gain built-in support for APNG without a patch at
some point.
The root CMakeLists.txt has a minimum CMake version of 3.5, and
CheckHiddenVisibility.cmake's workarounds are only needed for
CMake 3.2 and earlier.
Set CMP0063 unconditionally (added in CMake 3.3) and set the
CMAKE_<LANG>_VISIBILITY_PRESET and CMAKE_VISIBILITY_INLINES_HIDDEN
variables where CHECK_HIDDEN_VISIBILITY() was called before.
There should effectively be no code changes with this commit.
Something changed that caused the build on Xubuntu 16.04 (32-bit) to fail:
[ 63%] Linking CXX shared library ../../lib/libromdata.so
/usr/bin/ld: read-only segment has dynamic IFUNC relocations; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: Bad value
collect2: error: ld returned 1 exit status
src/libromdata/CMakeFiles/romdata.dir/build.make:3614: recipe for target 'lib/libromdata.so.6.0' failed
make[2]: *** [lib/libromdata.so.6.0] Error 1
Setting POSITION_INDEPENDENT_CODE instead of "-fpic -fPIC" fixes this.
[extlib] Correctly set properties on the 'mspack' target instead of
'libmspack'. Otherwise, libmspack won't have either EXCLUDE_FROM_ALL
or POSITION_INDEPENDENT_CODE.
For most libraries, this merely required adding hidden visibility
flags to the CMakeLists.txt files. zlib-ng was a bit finicky,
and TinyXML2 needed a new macro, TINYXML2_NO_GCC_EXPORT.
TODO: zstd isn't currently used by libromdata.so. If I make use of it
later, either directly or indirectly via minizip, update it to not
export symbols when statically linking to it on Linux.
APNG_dlopen.c: Rework this file so it's always compiled regardless of
USE_INTERNAL_PNG and USE_INTERNAL_PNG_DLL. It exports two symbols,
APNG_ref() and APNG_unref(). When using the statically-linked libpng,
these functions are now no-ops, but they still need to be exported.
We're technically installing both the Debug and Release files, but only
one will exist at any given time, so it has to be OPTIONAL.
[libpng] CMakeLists.txt: Minor formatting improvements.
We need to install in ${INSTALL_BIN_DIR}, not ${CMAKE_INSTALL_BINDIR}.
Otherwise, it ends up in bin/ instead of i386/ or amd64/.
[libpng] Use ${INSTALL_BIN_DIR} for the Framework destination. This will
be used if I ever get any Mac OS X frontends done (besides rpcli).
This fixes issue #194: package.cmd: tinyxml2.dll isn't copied over correctly.
Tests are all executables, so none of the libraries need to be PUBLIC.
External libraries should not be exporting their dependencies if they
aren't needed.
The eXIf functions added in 1.6.31 were broken, so two new functions
were added and the old ones stubbed. This shifts the ordinals for APNG
over by two again.
Note that two new functions were added to the original libpng, so the
ordinals for APNG were shifted over by two. This shouldn't be a problem,
since programs should be accessing functions by name instead of by
ordinal in 2017.
CMakeLists.txt: Use the top-level CMake directories.
cmake/platform/win32*.cmake: Define the Windows SDK version in
win32.cmake. Use the same version (Windows XP) regardless of
the target operating system in order to keep everything consistent.
[libpng] CMakeLists.txt: Fix MSVC debug paths for png_static.
Intel SSE2 was merged into the main codebase.
Added more ARM, MIPS, and PowerPC optimizations, though some of them
aren't currently used by CMakeLists.txt.
Using MinGW-w64 4.0.6 with gcc-6.2.0.
Note that it still doesn't compile successfully due to missing
functionality in MinGW-w64 4.0.6. I'll try it again with 5.0.1 later.
Note that MinGW-w64 5.0.1 is still missing isolation-aware functionality,
so it won't be able to handle XP theming correctly.
Summary of changes:
- cmake/platform.cmake: MinGW-w64 uses separate crt*.o files for Unicode
instead of a separate entry point. Handle this by removing the "w" from
the Unicode entry point and passing the "-municode" option instead.
- libpng, rpcli, win32: CMake-3.7.2 doesn't add include paths to windres.
Add the include paths manually in order to fix .rc compilation.
- c++11-compat.h: Moved the case-insensitive string comparison macros
from c++11-compat.msvc.h. MinGW-w64 doesn't have the wcs*() functions,
but it does have macros for str*(), so we have to define the macros
only if said macros don't already exist.
- [libcachemgr] CacheManager: gettimeofday() is in time.h on MSVC,
and sys/time.h on MinGW-w64 and other platforms. sys/types.h is
no longer needed.
libromdata:
- RpWin32.cpp: Added more conditionals to the error list in order to
fix compilation with MinGW-w64.
- RpWin32.hpp: Use reinterpret_cast<> for the atomic memory access
functions.
rpcli:
- time_r.h: #define _POSIX_C_SOURCE is required on MinGW-w64 in order
to use the *_r() functions.
- properties.cpp: #include "time_r.h" earlier to prevent time.h from
being included before _POSIX_C_SOURCE is defined.
win32:
- QITab.h: Split the QISearch() defines out of RP_ComBase.h and added
definitions that are missing on MinGW-w64.
- Added an extra '0' in QITAB instances in order to suppress gcc's
"missing initializer" warning. [-Wmissing-field-initializers]
- Moved all COM smart pointers to the top of the file. Disabled some of
them in MSVC builds because they're already defined in comdefsp.h.
- rom-properties.def: Removed the comment and "LIBRARY" statement, since
GNU ld doesn't recognize them.
The subsystem was being set to 6.0 in 64-bit builds, which prevents
usage on XP64 and Server 2003 64-bit. Use SET_WINDOWS_SUBSYSTEM()
to fix this.
Also mark the DLLs as using the Windows subsystem. (Not that it matters,
since that field is only relevant for EXEs...)
TODO: Check other DLLs before committing, and do this before the
/TSAWARE commit.