Commit Graph

72 Commits

Author SHA1 Message Date
Lasse Collin 842deba404
Windows: Embed an application manifest in the EXE files
IMPORTANT: This includes a security fix to command line tool
           argument handling.

Some toolchains embed an application manifest by default to declare
UAC-compliance. Some also declare compatibility with Vista/8/8.1/10/11
to let the app access features newer than those of Vista.

We want all the above but also two more things:

  - Declare that the app is long path aware to support paths longer
    than 259 characters (this may also require a registry change).

  - Force the code page to UTF-8. This allows the command line tools
    to access files whose names contain characters that don't exist
    in the current legacy code page (except unpaired surrogates).
    The UTF-8 code page also fixes security issues in command line
    argument handling which can be exploited with malicious filenames.

Thanks to Orange Tsai and splitline from DEVCORE Research Team
for discovering this issue.

Thanks to Vijay Sarvepalli for reporting the issue to me.

Thanks to Kelvin Lee for testing with MSVC and helping with
the required build system fixes.

(cherry picked from commit 46ee006162)
2024-10-01 13:22:32 +03:00
Lasse Collin 80f72396ea CMake: Bump maximum policy version to 3.29 2024-05-22 00:12:07 +03:00
Lasse Collin c5c091332c Update website URLs back to tukaani.org.
The XZ projects were moved back to their original URLs.

(cherry picked from commit 17aa2e1a79)
2024-05-22 00:12:07 +03:00
Lasse Collin 08754772e8 CMake: Use only the generic symbol versioning with NVIDIA HPC Compiler.
It doesn't support the __symver__ attribute or __asm__(".symver ...").
The generic symbol versioning can still be used since it only needs
linker support.

(cherry picked from commit c273123ed0)
2024-05-22 00:12:07 +03:00
Lasse Collin 78a015e753 CMake: Disable symbol versioning on non-glibc Linux.
This better matches what configure.ac does. For example, musl has
only basic symbol versioning support:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Symbol_versioning

configure.ac tries to enable symbol versioning only with glibc
so now CMake does the same.

(cherry picked from commit 2ad7fad670)
2024-05-22 00:11:58 +03:00
Lasse Collin 20e590bbed CMake: Make symbol versioning configurable.
(cherry picked from commit 82f0c0d39e)
2024-05-22 00:11:58 +03:00
Lasse Collin bcac3e3aa2 CMake: Handle symbol versioning on MicroBlaze specially.
This is to match configure.ac.

(cherry picked from commit 025eb6d787)
2024-05-22 00:11:58 +03:00
Jia Tan 3cc54f1c0b Build: Update website URL. 2024-01-24 21:13:10 +08:00
Lasse Collin 36fabdbe67 CMake: Use -D_FILE_OFFSET_BITS=64 if (and only if) needed.
A CMake option LARGE_FILE_SUPPORT is created if and only if
-D_FILE_OFFSET_BITS=64 affects sizeof(off_t).

This is needed on many 32-bit platforms and even with 64-bit builds
with MinGW-w64 to get support for files larger than 2 GiB.
2023-10-31 18:44:59 +08:00
Lasse Collin 989c8c354c CMake: Generate and install liblzma.pc if not using MSVC.
Autotools based build uses -pthread and thus adds it to Libs.private
in liblzma.pc. CMake doesn't use -pthread at all if pthread functions
are available in libc so Libs.private doesn't get -pthread either.
2023-10-31 18:44:59 +08:00
Lasse Collin 983f3b458d CMake: Rearrange the PACKAGE_ variables.
The windres workaround now replaces spaces with \x20 so
the package name isn't repeated.

These changes will help with creation of liblzma.pc.
2023-10-31 18:44:59 +08:00
Lasse Collin 661549ecb7 CMake: Create liblzma.def when building liblzma.dll with MinGW-w64. 2023-10-31 18:44:59 +08:00
Lasse Collin 0e546eb4da CMake: Change one CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.
In this case they have identical values.
2023-10-31 18:44:59 +08:00
Lasse Collin da4d04e4d6 CMake/Windows: Fix the import library filename.
Both PREFIX and IMPORT_PERFIX have to be set to "" to get
liblzma.dll and liblzma.dll.a.
2023-10-31 18:44:59 +08:00
Lasse Collin 007558a358 CMake: Don't shadow the cache entry ENABLE_THREADS with a normal variable.
Using set(ENABLE_THREADS "posix") is confusing because it sets
a new normal variable and leaves the cache entry with the same
name unchanged. The intent wasn't to change the cache entry so
this switches to a different variable name.
2023-10-31 18:44:59 +08:00
Lasse Collin 7d01de67ee CMake: Edit threading related messages.
It's mostly to change from "thread method" to "threading method".
2023-10-31 18:44:59 +08:00
Lasse Collin f8edcf3da6 CMake: Use FATAL_ERROR if user-supplied options aren't understood.
This way typos are caught quickly and compounding error messages
are avoided (a single typo could cause more than one error).

