Port upstream commit 6cf33c93 (Issue 320: Rewrite (again) to avoid
the left shift that CLang dislikes so much, 2013-12-07) into CMake.
Inspired-by: Tim Kientzle <kientzle@freebsd.org>
Port upstream commit 533e8fda (Rework the sign-extension to avoid
left-shift of an explicit negative number, 2013-06-29) into CMake.
Inspired-by: Tim Kientzle <kientzle@freebsd.org>
Since commit 7d47c693 (Drop compatibility with CMake < 2.4, 2013-10-08)
we no longer need to use the configure_file IMMEDIATE option to support
compatibility modes less than 2.0.
Apple distributes their own Clang build with their own version numbers
that differ from upstream Clang. Use the __apple_build_version__ symbol
to identify the Apple Clang compiler and report the Apple Build Version
as the fourth version component in CMAKE_<LANG>_COMPILER_VERSION. Add
Compiler/AppleClang-<lang> and Platform/Darwin-AppleClang-<lang> modules
that simply include the upstream equivalents.
Fix comparisons of CMAKE_<LANG>_COMPILER_ID to Clang in CMake's own
source and tests to account for AppleClang.
Ensure CMAKE_DATA_DIR, CMAKE_DOC_DIR, and CMAKE_MAN_DIR are always
relative paths in CMake code, and set defaults accordingly. Use the
install() command instead of install_files() and install_targets().
This is more modern and also avoids stripping of the first character
from user-specified destinations.
While at it, fix the default destinations reported in the bootstrap
help.
Avoid requiring CMake 2.8.6 for CMakePushCheckState or CMake 2.8.8 for
CMakeExpandImportedTargets. Drop the custom versions of CMake modules
CheckCSource(Compiles|Runs) because we do not use the SAFESEH option
anyway.
Follow up change from commit ffa6faa4 (libarchive: Include cm_zlib.h to
get zlib used by CMake, 2011-12-20) for new includes of zlib.h in
updated libarchive.
The archive_string_conv type sc variable already freed via free(sc) on
the other hand in second line we are tyring to free its subset via
free(sc->from_charset) this will cause a problem because we couldn't
reach sc after first release.
Reviewed-by: Igor Murzov <e-mail@date.by>
caught by clang's -fsanitize=shift. A small unsigned int was
promoted, according to C's regular promotion rules, to a signed
int, it was then left shifted. This sometimes pushed a 1 into
the sign bit, which is undefined behaviour. Fixed by using
unsigned temporaries.
Update the requirement specified in the top-level CMakeLists.txt file.
Drop the special-case minimum required version of 2.8.0 because the new
minimum subsumes it.
Revert commit 6c611c6b (libarchive: Restore CMake 2.6.3 as minimum
version, 2012-01-05) since our requirement now subsumes libarchive's.
The CMake TarTest fails with the error
mbsnrtowcs.c:116: __mbsnrtowcs: Assertion
`status == GCONV_OK || status != GCONV_EMPTY_INPUT ||
status == GCONV_ILLEGAL_INPUT || status == GCONV_INCOMPLETE_INPUT ||
status == GCONV_FULL_OUTPUT' failed.
on very old glibc versions. Work around the problem by pretending that
mbsnrtowcs does not exist. Libarchive will fall back to mbrtowc.
Use the approach originally used in commit f91b3c1d (Add options to
build with system utility libraries, 2006-10-19) for all other
third-party libraries. Create a "cm_bzlib.h" header wrapper that
robustly includes the header from the bzip2 library chosen for the CMake
build (either builtin or system version). Include the header wrapper
anywhere we need the API provided by <bzlib.h>.
Upstream libarchive now requires CMake 2.8 to get the newer add_test
functionality. Since we do not build libarchive's tests we do not
need the requirement.
We cannot suppress PGI compiler warnings completely because even with
the "-w" flag the compiler still writes a message containing "compilation
completed with warnings" to stderr.
A warning is triggered by expressions like
test ? NULL : ptr_to_const_char
test ? ".." : ptr_to_const_char
that the PGI compiler handles incorrectly. It chooses the pointer type
of the first option (either void* or char*) and warns about conversion
of the second without a cast. Flip the expression logic to
!test ? ptr_to_const_char : NULL
!test ? ptr_to_const_char : ".."
to help the compiler choose the proper result type.
The HP-UX <wchar.h> header provides 'mbstate_t' in C89/C90 mode only if
_XOPEN_SOURCE is defined to exactly 500. Type 'mbstate_t' was
introduced in C89/C90 Normative Amendment 1, aka C94/C95, adding support
international character sets. It is part of C99 but not C89/C90.
Configure the result as definition HAVE_STRUCT_STATVFS_F_IOSIZE and use
the member only if it exists. At least one platform (IRIX) provides
struct statvfs without this member.
VS 6 warns verbosely when WINVER >= 0x0500. Avoid defining WINVER and
_WIN32_WINNT to higher than 0x0400 on VS 6. Provide missing API
declarations in archive_windows.h when we do not get them from
<windows.h>. Provide GetVolumePathNameW because VS 6 does not declare
it regardless of the API version.
At least one compiler (Borland) defines mode_t as just "short" which is
signed. This breaks code like
switch(archive_entry_filetype(e)) {
case AE_IFREG:
...
}
if AE_IFREG and other constants have a longer signed type (int) because
sign extension of the mode_t return type from archive_entry_filetype
changes its value. Avoid the problem by ensuring the type of the
constants matches mode_t.
This change was originally made in commit a73acfbe (Fix for mode_t with
signed types, 2009-11-07). Port it to the new libarchive snapshot.
Mangle the open_FILE symbols to avoid conflict with open_file:
Warning: public '_archive_read_open_file'
in module 'archive_read_open_filename.c' clashes with
prior module 'archive_read_open_file.c'
Warning: public '_archive_write_open_file'
in module 'archive_write_open_filename.c' clashes with
prior module 'archive_write_open_file.c'
This workaround should not go upstream because it will break when
mixing compilers.
Restore Windows 64-bit lseek removed by upstream svn revision 3826
(Cast away __la_lseek(), use _lseeki64() instead, 2011-11-21). We
need it on Borland.
Make changes equivalent to those originally made by commits
bd56626a (Fixes for the OSF operating system build, 2010-09-08)
92c082b1 (Add a fix for the inline keyword on the osf os, 2010-09-10)
but based on the updated libarchive snapshot.
Remove add_subdirectory() calls for directories not included in the
reduced libarchive snapshot. Remove options that configure settings in
the missing directories.
This version of MinGW defines _SSIZE_T_ for ssize_t. This patch is
based on upstream libarchive SVN commit 3649 (Fix build with mingwrt
3.20, 2011-08-27).
Inspired-by: Tim Kientzle <kientzle@freebsd.org>
OpenSSL is not part of the Linux Standard Base but its headers and
libraries may still be found at build time even though they may not be
available at runtime. Use it only if explicitly allowed.
If neither MAJOR_IN_MKDEV or MAJOR_IN_SYSMACROS is defined then provide
our own implementation of these macros locally. This complements the
change in commit cf5ad183 (Fix major() check for LSB 4.0, 2011-01-12).
This patch is based on upstream libarchive SVN commit 1553 (Shuffle the
major/minor/makedev support a bit; this should work on both Windows and
Haiku, 2009-10-31).
Inspired-by: Tim Kientzle <kientzle@freebsd.org>
The LSB header files define major() as a macro but if it is ever called
the macro references symbols not available at link time. Improve the
test for major() to actually call the macro and try to link. This
approach is based on upstream libarchive SVN commit 2866 which fixed
libarchive issue 125, submitted in response to CMake issue #11648.
Inspired-by: Tim Kientzle <kientzle@freebsd.org>
Dereferencing a 0-pointer is undefined behavior, not a deterministic
crash. Use a 1-pointer instead. This also avoids a warning by Clang
about the undefined behavior.
At least one version of GNU tar (1.15.1 with Fedora patches) does not
recognize these attributes and exits with error. Do not generate them.
Patch from upstream libarchive svn r2563.
We use CHECK_TYPE_SIZE in libarchive to check for the existence of some
types. For universal binary builds on the Mac, the size check can fail
if it is inconsistent across architectures. However, we do not actually
need the size so it is safe to do the checks for only one architecture.
See issue #9913.
In libarchive/archive_platform.h we should include <stdint.h> or
<inttypes.h> immediately after "config.h" to define integer types
referenced by configuration results. For example, on a non-conformant
platform ssize_t might default to int64_t, so int64_t must be defined
before ssize_t is used (and ssize_t is used in archive_windows.h).
In libarchive we configure an internal header file called 'config.h'.
This commits moves the include directory containing the file to the
beginning of the include path to avoid conflicts from system headers.
The commit "libarchive: Define _XOPEN_SOURCE for get(pwu|grg)id_r"
introduced a comment referring to get(pwu|grg)id_r in a source file that
actually uses the functions get(pw|gr)name_r. We fix the comment.
The "result" argument to functions get(pwu|grg)id_r and get(pw|gr)name_r
does not appear in the signatures provided on older platforms. We set
the pointer to the result memory in case the function ignores it, thus
ensuring initialization.