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.
It's similar to, but not the same as, the issue with MSVC 32-bit debug
builds that was fixed upstream in v2.2.4.
-O0 and -Og both crash; -O1 and higher work fine. The issue appears to be
%rax being 16-byte aligned, but not 32-byte aligned, when calling int
GET_CHUNK_MAG(). -O1 and higher enable inlining, which works around this
issue.
The crashes on AppVeyor appear to be related to AVX2, so I'll disable
AVX2 when using the internal copy of zlib-ng on Windows for now.
This reverts commit 4a0672ad6f.
This zlib-ng update is causing the AppVeyor MSVC 2015 x86 Debug build
to crash with an SEH exception in ImageDecoderTest and GcnFstTest.
This reverts commit 5178e6b25e.
This significantly reduces the total size. fmt-11.dll's Release build
size is 128 KiB, and it cuts between 16-64 KiB from binaries that use it.
Total size of EXEs and DLLs, with amiiboc.exe and libgnuintl-8.dll,
but without test executables or PDBs:
[MSVC 2022 v17.6.5, Release build]
- Total size of EXEs and DLLs with header-only: 4,332,032
- Total size of EXEs and DLLs with fmt-11.dll: 4,161,536
- Difference: -170,496
With test executables:
- Total size of EXEs and DLLs with header-only: 9,716,224
- Total size of EXEs and DLLs with fmt-11.dll: 7,907,840
- Difference: -1,808,384
TODO: Add Delay-Load checks for fmt-11.dll to e.g. rpcli and the
Win32 UI frontend. (amiiboc and unit tests don't need it.)
CMake 3.16.2 on AppVeyor (Win32) shows this error:
CMake Error in extlib/libfmt/CMakeLists.txt:
INTERFACE_LIBRARY targets may only have whitelisted properties. The
property "POSITION_INDEPENDENT_CODE" is not allowed.
CMake 3.31.0 on my Windows 7 VM didn't show this error...
Currently used as a header-only build. Will eventually be changed to
build a DLL for Windows and Mac OS X.
Other changes needed to get the Windows version to build with libfmt:
Add #include <fmt/xchar.h> to some files for full wchar_t support
in libfmt. Otherwise, errors like this appear:
src\amiibo-data\amiiboc.cpp(175,8): error C2665: 'fmt::v11::print': no overloaded function could convert all the argument types
extlib\libfmt\include\fmt\base.h(2925,17): message : could be 'void fmt::v11::print<TCHAR*&>(FILE *,fmt::v11::fstring<TCHAR *&>,TCHAR *&)'
src\amiibo-data\amiiboc.cpp(175,8): message : 'void fmt::v11::print<TCHAR*&>(FILE *,fmt::v11::fstring<TCHAR *&>,TCHAR *&)': cannot convert argument 2 from 'wmain::<lambda_1>::()::FMT_COMPILE_STRING' to 'fmt::v11::fstring<TCHAR *&>'
src\amiibo-data\amiiboc.cpp(175,22): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
extlib\libfmt\include\fmt\base.h(2908,17): message : or 'void fmt::v11::print<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR*&>(fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>,wmain::<lambda_1>::()::FMT_COMPILE_STRING &&,TCHAR *&)'
src\amiibo-data\amiiboc.cpp(175,8): message : 'void fmt::v11::print<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR*&>(fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>,wmain::<lambda_1>::()::FMT_COMPILE_STRING &&,TCHAR *&)': cannot convert argument 1 from 'FILE *' to 'fmt::v11::fstring<wmain::<lambda_1>::()::FMT_COMPILE_STRING,TCHAR *&>'
src\amiibo-data\amiiboc.cpp(175,14): message : No constructor could take the source type, or constructor overload resolution was ambiguous
src\amiibo-data\amiiboc.cpp(175,8): message : while trying to match the argument list '(FILE *, wmain::<lambda_1>::()::FMT_COMPILE_STRING, TCHAR *)' [build.vc17_64\src\amiibo-data\amiiboc.vcxproj]
Files modified for xchar.h:
- amiibo-data/amiiboc.cpp
- libromdata/stdafx.h (needed by WiiUPackage)
- libromdata/tests/RomHeaderTest.cpp
NOTE: Only included on Windows. xchar.h was added in libfmt-8.0.0,
which was first added (in Ubuntu LTS releases) in Ubuntu 20.04.
It's not needed on Linux, anyway.
New option USE_INTERNAL_FMT to force the use of the internal copy of
libfmt on Linux, for testing purposes. (...and also for Ubuntu 16.04)
- TODO: Maybe use it on 18.04, etc. for improved performance?
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.
The recent PIC changes for the internal TinyXML2 somehow broke compiling
gtest_main on Windows:
extlib\googletest\googletest\src\gtest_main.cc(48): error C2491: 'main':
definition of dllimport function not allowed
Also disable gmock_main, since it depends on gtest_main.
We aren't actually using these, so it's not an issue.
(We implement our own main() in gtest_init.cpp.)
[extlib] CMakeLists.txt: Rename SET_EXTLIB_PROPERTIES_PIC() to
SET_EXTLIB_PROPERTIES_PIC_ONLY(), since SET_EXTLIB_PROPERTIES()
also sets POSITION_INDEPENDENT_CODE=TRUE.
Also use SET_EXTLIB_PROPERTIES_PIC_ONLY() for shared libraries that
may be installed, since we can't use SET_EXTLIB_PROPERTIES().
Adjusted SET_EXTLIB_PROPERTIES() to skip EXCLUDE_FROM_ALL if they're
being installed (i.e. SKIP_INSTALL_ALL is set when the function is
called).
This should fix a PIC issue when building the internal copy of
TinyXML2 on Linux, and possibly other libraries too:
/usr/bin/ld: lib/../extlib/tinyxml2/CMakeFiles/tinyxml2.dir/tinyxml2.cpp.o: warning: relocation against `stdout@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: lib/../extlib/tinyxml2/CMakeFiles/tinyxml2.dir/tinyxml2.cpp.o: relocation R_X86_64_PC32 against symbol `stdout@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
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.
- Don't install binaries. minigzip and minizip aren't compiled by
default, so attempting to install them will fail.
- Set SKIP_INSTALL_LIBRARIES to OFF when building DLLs.
- Disable installation of headers, import libraries, and .cmake files.
- Install PDB files.
Since we're now using MiniZip in the J2ME parser, it should be compiled
as a DLL instead of statically linked.
Disable zstd support. It's causing issues with DelayLoad, since we're not
loading zstd in the J2ME parser. I originally enabled this to potentially
improve compression for test cases, but I ended up using .tar.zst instead
of zstd-compressed .zip files.
[libwin32common] Add MiniZip DLL information.
[libromdata] J2ME: Add MiniZip delay-load handling.
[libromdata] GczReader: Improve delay-load handling a bit.
Without this renaming, these binaries are built automatically, even
though we don't need them most of the time.
With this renaming, they'll only be built if the user explicitly
specifies that they should be built.
This regressed when updating from minizip-ng v4.0.6 to v4.0.7 in
commit 3c90ea3d26.
These are test files and aren't really needed here.
[.github] codecov.yml: Remove "./extlib", which didn't work anyway:
warning - 2024-10-19 13:18:48,965 -- Some files were not found --- {"not_found_files": ["!./extlib"]}
librpbyteswap is still embedded into libromdata and has exported
functions.
librpcpuid is a standalone static library and will be linked into
anything that needs CPU flags, instead of using __builtin_cpu_supports().
librpcpuid's version is more efficient because it has fewer tests and
it doesn't do string comparisons.
Remove #include "byteorder.h" from a few files, since it isn't actually used:
- librpbase/img/RpPng.cpp
- librpbase/img/RpPngWriter.cpp
- libromdata/disc/xdvdfs_structs.h
- libromdata/Media/hsfs_structs.h
[gtk,librpbase] Remove #include "librpcpu/cpu_dispatch.h" from stdafx.h,
since it's only used by a few files.
[gtk3] CMakeLists.txt: Removed SSSE3 checks. SSSE3 is only used by
GdkImageConv, which is only used by the XFCE (GTK2) UI frontend.
[gtk3] CairoImageConv.hpp: Remove #include "librpcpu/cpu_dispatch.h",
since it isn't actually used here.
[xfce] GdkImageConv_ifunc.cpp, [librpbyteswap] byteswap_ifunc.c:
- #include "config.librpcpuid.h" before checking for HAVE_IFUNC.
This was indirectly included before, but explicitly including it
allows us to skip the other inclusion if IFUNC is not available.
gcc-4.9 doesn't support std::is_trivially_copy_constructible<T> or
std::is_trivially_destructible<T>, so use __has_trivial_copy(T)
and __has_trivial_destructor(T) on old gcc.
It's not a perfect fix, but it gets the code to compile.
(I'm using Debian 8 to test big-endian using qemu-system-ppc.
Surprisingly, it's faster than Wii U Linux, even with all of
the CPU emulation overhead!)
Fixes the following 64-bit MSVC warnings:
unice68_pack.c(243,43): warning C4244: '=': conversion from '__int64' to 'dreg_t', possible loss of data
unice68_pack.c(319,28): warning C4244: '=': conversion from '__int64' to 'dreg_t', possible loss of data
unice68_pack.c(325,36): warning C4244: '=': conversion from '__int64' to 'dreg_t', possible loss of data
unice68_pack.c(456,40): warning C4244: '=': conversion from '__int64' to 'dreg_t', possible loss of data
unice68_pack.c(488,36): warning C4244: '=': conversion from '__int64' to 'dreg_t', possible loss of data
This matches msvc.cmake, which disables thread-safe statics for both
i386 and amd64, even though we aren't really supporting 64-bit versions
of Windows XP or Windows Server 2003.
rp-config suddenly started crashing on XP when trying to decode PNG
images. It turns out that *something* caused zlib-ng to start using
TLS, though the code indicates it may have always used it...
It's entirely possible that this was broken on XP for quite a while,
and I just didn't notice it until now.
TLS usage was added in zlib-ng 2.1.0-beta1. rom-properties updated
from v2.0.7 to v2.1.2 in rom-properties 2.2, so the previous release
will randomly crash on Windows XP.
It's going to have a lot of local customizations, so it isn't really
a vendored library anymore. Among other things, I'm converting it from
header-only to .cpp files.
In order to use "dark mode" in Win10 1809+ in a standard Win32 program,
we have to do all sorts of weird shenanigans.
Currently, dark mode is "enabled" in rp-config, but it only works in
context menus and scroll bars.
Reference: https://github.com/ysc3839/win32-darkmode
rapidjson hasn't had a proper release since August 2016, even though it's
had patches as recently as this past September. This patch is from
December 2017 and reworks GenericMemberIterator to not inherit from
std::iterator.
This fixes several warnings in MSVC when compiling in C++17 mode:
extlib\rapidjson\include\rapidjson/document.h(111,5): warning C4996:
'std::iterator<std::random_access_iterator_tag,internal::MaybeAddConst
<Const,rapidjson::GenericMember<Encoding,Allocator>>::Type,ptrdiff_t,
internal::MaybeAddConst<Const,rapidjson::GenericMember<Encoding,Allocator>>
::Type*,internal::MaybeAddConst<Const,rapidjson::GenericMember<Encoding,Allocator>>::Type&>':
warning STL4015: The std::iterator class template (used as a base class
to provide typedefs) is deprecated in C++17. (The <iterator> header is NOT
deprecated.) The C++ Standard has never required user-defined iterators to
derive from std::iterator. To fix this warning, stop deriving from
std::iterator and start providing publicly accessible typedefs named
iterator_category, value_type, difference_type, pointer, and reference.
Note that value_type is required to be non-const, even for constant
iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this warning.
One of the afl-fuzz tests (000003?) was failing due to the source
range being out of bounds.
Also, add assert() to the checked chk_src_range() and chk_dst_range()
functions.
Otherwise, attempting to dereference a5 will segfault.
This fixes all of the unice68 segfaults found with afl-fuzz so far...
at least in debug builds. Release builds are still faulting for some
reason...
TODO: Continue running afl-fuzz. I suspect I'll need to add something
similar to all uses of chk_src_range() and chk_dst_range().
- Define _DEFAULT_SOURCE in addition to _BSD_SOURCE.
In file included from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdlib.h:26,
from /home/david/programming/rom-properties/extlib/minizip-ng/mz.h:158,
from /home/david/programming/rom-properties/extlib/minizip-ng/mz_strm_mem.c:19:
/usr/include/features.h:196:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
196 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
| ^~~~~~~
- mz_os_posix.c, mz_os_utf8_string_create(): `encoding` is unused.
This ensures any project that pulls in TinyXML2 also defines it.
I don't think this caused any actual problems, since libromdata.so wasn't
exporting TinyXML2 symbols when -DUSE_INTERNAL_XML=ON, but it does silence
a warning:
In file included from src/kde/config/AboutTab.cpp:48:0:
extlib/tinyxml2/tinyxml2.h:85:25: warning: "TINYXML2_NO_GCC_EXPORT" is not defined [-Wundef]
.#elif __GNUC__ >= 4 && !TINYXML2_NO_GCC_EXPORT
^
Windows 2000 support only partially worked in rp-config. The actual
shell extension component didn't work.
Support for ANSI Windows was mostly just compile-tested, and it was
becoming a burden to support something almost no one will use.
Removed most `#ifdef UNICODE` and `#ifdef _UNICODE` branches in
favor of using the Unicode path exclusively.
Removed oldwincompat, which was an attempt to get things working
properly on Windows 9x and 2000 with the MSVC 2010 runtime.
rom-properties doesn't compile with MSVC 2010 anymore, so this
probably wasn't very useful anyways.
Consolidated tstring macros in tcharx.h.
Removed GUID_fns.c since it was only useful in ANSI builds.
Compiled using gcc-13.2.0 and MinGW-w64 11.0.0.
Removed the *.dll.debug files, since I'm not planning on debugging
gettext, and no one seems to care about them anyway.
NOTE: The libgnuintl-8.dll files are more than double the size of
the previous version. This might be due to using a newly-built
Gentoo crossdev MinGW-w64 toolchain on my laptop instead of the
old MinGW-w64 toolchain on Ubuntu 22.04, or it might be because
gettext-0.22 has more wchar_t functionality on Windows now.
TODO: Build for Windows on ARM using LLVM MinGW-w64.
[libmspack-xenia] lzxd.c: Cast pointer differences to int.
[microtar] microtar.c: fwrite() and fread() return size_t.
[libcachecommon] CacheKeys.hpp: Silence C4834 and gcc -Wunused-result
for cacheKeys.c_str().
[libromdata] ELF.cpp: Cast val_dtag[] to uint32_t.
[libromdata] EXE_NE.cpp: Cast ao::uvector<> sizes to uint32_t.
[libromdata/tests] microtar_zstd.c: Cast toCopy to unsigned when passing
it to microtar functions.
[librpfile] RpFile_scsi_win32.cpp: Windows 8.1 SDK's ntddscsi.h doesn't
properly declare _NV_SEP_WRITE_CACHE_TYPE as an enum.
[librptext/tests] TextFuncsTest: Silence warnings about implicit
conversoin from double to unsigned int by only doing integer
calculations. (It's done at compile time, not runtime.)
[librptexture] PowerVR3, ValveVTF3: Explicitly cast some size_t
calculations to unsigned int.
[win32] KeyManagerTab: Explicitly cast the return value from
std::count_if() to int.
CMAKE_DEBUG_POSTFIX wasn't being set, so the PDB filename ended up being
gtestpdb_debug_postfix-NOTFOUND.pdb.
Set CMAKE_DEBUG_POSTFIX="d" and CMAKE_RELEASE_POSTFIX="" when building
with MSVC. For other compilers, both are set to "".
Also disable some warnings that merely clutter up the logs and don't
help at all.
extlib/.clang-tidy: Attempt to disable header file scanning, but it
doesn't seem to work...
zlib-ng v2.1 has significant performance improvements compared to v2.0.
In particular, decompression can be up to 56% faster on amd64 when
using AVX2 instructions.
FIXME: RomHeaderTest infinite-loops on Xubuntu 16.04 32-bit with 1.5 GB
RAM due to memory allocation issues. microtar_zstd.c doesn't ever receive
an "out of memory" error...
Ubuntu 16.04 has CMake 3.5.1:
- DESCRIPTION was added in CMake 3.9.
- HOMEPAGE_URL was added in CMake 3.12.
CMake 3.5.1 incorrectly interprets these as programming languages and
gets very confused when it can't find .cmake files that describe how
to handle those "languages".
This was added in minizip-ng 4.0.0, so no rom-properties releases are
affected by this.