This keeps using SEND_ERROR when the system is lacking a feature
(like threading library or sandboxing method). This way the whole
configuration log will be generated in case someone wishes to
report a problem upstream.
2023-10-31 18:44:59 +08:00
Jia Tan 1695021e4a CMake: Add ALLOW_CLMUL_CRC option to enable/disable CLMUL.
The option is enabled by default, but will only be visible to a user
listing cache variables or using a CMake GUI application if the
immintrin.h header file is found.

This mirrors our Autotools build --disable-clmul-crc functionality.
2023-10-31 18:44:59 +08:00
Jia Tan 8fdc71a27d CMake: Rename xz and man page symlink custom targets.
The Ninja Generator for CMake cannot have a custom target and its
BYPRODUCTS have the same name. This has prevented Ninja builds on
Unix-like systems since the xz symlinks were introduced in
80a1a8bb83.
2023-10-31 18:44:59 +08:00
Lasse Collin 38171492de CMake: Fix Windows build with Clang/LLVM 17.
llvm-windres 17.0.0 has more accurate emulation of GNU windres, so
the hack for GNU windres must now be used with llvm-windres too.

LLVM 16.0.6 has the old behavior and there likely won't be more
16.x releases. So we can simply check for >= 17.0.0.

The workaround must not be used with Clang that is acting in
MSVC mode. This checks for the known environments that need
the workaround instead of using "NOT MSVC".

See also:
2bcc0fdc58
2023-10-31 18:44:59 +08:00
Jia Tan 46cb133ce7 CMake: Remove /lib from tests include path.
The tests never included anything from /lib, so this was not needed.
2023-10-31 18:44:59 +08:00
Lasse Collin b7ce6e8078 CMake: Wrap two overlong lines that are possible to wrap. 2023-10-31 18:44:59 +08:00
Lasse Collin 1595f454d5 CMake: Add a comment about threads on Cygwin. 2023-10-31 18:44:59 +08:00
Lasse Collin 5be6275f19 CMake: Bump maximum policy version to 3.27.
There are several new policies. CMP0149 may affect the Windows SDK
version that CMake will choose by default. The new behavior is more
predictable, always choosing the latest SDK version by default.

The other new policies shouldn't affect this package.
2023-10-31 18:44:58 +08:00
Jia Tan a70e96d2da CMake: Fix time.h checks not running on second CMake run.
If CMake was configured more than once, HAVE_CLOCK_GETTIME and
HAVE_CLOCK_MONOTONIC would not be set as compile definitions. The check
for librt being needed to provide HAVE_CLOCK_GETTIME was also
simplified.
2023-10-31 01:03:25 +08:00
Jia Tan d5275d83bd CMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.
If HAVE_CLOCK_GETTIME was defined, then HAVE_CLOCK_MONOTONIC was always
added as a compile definition even if the check for it failed.
2023-10-31 01:03:25 +08:00
Jia Tan bfb623ad96 CMake: Conditionally allow win95 threads and --enable-small. 2023-10-26 06:22:24 +08:00
Dimitri Papadopoulos Orfanos 0db6fbe0be Docs: Fix typos found by codespell 2023-08-01 18:44:02 +03:00
Jia Tan 962b3d41e0 CMake: Conditionally allow the creation of broken symlinks.
The CMake build will try to create broken symlinks on Unix and Unix-like
platforms. Cygwin and MSYS2 are Unix-like, but may not be able to create
broken symlinks. The value of the CYGWIN or MSYS environment variables
determine if broken symlinks are valid.

The default for MSYS2 does not allow for broken symlinks, so the CMake
build has been broken for MSYS2 since commit
80a1a8bb83.
2023-08-01 18:41:42 +03:00
Benjamin Buch d04eb78ab3 CMake: Protects against double find_package
Boost iostream uses `find_package` in quiet mode and then again uses
`find_package` with required. This second call triggers a
`add_library cannot create imported target "LibLZMA::LibLZMA"
because another target with the same name already exists.`

This can simply be fixed by skipping the alias part on secondary
`find_package` runs.
2023-07-18 13:02:02 +03:00
Jia Tan 32980d1562 CMake: Update liblzma-config.cmake generation.
Now that the threading is configurable, the liblzma CMake package only
needs the threading library when using POSIX threads.
2023-04-25 20:18:55 +08:00
Jia Tan 023907faa9 CMake: Allows setting thread method.
The thread method is now configurable for the CMake build. It matches
the Autotools build by allowing ON (pick the best threading method),
OFF (no threading), posix, win95, and vista. If both Windows and
posix threading are both available, then ON will choose Windows
threading. Windows threading will also not use:

target_link_libraries(liblzma Threads::Threads)

