- `inline` isn't defined in C mode in MSVC 2010 and 2013.
(It might be in 2015 and 2017?)
- main() must be `__cdecl`, but we're defaulting to `__stdcall`
in 32-bit builds.
- myfileno(): Added a missing semicolon.
This broke the travis-ci build:
/usr/bin/ld: ../../../lib/../extlib/unice68/CMakeFiles/unice68_lib.dir/unice68_unpack.c.o:
relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
../../../lib/libunice68.a: error adding symbols: Bad value
I didn't see this locally because I was only building rpcli when testing
the SNDH unice68 functionality.
This significantly reduces the size of the test executables.
This can be done more easily on Windows than on other platforms because
Windows includes the program's directory as part of the DLL search path
by default.
NOTE: I was originally trying to fix a linkage issue with
g_linked_ptr_mutex that was showing up when building on MSVC 2010,
but that seems to have disappeared by itself...
References for the linkage issue:
- https://github.com/google/googletest/issues/292
- https://github.com/ornladios/ADIOS2/pull/477
- d9657bda86
Apparently Windows 7 without SP1 has O/S support for XSAVE but not for
YMM registers, and this exposed a bug in our usage of xgetbv. The test
instruction will set ZF only if none of the bits match between the two
operarands, so in effect, we were enabling AVX2 instructions if the O/S
supported XSAVE and the CPU supported AVX2 but the O/S only supported
XMM registers. This bug was not exposed on, for instance, Windows XP or
RHEL 5 because those O/S's do not support XSAVE.
Upstream commit:
d5f281b734
This fixes the build of unice68.
The unice68 executable can now be built in tree for testing purposes,
but it isn't built or installed as part of the normal build.
This will be used to decompress Atari ST SNDH files.
Note that unice68 is GPLv3, so there's a compile-time option to
disable it.
TODO: Make it a DLL/SO instead and use dlopen().
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.
Major changes include AVX2 optimizations and a vastly improved
CMakeLists.txt that works on all platforms.
This includes the JPEGCALL changes required for /Gz on 32-bit MSVC.
libjpeg-turbo.rc: Moved from sharedlib/ to win/.
https://github.com/nmoinvaz/minizip
[extlib] CMakeLists.txt: Disabled MiniZip compression. We're currently
only using it for decompression, so there's no need to build the
compression code, which wastes time and disk space.
- #include "config.librpbase.h" in order to define HAVE_ZLIB, which tells
mz_compat.h to #include <zlib.h>.
- #include <zlib.h> manually anyway.
- unz_file_info64.uncompressed_size is uint64_t, not uLong.
libintl.h: Disabled libgnuintl wrappers for printf() functions.
We don't need to use the GNU versions for anything, and it causes problems
if libgnuintl-8.dll is unavailable, since we can't use printf() to print
an error message in that case.
- Redefine snprintf() as _snprintf() on older versions of MSVC.
See c99-compat.msvcrt.h.
DelayLoadHelper.cmake: Delay-load libgnuintl-8.dll.
DelayLoadHelper.h: Added a 1-argument macro.
[win32] DllMain.cpp, DllGetClassObject() Fail if libgnuintl-8.dll can't
be loaded.
[rpcli] rpcli.cpp: Print an error message if libgnuintl-8.dll can't be
loaded.
- TODO: Print the program information.
[win32] ConfigDialog.cpp: Show an error message if libgnuintl-8.dll
can't be loaded.
- TODO: Move this to rp-config.c? Doing that will result in no error
message if rundll32.exe is used, though...
This should be the last thing needed for issue #122:
[win32] Build and link in GNU gettext or equivalent
This will fix some of the unit tests that aren't running because they
can't find libtinyxml2.6.dylib.
FIXME: #include <fstream> is still causing fseeko()/ftello() issues in
bmp.cpp, but not rpcli.cpp or properties.cpp...
loadmsgcat.c: Convert the filename from UTF-8 to UTF-16, then use
_wopen() to open the file.
[libi18n] i18n.c: Convert the filename to UTF-8 instead of ANSI.
gettext now works on Windows if non-ANSI characters are present in
rom-properties' path.
The gettext libraries and executables were built on Ubuntu 18.04 using
MinGW-w64 with gcc-7.3.0.
iconv support has been disabled for the runtime, but it's still needed
for some of the build executables. For that, we're using win-iconv, which
is an iconv wrapper that uses the Windows API. [1]
In addition, several patches from the official MinGW package repository
were applied to gettext-0.19.8.1 in order to get it to build correctly
for Windows. [2]
TODO:
- Test packaging to ensure the correct DLL is packaged.
- Test bindtextdomain() to determine if it supports Unicode. If it
doesn't, then another patch will be needed.
[1] https://github.com/win-iconv/win-iconv
[2] https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-gettext
This fixes NASM detection on Win64 if 64-bit NASM is installed and
hasn't been added to PATH.
This should fix issue #79. (cmake can't find NASM on Win 10)
https://github.com/nmoinvaz/minizip
Note that this release removes the AES-NI code, though we weren't
enabling encryption in the first place.
There's also some changes to use add_compile_options() and the
POSITION_INDEPENDENT_CODE property instead of manually setting
CMAKE_C_FLAGS and "-fpic -fPIC".
TODO: Use POSITION_INDEPENDENT_CODE in other libraries?
This adds INI_START_COMMENT_PREFIXES to allow changing start-of-line
comment characters. It also adds dynamic line buffer reallocation,
though it's disabled in rom-properties.
https://github.com/nmoinvaz/minizip
NOTE: The changes include removing the 16-bit size limitation, which only
really applies when building for DOS, but it was incorrectly set for all
platforms. I'm not going to change anything that uses it right now, though.
MiniZip already checks for libbsd, but doesn't fail if it's not found.
Added a failure if it's not found, and removed the broken FIND_PACKAGE()
call, which doesn't work because there's no CMake module for it.
https://github.com/nmoinvaz/minizip
An additional fix for unzOpen() hasn't been merged yet:
https://github.com/nmoinvaz/minizip/pull/207
Note that MiniZip 2.x uses UTF-8 for filenames on all platforms,
including Windows. I'm keeping the fill_win32_filefunc64W() call
in place just in case, though.
Bzip2, LZMA, ZipCrypto, and AES support are all disabled for now,
but the sources are still included.
I'm going to try using stdcall to build the 32-bit version, which should
save a bit of space and improve performance slightly. However, in order
to preserve ABI compatibility, exported C functions must have __cdecl,
and libjpeg-turbo doesn't do this.
JPEGCALL expands to __cdecl on MSVC and nothing on other compilers.
JPEGCALL has been added to function declarations and function pointers
in order to fix compilation with /Gz on MSVC.
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.
MSVC didn't properly support C99 until MSVC 2015, so the extra ';' makes
MSVC think that we've started adding statements. Hence, it fails because
there are still some variable declarations after it.
Commit: d507f2e7e8b771a76f4eb96d5c5d4dee50988196
Merge pull request #124 from Coeur/patch-3
The original MiniZip hasn't been updated in quite a while. This fork has
a lot of new functionality, including support for AES (though we aren't
using it). It also has some of the stuff I manually added before,
including CMakeLists.txt and Windows fixes.
FIXME: It's not compiling on MSVC 2010, probably due to declaring
variables after statements.
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.
Among other things, this update adds in reporting of the location oc
parsing errors, which was present in the original TinyXML but not
earlier versions of TinyXML2.
This adds a new function ini_parse_string(), which parses an INI file
from a loaded C string buffer.
Local changes, including ini_parse_w(), have been preserved.
This didn't seem to actually cause any problems, but it could result in
the statically-linked zlib being used in test suites in addition to the
DLL zlib.
Rebased CMakeLists.txt on the original TinyXML2 CMakeLists.txt,
but with lots of stuff disabled and some changes.
- Disable installation of everything except the DLL.
- Disable testing.
- Set TINYXML2_IMPORT as an interface definition when building
as a DLL.
- Remove TINYXML2_EXPORT in the static library build, which didn't
work anyway due to a typo.
- Added a debug postfix for debug DLLs.
- Disabled MSVC configuration that's alread yset in the platform
configuration.
- Added other MSVC options, including split debug settings.
TinyXML2 will be used to parse Windows manifests.
The Ubuntu 17.04 64-bit dynamic library build is around 83 KB, so
this won't add too much to the executable size.
TODO:
- Use the system TinyXML2 if available.
- Compile as a DLL? (with delay loading on Windows, maybe)
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 internal version of libjpeg-turbo currently only builds on Windows.
(The bundled CMakeLists.txt is Windows only.)
All example and demo executables have been disabled, and the autoconf
build system has been removed. The only target that builds now is
jpeg62.dll.
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.
zlib-1.2.9 seems to crash when using the asm optimizations on 32-bit
Windows. A zlib issue seems to indicate that previous versions had
issues as well: https://github.com/madler/zlib/issues/41
This causes zlib, libpng, and possibly others to not export any symbols
in either the .a or .so on Linux, which makes them unusable.
CheckHiddenVisibility.cmake: New macro CHECK_HIDDEN_VISIBILITY().
Use this in the upper-level source directory to apply hidden visibility
to all subprojects. Used in src/CMakeLists.txt.
[extlib] CMakeLists.txt: Remove SET_MSVC_DEBUG_PATH() from the
SET_EXTLIB_PROPERTIES() macro.
[minizip] Removed EXCLUDE_FROM_ALL, since this is handled by the
extlib/CMakeLists.txt file.
NOTE: We can't move DO_SPLIT_DEBUG() out of the individual extlib
directories, since CMake complains if we attempt to use it on targets
created in a different directory.
CPack doesn't like using the PDB property for some reason, so we have to
manually build the pathname using the correct postfix. Also, install both
debug and release PDBs with the "optional" tag so it won't fail if one is
missing (and one is always missing because we're only building either
Debug or Release).
Set -DPNG_DEBUG=0 in debug builds. This tells pngwin.rc to append "D"
to the filename, but doesn't actually enable the debugging macros,
which we don't need.
Set BUILD_SHARED_LIBRARIES=ON to do this.
Note that the default filename for the debug version is zlibd1.dll,
which doesn't make sense. It should be zlib1d.dll.
SetMSVCDebugPath.cmake: Add PREFIX and POSTFIX even if OUTPUT_NAME
is set, since libpng sets PREFIX to "lib" for consistency with other
operating systems. (Both set POSTFIX to "d" in debug builds.)
I'll eventually make them delayload so they won't be loaded unless they're
actually needed.
Rearranged the build directory layout such that all binaries are located
in the top-level bin/ directory. This is needed in order for the test
suites to work, since they might depend on zlib and/or libpng.
NOTE: We have to use CACHE INTERNAL; otherwise, the KDE5 build ignores
the directory options. (Maybe this is why the KDE4 build always used
this directory layout in the first place?)
NOTE 2: On Windows, DLLs are copied to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY},
whereas on Linux, SOs are copied to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}.
Test images are now copied using a custom command, since the output
directory isn't easily determined at generate time. (It could be
the same as ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}, but msbuild uses
configuration-specific subdirectories.
TODO: Keep test images in a subdirectory. This will need adjustments in
the test suites to look in img/ first, then the current directory.
Added a CPUID check to disable SSE2 functionality if the system
doesn't support it.
The following are changes respective to the original Intel patch:
pngpriv.h: Disable compiler checks for SSE2, since we're conditionally
enabling it only on filter_sse2_intrinsics.c to prevent issues on
systems that don't have SSE2.
intel_init.c: Added CPUID checking for MSVC and gcc. (TODO test gcc)
filter_sse2_intrinsics.c: Added casting for some variables. For MSVC
versions older than 2015, we need to compile with /TP, since older
MSVC doesn't support declaring variables after statements in C mode.
C++ doesn't support some types of implicit casting, so we have to make
it explicit.
I've decided to get rid of the GDI+ PNG handling. It doesn't improve
anything performance-wise, adds coding overhead, and probably isn't
any faster than libpng.
GDI+ also doesn't support APNG. This version does.
NOTE: If I add APNG export, I'll need to use the included libpng
in Ubuntu builds, since Ubuntu still has libpng-1.2, and it's a
version that doesn't support APNG.
Reworked the bundled library system to be similar to the one in
mcrecover, but improved.
Added "-fpic -fPIC" to all extlib static libraries when building
for Linux systems. This is needed for libpng, but might not be
needed for other libraries; nevertheless, it should be set.
TODO: Use libpng in the Windows build. It's being linked in,
but it isn't actually being used for anything yet.
Interface include paths are needed in order to automatically add paths
when adding minizip as a dependent library.
DO_SPLIT_DEBUG() breaks the static library:
../../../extlib/minizip/libminizip.a: error adding symbols: Archive has no index; run ranlib to add one
This function sets common properties on extlib targets.
[zlib] Remove the MSVC debug path and build exclusion settings, since
these are now set by the parent CMakeLists.txt file.
msvc.cmake: Specify MASM flags "/W0 /safeseh". This fixes the 32-bit masm
build when using MSBUILD with MSVC 2015. 64-bit wasn't affected, though
we're setting it for all MSVC platforms.
libromdata/tests/CMakeLists.txt:
- Link to gtest directly instead of ${GTEST_LIBRARY}.
- Removed INCLUDE_DIRECTORIES() for googletest, since it's added to
TARGET_INCLUDE_DIRECTORIES() by googletest's CMakeLists.txt.
extlib/googletest/googletest/CMakeLists.txt:
- Uncommented gtest_hide_internal_symbols.
Removed cmake/gtest.cmake, since it doesn't have anything useful other
than INCLUDE(CTest), which is now present in the top-level CMakeLists.txt.
Unlike the aforementioned two programs, this copy of zlib will *only*
be used for Windows builds, and it will only be used for test suites.
We're using GDI+ instead of libpng, so the only reason we need zlib
is to decompress the compressed reference BMP images used by
RpImageLoaderTest.
Changes compared to upstream zlib-1.2.8:
- Non-CMake build infratsructure has been removed.
- CMakeLists.txt has been edited to prevent building the Win32 resource
data when being built as a shared library.
- Example binaries are no longer built.
- The GZip functions are now prefixed with "mcr_z_" in order to prevent
function naming conflicts with Qt4/Win32, which has its own copy of
zlib that exposes the same functions.
- The OF() and ON() macros have been renamed to _Z_OF() and _Z_ON().
Based on Gentoo's zlib-1.2.8 patches.
- contrib/ has been stripped of everything but asm-optimized functions.
- 64-bit assembly-optimized routines now check for __x86_64__ in addition
to __amd64__ for compatibility with certain compilers, e.g. icc.
- CMakeLists.txt adds -DZLIB_CONST to the zlib and zlibstatic targets'
compile definitions.
Google Test will be used for implementing unit tests. The first set of
unit tests will be for testing RpPng with various PNG image formats.
The Google Test code is currently identical to the release archive,
except for the removal of .travis.yml and appveyor.xml.
CMakeLists.txt: Added CTest support. (see cmake/gtest.cmake)
extlibs/CMakeLists.txt: Only build googletest libraries if testing is
enabled and some project depends on them.