Initialize some variables, and use memcpy() instead of strncpy().
Remove the -Wno-error options. This broke on Debian 8 ppc (gcc-4.9.2),
which doesn't support -Wstringop-overflow or -Wstringop-truncation.
extlib/minizip-ng/compat/unzip.c: In function ‘unzGetFilePos’:
extlib/minizip-ng/compat/unzip.c:563:38: error: ‘file_pos64.pos_in_zip_directory’ may be used uninitialized [-Werror=maybe-uninitialized]
563 | file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:556:20: note: ‘file_pos64.pos_in_zip_directory’ was declared here
556 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:564:29: error: ‘file_pos64.num_of_file’ may be used uninitialized [-Werror=maybe-uninitialized]
564 | file_pos->num_of_file = (uint32_t)file_pos64.num_of_file;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:556:20: note: ‘file_pos64.num_of_file’ was declared here
556 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
cc1: all warnings being treated as errors
extlib/minizip-ng/mz_zip.c: In function ‘mz_zip_set_comment’:
extlib/minizip-ng/mz_zip.c:1569:5: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
1569 | strncpy(zip->comment, comment, comment_size);
| ^
extlib/minizip-ng/mz_zip.c:1563:29: note: length computed here
1563 | comment_size = (int32_t)strlen(comment);
| ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
This broke the Ubuntu 22.04 AppVeyor build:
extlib/minizip-ng/mz_compat.c: In function ‘unzGetFilePos’:
extlib/minizip-ng/mz_compat.c:1201:38: error: ‘file_pos64.pos_in_zip_directory’ may be used uninitialized [-Werror=maybe-uninitialized]
1201 | file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1194:20: note: ‘file_pos64.pos_in_zip_directory’ was declared here
1194 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1202:29: error: ‘file_pos64.num_of_file’ may be used uninitialized [-Werror=maybe-uninitialized]
1202 | file_pos->num_of_file = (uint32_t)file_pos64.num_of_file;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1194:20: note: ‘file_pos64.num_of_file’ was declared here
1194 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
cc1: all warnings being treated as errors
This broke the Ubuntu 22.04 AppVeyor build:
extlib/minizip-ng/mz_zip_rw.c: In function ‘mz_zip_reader_entry_save_file’:
extlib/minizip-ng/mz_zip_rw.c:668:5: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
668 | strncat(pathwfs, path, path_length);
| ^
extlib/minizip-ng/mz_zip_rw.c:662:19: note: length computed here
662 | path_length = strlen(path);
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
extlib/minizip-ng/mz_zip.c: In function ‘mz_zip_set_comment’:
extlib/minizip-ng/mz_zip.c:1574:5: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
1574 | strncpy(zip->comment, comment, comment_size);
| ^
extlib/minizip-ng/mz_zip.c:1568:29: note: length computed here
1568 | comment_size = (int32_t)strlen(comment);
| ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
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.
- 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.
- 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.
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.
minizip-ng:
extlib/minizip-ng/mz_os_posix.c: In function ‘mz_os_utf8_string_create’:
extlib/minizip-ng/mz_os_posix.c:94:63: warning: unused parameter ‘encoding’ [-Wunused-parameter]
94 | uint8_t *mz_os_utf8_string_create(const char *string, int32_t encoding) {
| ~~~~~~~~^~~~~~~~
rapidjson:
src/librpbase/TextOut_json.cpp:31:
extlib/rapidjson/include/rapidjson/document.h:102:19: warning:
‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
struct std::iterator’ is deprecated [-Wdeprecated-declarations]
102 | : public std::iterator<std::random_access_iterator_tag
| ^~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_algobase.h:65,
from /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/algorithm:60,
from src/librpbase/stdafx.h:28,
from src/librpbase/TextOut_json.cpp:10:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_iterator_base_types.h:127:34: note: declared here
127 | struct _GLIBCXX17_DEPRECATED iterator
| ^~~~~~~~
This causes issues on Xubuntu 16.04 if a system-wide zstd is installed
because extlib uses the internal version while minizip-ng tries using
the system version, and the system version isn't recent enough for
minizip-ng. (Requires 1.4.0; Xubuntu 16.04 has 1.3.1.)
Reference: https://fedoraproject.org/wiki/Format-Security-FAQ
-Werror=format-nonliteral is *not* enabled because there are some
legitimate uses of non-literal format strings.
Separated the warning flags into multiple variables.
Updated everything to build with this change.
I tested a release build and it saved a total of 10,752 bytes.
On the other hand, it had a rather huge maintenance overhead, since I had
to ensure that all extlibs had __cdecl set up in the headers properly,
and this had to be redone on every update.
The i386 build of LZ4 on AppVeyor was failing in tests because of missing
stdcall symbols. I decided not to bother adding stdcall support to LZ4
and simply revert stdcall entirely.