since on systems like MinGW-w64 it would link the posix threads
without purpose.
2023-04-25 20:18:45 +08:00
Jia Tan ba176d77cb CMake: Only build xzdec if decoders are enabled. 2023-04-25 20:18:31 +08:00
Lasse Collin 54a2fd8c85 CMake: Bump maximum policy version to 3.26.
It adds only one new policy related to FOLDERS which we don't use.
This makes it clear that the code is compatible with the policies
up to 3.26.
2023-04-25 20:18:08 +08:00
Jia Tan 622d0fdc02 CMake: Conditionally build xz list.* files if decoders are enabled. 2023-04-25 20:18:00 +08:00
Jia Tan 3e2dc523c5 CMake: Allow configuring features as cache variables.
This allows users to change the features they build either in
CMakeCache.txt or by using a CMake GUI. The sources built for
liblzma are affected by this too, so only the necessary files
will be compiled.
2023-04-25 20:17:49 +08:00
Jia Tan 01a67e89a5 CMake: Fix typo in a comment. 2023-03-18 00:41:09 +08:00
Lasse Collin 147d282cc3 CMake: Add microlzma_*.c to the build.
These should have been included in 5.3.2alpha already.
2023-03-17 20:19:34 +08:00
Jia Tan 5d351c69c1 Build: Adjust CMake version search regex.
Now, the LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, and LZMA_VERSION_PATCH
macros do not need to be on consecutive lines in version.h. They can be
separated by more whitespace, comments, or even other content, as long
as they appear in the proper order (major, minor, patch).
2023-03-07 23:57:39 +08:00
Lasse Collin 594f904673 CMake: Require that the C compiler supports C99 or a newer standard.
Thanks to autoantwort for reporting the issue and suggesting
a different patch:
https://github.com/tukaani-project/xz/pull/42
2023-03-07 23:25:12 +08:00
Jia Tan b9a3511bb6 CMake: Add LZIP decoder test to list of tests. 2023-03-07 23:23:41 +08:00
Jia Tan 85e01266a9 Tests: Create test_filter_str.c.
Tests lzma_str_to_filters(), lzma_str_from_filters(), and
lzma_str_list_filters() API functions.
2023-02-03 21:42:48 +08:00
Lasse Collin 65c59ad429 CMake/Windows: Add a workaround for windres from GNU binutils.
This is combined from the following commits in the master branch:
443dfebced
6b117d3b1f
5e34774c31

Thanks to Iouri Kharon for the bug report, the original patch,
and testing.
2023-01-10 08:50:26 +02:00
Lasse Collin ce3a3fbc7c CMake: Update cmake_minimum_required from 3.13...3.16 to 3.13...3.25.
The changes listed on cmake-policies(7) for versions 3.17 to 3.25
shouldn't affect this project.
2023-01-09 16:58:27 +02:00
Lasse Collin 3d45987451 CMake: Fix a copypaste error in xzdec Windows resource file handling.
It was my mistake. Thanks to Iouri Kharon for the bug report.
2023-01-09 16:58:27 +02:00
Lasse Collin 706bce5018 CMake/Windows: Add resource files to xz.exe and xzdec.exe.
The command line tools cannot be built with MSVC for now but
they can be built with MinGW-w64.

Thanks to Iouri Kharon for the bug report and the original patch.
2023-01-09 16:58:27 +02:00
Lasse Collin 52bc1ee34d Build: Require that _mm_set_epi64x() is usable to enable CLMUL support.
VS2013 doesn't have _mm_set_epi64x() so this way CLMUL gets
disabled with VS2013.

Thanks to Iouri Kharon for the bug report.
2023-01-09 16:58:27 +02:00
Jia Tan bad44cfe19 Tests: Creates test_index_hash.c
Tests all API functions exported from index_hash.h. Does not have a
dedicated test for lzma_index_hash_end.

[Minor edits were made by Lasse Collin.]
2023-01-09 16:56:07 +02:00
Jia Tan 9e3cb514b5 Build: No longer require HAVE_DECL_CLOCK_MONOTONIC to always be set.
Previously, if threading was enabled HAVE_DECL_CLOCK_MONOTONIC would always
be set to 0 or 1. However, this macro was needed in xz so if xz was not
built with threading and HAVE_DECL_CLOCK_MONOTONIC was not defined but
HAVE_CLOCK_GETTIME was, it caused a warning during build. Now,
HAVE_DECL_CLOCK_MONOTONIC has been renamed to HAVE_CLOCK_MONOTONIC and
will only be set if it is 1.
2023-01-05 00:26:35 +08:00
Lasse Collin 764955e2d4 Change the bug report address.
It forwards to me and Jia Tan.

Also update the IRC reference in README as #tukaani was moved
to Libera Chat long ago.
2022-11-30 18:08:34 +02:00