]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
7 months agoWindows: Document the need for setlocale(LC_ALL, ".UTF8")
Lasse Collin [Tue, 17 Dec 2024 13:01:29 +0000 (15:01 +0200)] 
Windows: Document the need for setlocale(LC_ALL, ".UTF8")

Also warn about unpaired surrogates and (somewhat UTF-8-specific)
MAX_PATH issue in FindFirstFileA().

Fixes: 46ee0061629fb075d61d83839e14dd193337af59
7 months agoxzdec: Call tuklib_progname_init() early enough
Lasse Collin [Wed, 18 Dec 2024 12:12:22 +0000 (14:12 +0200)] 
xzdec: Call tuklib_progname_init() early enough

If the early pledge() call on OpenBSD fails, it calls my_errorf()
which requires the "progname" variable.

Fixes: d74fb5f060b76db709b50f5fd37490394e52f975
7 months agoCMake: Bump maximum policy version to 3.31
Lasse Collin [Sun, 15 Dec 2024 17:08:32 +0000 (19:08 +0200)] 
CMake: Bump maximum policy version to 3.31

With CMake 3.31, there were a few warnings from
CMP0177 "install() DESTINATION paths are normalized".
These occurred because the install(FILES) command in
my_install_man_lang() is called with a DESTINATION path
that contains two consecutive slashes, for example,
"share/man//man1". Such a path is for the English man pages.
With translated man pages, the language code goes between
the slashes. The warning was probably triggered because the
extra slash gets removed by the normalization.

7 months agoUpdate THANKS
Lasse Collin [Sun, 15 Dec 2024 16:35:27 +0000 (18:35 +0200)] 
Update THANKS

7 months agoliblzma: Fix incorrect macro name in a comment
Dexter Castor Döpping [Sun, 8 Dec 2024 17:24:29 +0000 (18:24 +0100)] 
liblzma: Fix incorrect macro name in a comment

Fixes: 33b8a24b6646a9dbfd8358405aec466b13078559
Closes: https://github.com/tukaani-project/xz/pull/155
7 months agolicense-check.sh: Add an exception for doc/SHA256SUMS
Lasse Collin [Tue, 17 Dec 2024 08:36:43 +0000 (10:36 +0200)] 
license-check.sh: Add an exception for doc/SHA256SUMS

Fixes: 36b531022f24a2ab57a2dfb9e5052f1c176e9d9a
8 months agodoc/SHA256SUMS: Add the list of SHA-256 hashes of release files
Lasse Collin [Sun, 1 Dec 2024 19:38:17 +0000 (21:38 +0200)] 
doc/SHA256SUMS: Add the list of SHA-256 hashes of release files

The release files are signed but verifying the signatures cannot
catch certain types of attacks:

1. A malicious maintainer could make more than one variant of
   a package. One could be for general distribution. Another
   with malicious content could be targeted to specific users,
   for example, distributing the malicious version on a mirror
   controlled by the attacker.

2. If the signing key of an honest maintainer was compromised
   without being detected, a similar situation as described
   above could occur.

SHA256SUMS could be put on the project website but having it in
the Git repository makes it obvious that old lines aren't modified
when the file is updated.

Hashes of uncompressed files are included too. This way tarballs
can be recompressed and the hashes can still be verified.

8 months agoDocs: Remove .github/SECURITY.md
Lasse Collin [Sat, 30 Nov 2024 10:05:59 +0000 (12:05 +0200)] 
Docs: Remove .github/SECURITY.md

One of the reasons to have this file in the xz repository was to
show vulnerability reporting info in the Security section on GitHub.
On 2024-11-25, I added SECURITY.md to the tukaani-project organization
on GitHub:

    https://github.com/tukaani-project/.github/blob/main/SECURITY.md

GitHub shows that file in all projects in the organization unless
overridden by a project-specific SECURITY.md. Thus, removing
the file from the xz repo makes GitHub show the organization-wide
text instead.

Maintaining a single copy for the whole GitHub organization makes
things simpler. It's also nicer to have fewer GitHub-specific files
in the xz repo. Information how to report bugs (including security
issues) is available in README and on the home page too.

The OpenSSF Scorecard tool didn't find .github/SECURITY.md from the
xz repository. There was a suggestion to move the file to the top-level
directory where Scorecard should find it. However, Scorecard does find
the organization-wide SECURITY.md. Thus, the file isn't needed in the
xz repository to score points in the Scorecard game:

    https://scorecard.dev/viewer/?uri=github.com/tukaani-project/xz

Closes: https://github.com/tukaani-project/xz/issues/148
Closes: https://github.com/tukaani-project/xz/pull/149
8 months agoTranslations: Update the Chinese (traditional) translation
Lasse Collin [Sat, 30 Nov 2024 08:27:14 +0000 (10:27 +0200)] 
Translations: Update the Chinese (traditional) translation

8 months agoliblzma: Optimize the loop conditions in BCJ filters
Lasse Collin [Wed, 30 Oct 2024 17:54:34 +0000 (19:54 +0200)] 
liblzma: Optimize the loop conditions in BCJ filters

Compilers cannot optimize the addition "i + 4" away since theoretically
it could overflow.

8 months agoUpdate THANKS
Lasse Collin [Mon, 25 Nov 2024 14:26:54 +0000 (16:26 +0200)] 
Update THANKS

8 months agoxz: Landlock: Fix a file descriptor leak
Mark Wielaard [Mon, 25 Nov 2024 10:28:44 +0000 (12:28 +0200)] 
xz: Landlock: Fix a file descriptor leak

10 months agoCI: update FreeBSD, NetBSD, OpenBSD, Solaris actions
Sam James [Wed, 2 Oct 2024 02:04:03 +0000 (03:04 +0100)] 
CI: update FreeBSD, NetBSD, OpenBSD, Solaris actions

Checked the changes and they're all innocuous. This should hopefully
fix the "externally managed" pip error in these jobs that started
recently.

10 months agoAdd NEWS for 5.6.3
Lasse Collin [Tue, 1 Oct 2024 09:17:39 +0000 (12:17 +0300)] 
Add NEWS for 5.6.3

10 months agocmake/tuklib_large_file_support.cmake: Add a missing include
Lasse Collin [Tue, 1 Oct 2024 11:49:41 +0000 (14:49 +0300)] 
cmake/tuklib_large_file_support.cmake: Add a missing include

v5.2 didn't build with CMake. Other branches had
include(CMakePushCheckState) in top-level CMakeLists.txt
which made the build work.

Fixes: 597f49b61475438a43a417236989b2acc968a686
10 months agoUpdate THANKS
Lasse Collin [Tue, 1 Oct 2024 09:10:23 +0000 (12:10 +0300)] 
Update THANKS

10 months agoTests/Windows: Add the application manifest to the test programs
Lasse Collin [Tue, 1 Oct 2024 09:10:23 +0000 (12:10 +0300)] 
Tests/Windows: Add the application manifest to the test programs

This ensures that the test programs get executed the same way as
the binaries that are installed.

10 months agolicense-check.sh: Add an exception for w32_application.manifest
Lasse Collin [Tue, 1 Oct 2024 09:10:23 +0000 (12:10 +0300)] 
license-check.sh: Add an exception for w32_application.manifest

The file gets embedded as is into executables, thus it cannot
hold a license identifier.

10 months agoWindows: Embed an application manifest in the EXE files
Lasse Collin [Tue, 1 Oct 2024 09:10:23 +0000 (12:10 +0300)] 
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.
    See the new file w32_application.manifest.comments.txt.

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.

10 months agoWindows: Set DLL name accurately in StringFileInfo on Cygwin and MSYS2
Lasse Collin [Sun, 29 Sep 2024 11:46:52 +0000 (14:46 +0300)] 
Windows: Set DLL name accurately in StringFileInfo on Cygwin and MSYS2

Now the information in the "Details" tab in the file properties
dialog matches the naming convention of Cygwin and MSYS2. This
is only a cosmetic change.

10 months agocommon_w32res.rc: White space edits
Lasse Collin [Wed, 25 Sep 2024 12:47:55 +0000 (15:47 +0300)] 
common_w32res.rc: White space edits

LANGUAGE and VS_VERSION_INFO begin new statements so put an empty line
between them.

10 months agoCMake: Add the resource files to the Cygwin and MSYS2 builds
Lasse Collin [Sat, 28 Sep 2024 17:09:50 +0000 (20:09 +0300)] 
CMake: Add the resource files to the Cygwin and MSYS2 builds

Autotools-based build has always done this so this is for consistency.

However, the CMake build won't create the DEF file when building
for Cygwin or MSYS2 because in that context it should be useless.
(If Cygwin or MSYS2 is used to host building of normal Windows
binaries then the DEF file is still created.)

10 months agoCMake: Fix Windows resource file dependencies
Lasse Collin [Sat, 28 Sep 2024 12:19:14 +0000 (15:19 +0300)] 
CMake: Fix Windows resource file dependencies

If common_w32res.rc is modified, the resource files need to be rebuilt.
In contrast, the liblzma*.map files truly are link dependencies.

10 months agoCMake: Checking for CYGWIN covers MSYS2 too
Lasse Collin [Sat, 28 Sep 2024 22:20:03 +0000 (01:20 +0300)] 
CMake: Checking for CYGWIN covers MSYS2 too

On MSYS2, both CYGWIN and MSYS are set.

10 months agoTranslations: Add the SPDX license identifier to pt_BR.po
Lasse Collin [Sat, 28 Sep 2024 06:37:30 +0000 (09:37 +0300)] 
Translations: Add the SPDX license identifier to pt_BR.po

10 months agoWindows/CMake: Use the correct resource file for lzmadec.exe
Lasse Collin [Wed, 25 Sep 2024 13:41:37 +0000 (16:41 +0300)] 
Windows/CMake: Use the correct resource file for lzmadec.exe

CMakeLists.txt was using xzdec_w32res.rc for both xzdec and lzmadec.

Fixes: 998d0b29536094a89cf385a3b894e157db1ccefe
10 months agoTranslations: Update the Brazilian Portuguese translation
Lasse Collin [Wed, 25 Sep 2024 18:29:59 +0000 (21:29 +0300)] 
Translations: Update the Brazilian Portuguese translation

10 months agoUpdate THANKS
Lasse Collin [Mon, 16 Sep 2024 22:21:15 +0000 (01:21 +0300)] 
Update THANKS

10 months agolzmainfo: Avoid integer overflow
Tobias Stoeckmann [Mon, 16 Sep 2024 21:19:46 +0000 (23:19 +0200)] 
lzmainfo: Avoid integer overflow

The MB output can overflow with huge numbers. Most likely these are
invalid .lzma files anyway, but let's avoid garbage output.

lzmadec was adapted from LZMA Utils. The original code with this bug
was written in 2005, over 19 years ago.

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
Closes: https://github.com/tukaani-project/xz/pull/144
10 months agoxzdec: Remove unused short option -M
Tobias Stoeckmann [Mon, 16 Sep 2024 20:04:40 +0000 (22:04 +0200)] 
xzdec: Remove unused short option -M

"xzdec -M123" exited with exit status 1 without printing
any messages. The "M:" entry should have been removed when
the memory usage limiter support was removed from xzdec.

Fixes: 792331bdee706aa852a78b171040ebf814c6f3ae
Closes: https://github.com/tukaani-project/xz/pull/143
[ Lasse: Commit message edits ]

10 months agoUpdate THANKS
Lasse Collin [Tue, 10 Sep 2024 10:54:47 +0000 (13:54 +0300)] 
Update THANKS

10 months agoBuild: Fix a typo in autogen.sh
Firas Khalil Khana [Tue, 10 Sep 2024 09:30:32 +0000 (12:30 +0300)] 
Build: Fix a typo in autogen.sh

Fixes: e9be74f5b129fe8a5388d588e68b1b7f5168a310
Closes: https://github.com/tukaani-project/xz/pull/141
11 months agoTranslations: Update Chinese (simplified) translation
Lasse Collin [Mon, 2 Sep 2024 17:08:40 +0000 (20:08 +0300)] 
Translations: Update Chinese (simplified) translation

Differences to the zh_CN.po file from the Translation Project:

  - Two uses of \v were fixed.

  - Missing "OPTS" translation in --riscv[=OPTS] was copied from
    previous lines.

  - "make update-po" was run to remove line numbers from comments.

11 months agoTranslations: Update the Catalan translation
Lasse Collin [Mon, 2 Sep 2024 16:40:50 +0000 (19:40 +0300)] 
Translations: Update the Catalan translation

Differences to the ca.po file from the Translation Project:

  - An overlong line translating --filters-help was wrapped.

  - "make update-po" was used to remove line numbers from the comments
    to match the changes in fccebe2b4fd513488fc920e4dac32562ed3c7637
    and 093490b58271e9424ce38a7b1b38bcf61b9c86c6. xz.pot in the TP
    is older than these commits.

11 months agoUpdate THANKS
Lasse Collin [Thu, 22 Aug 2024 11:06:16 +0000 (14:06 +0300)] 
Update THANKS

11 months agoCMake: Don't install lzmadec.1 symlinks if XZ_TOOL_LZMADEC=OFF
Lasse Collin [Thu, 22 Aug 2024 11:06:16 +0000 (14:06 +0300)] 
CMake: Don't install lzmadec.1 symlinks if XZ_TOOL_LZMADEC=OFF

Thanks-to: 榆柳松 (ZhengSen Wang) <wzhengsen@gmail.com>
Fixes: fb50c6ba1d4c9405e5b12b5988b01a3002638c5d
Closes: https://github.com/tukaani-project/xz/pull/134
11 months agoCMake: Fix the build when XZ_TOOL_LZMADEC=OFF
Lasse Collin [Thu, 22 Aug 2024 11:06:16 +0000 (14:06 +0300)] 
CMake: Fix the build when XZ_TOOL_LZMADEC=OFF

Co-developed-by: 榆柳松 (ZhengSen Wang) <wzhengsen@gmail.com>
Fixes: fb50c6ba1d4c9405e5b12b5988b01a3002638c5d
Fixes: https://github.com/tukaani-project/xz/pull/134
11 months agoUpdate THANKS
Lasse Collin [Thu, 22 Aug 2024 08:01:07 +0000 (11:01 +0300)] 
Update THANKS

11 months agoliblzma: Fix x86-64 movzw compatibility in range_decoder.h
Yifeng Li [Thu, 22 Aug 2024 02:18:49 +0000 (02:18 +0000)] 
liblzma: Fix x86-64 movzw compatibility in range_decoder.h

Support for instruction "movzw" without suffix in "GNU as" was
added in commit [1] and stabilized in binutils 2.27, released
in August 2016. Earlier systems don't accept this instruction
without a suffix, making range_decoder.h's inline assembly
unable to build on old systems such as Ubuntu 16.04, creating
error messages like:

    lzma_decoder.c: Assembler messages:
    lzma_decoder.c:371: Error: no such instruction: `movzw 2(%r11),%esi'
    lzma_decoder.c:373: Error: no such instruction: `movzw 4(%r11),%edi'
    lzma_decoder.c:388: Error: no such instruction: `movzw 6(%r11),%edx'
    lzma_decoder.c:398: Error: no such instruction: `movzw (%r11,%r14,4),%esi'

Change "movzw" to "movzwl" for compatibility.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c07315e0c610e0e3317b4c02266f81793df253d2

Suggested-by: Lasse Collin <lasse.collin@tukaani.org>
Tested-by: Yifeng Li <tomli@tomli.me>
Signed-off-by: Yifeng Li <tomli@tomli.me>
Fixes: 3182a330c1512cc1f5c87b5c5a272578e60a5158
Fixes: https://github.com/tukaani-project/xz/issues/121
Closes: https://github.com/tukaani-project/xz/pull/136
12 months agoBuild: Comment that elf_aux_info(3) will be available on OpenBSD >= 7.6
Lasse Collin [Fri, 19 Jul 2024 17:02:43 +0000 (20:02 +0300)] 
Build: Comment that elf_aux_info(3) will be available on OpenBSD >= 7.6

12 months agoRevert "liblzma: Add ARM64 CRC32 instruction support detection on OpenBSD"
Lasse Collin [Fri, 19 Jul 2024 16:42:26 +0000 (19:42 +0300)] 
Revert "liblzma: Add ARM64 CRC32 instruction support detection on OpenBSD"

This reverts commit dc03f6290f5b9bd3d50c7e12e58dee870889d599.

OpenBSD 7.6 will support elf_aux_info(3), and the detection code used
on FreeBSD will work on OpenBSD 7.6 too. Keep things simpler and drop
the OpenBSD-specific sysctl() method.

Thanks to Christian Weisgerber.

12 months agoliblzma: Tweak a comment
Lasse Collin [Sat, 13 Jul 2024 19:10:37 +0000 (22:10 +0300)] 
liblzma: Tweak a comment

12 months agoCMake: Bump maximum policy version to 3.30
Lasse Collin [Thu, 11 Jul 2024 19:17:56 +0000 (22:17 +0300)] 
CMake: Bump maximum policy version to 3.30

12 months agoCMake: Require CMake 3.20 or later
Lasse Collin [Sat, 6 Jul 2024 12:13:19 +0000 (15:13 +0300)] 
CMake: Require CMake 3.20 or later

This allows a few cleanups.

13 months agoUpdate THANKS
Lasse Collin [Tue, 9 Jul 2024 11:27:51 +0000 (14:27 +0300)] 
Update THANKS

13 months agoxz: Remove the TODO comment about --recursive
Lasse Collin [Sat, 6 Jul 2024 11:04:48 +0000 (14:04 +0300)] 
xz: Remove the TODO comment about --recursive

It won't be implemented. find + xargs is more flexible, for example,
it allows compressing small files in parallel. An example for that
has been included in the xz man page since 2010.

13 months agoDocument --disable-loongarch-crc32 in INSTALL
Lasse Collin [Sat, 6 Jul 2024 11:04:16 +0000 (14:04 +0300)] 
Document --disable-loongarch-crc32 in INSTALL

13 months agoCMake: Link xz against Threads::Threads if using pthreads
Lasse Collin [Wed, 3 Jul 2024 17:45:48 +0000 (20:45 +0300)] 
CMake: Link xz against Threads::Threads if using pthreads

The liblzma target was recently changed to link against Threads::Threads
with the PRIVATE keyword. I had forgotten that xz itself depends on
pthreads too due to pthread_sigmask(). Thus, the build broke when
building shared liblzma and pthread_sigmask() wasn't in libc.

Thanks to Peter Seiderer for the bug report.

Fixes: ac05f1b0d7cda1e7ae79775a8dfecc54601d7f1c
Fixes: https://github.com/tukaani-project/xz/issues/129#issuecomment-2204522994
13 months agoUpdate THANKS
Lasse Collin [Tue, 2 Jul 2024 19:49:33 +0000 (22:49 +0300)] 
Update THANKS

13 months agoCMake: Improve NLS error messages
Lasse Collin [Tue, 2 Jul 2024 17:23:35 +0000 (20:23 +0300)] 
CMake: Improve NLS error messages

13 months agoCMake: Update the comment at the top of CMakeLists.txt
Lasse Collin [Tue, 2 Jul 2024 17:19:47 +0000 (20:19 +0300)] 
CMake: Update the comment at the top of CMakeLists.txt

While po/*.gmo files won't be used from the release tarball,
the generated translated man pages will be used still. Those
are text files and po4a has slightly more dependencies than
gettext tools so installing po4a might be a bit more challenging
in some situations.

13 months agoCMake: Drop support for pre-generated po/*.gmo files
Lasse Collin [Tue, 2 Jul 2024 17:12:40 +0000 (20:12 +0300)] 
CMake: Drop support for pre-generated po/*.gmo files

When a release tarball is created using Autotools, the tarball includes
po/*.gmo files which are binary files generated from po/*.po. Other
tarball creation methods don't and won't create the .gmo files.

It feels clearer if CMake will never install pre-generated binary files
from the source package. If people are able to install CMake, they
likely are able to install gettext tools as well (assuming they want
translations).

13 months agoCMake: Make XZ_NLS handling more robust
Lasse Collin [Tue, 2 Jul 2024 16:14:50 +0000 (19:14 +0300)] 
CMake: Make XZ_NLS handling more robust

If a user set XZ_NLS=ON but find_package(Intl) failed or CMake version
wasn't at least 3.20, the configuration would fail in a cryptic way.

If XZ_NLS is enabled, require that CMake is new enough and that either
gettext tools or pre-generated .gmo files are available. Otherwise fail
the configuration. Previously missing gettext tools and .gmo files would
only result in a warning.

Missing man page translations are still only a warning.

Thanks to Peter Seiderer for the bug report.

Fixes: https://github.com/tukaani-project/xz/issues/129
Closes: https://github.com/tukaani-project/xz/pull/130
13 months agoCI: Add gettext as a dependency to CMake builds
Lasse Collin [Tue, 2 Jul 2024 16:39:05 +0000 (19:39 +0300)] 
CI: Add gettext as a dependency to CMake builds

13 months agoCMake: Fix ENABLE_NLS comment too
Lasse Collin [Tue, 2 Jul 2024 15:43:56 +0000 (18:43 +0300)] 
CMake: Fix ENABLE_NLS comment too

Fixes: 29f77c7b707f2458fb047e77497354b195e05b14
13 months agoCMake: The compile definition is ENABLE_NLS, not XZ_NLS
Lasse Collin [Tue, 2 Jul 2024 15:02:50 +0000 (18:02 +0300)] 
CMake: The compile definition is ENABLE_NLS, not XZ_NLS

The CMake variables were renamed and accidentally also
the compile definition was renamed. As a result, translation
support wasn't actually enabled in the executables.

Fixes: 29f77c7b707f2458fb047e77497354b195e05b14
13 months agoUpdate AUTHORS and THANKS
Lasse Collin [Mon, 1 Jul 2024 14:33:20 +0000 (17:33 +0300)] 
Update AUTHORS and THANKS

13 months agoliblzma: Speed up CRC32 calculation on 64-bit LoongArch
Xi Ruoyao [Fri, 28 Jun 2024 10:36:43 +0000 (13:36 +0300)] 
liblzma: Speed up CRC32 calculation on 64-bit LoongArch

The crc.w.{b/h/w/d}.w instructions in LoongArch can calculate the CRC32
result for 1/2/4/8 bytes in a single operation. Using these is much
faster compared to the generic method.

Optimized CRC32 is enabled unconditionally on 64-bit LoongArch because
the LoongArch specification says that CRC32 instructions shall be
implemented for 64-bit processors. Optimized CRC32 isn't enabled for
32-bit LoongArch processors because not enough information is available
about them.

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
Closes: https://github.com/tukaani-project/xz/pull/86
13 months agoliblzma: ARM64 CRC32: Align the buffer faster
Lasse Collin [Fri, 28 Jun 2024 11:20:49 +0000 (14:20 +0300)] 
liblzma: ARM64 CRC32: Align the buffer faster

Instead of doing it byte by byte, use the 1/2/4-byte CRC32 instructions.

13 months agoCI: Speed up Valgrind job by using --trace-children-skip-by-arg=...
Sam James [Fri, 28 Jun 2024 11:18:35 +0000 (14:18 +0300)] 
CI: Speed up Valgrind job by using --trace-children-skip-by-arg=...

This addresses the issue I mentioned in
6c095a98fbec70b790253a663173ecdb669108c4 and speeds up the Valgrind
job a bit, because non-xz tools aren't run unnecessarily with
Valgrind by the script tests.

13 months agoBuild: Prepend, not append, PTHREAD_CFLAGS to LIBS
Lasse Collin [Tue, 25 Jun 2024 13:00:22 +0000 (16:00 +0300)] 
Build: Prepend, not append, PTHREAD_CFLAGS to LIBS

It shouldn't make any difference because LIBS should be empty
at that point in configure. But prepending is the correct way
because in general the libraries being added might require other
libraries that come later on the command line.

13 months agoBuild: Use AC_LINK_IFELSE to handle implicit function declarations
Lasse Collin [Tue, 25 Jun 2024 11:24:29 +0000 (14:24 +0300)] 
Build: Use AC_LINK_IFELSE to handle implicit function declarations

It's more robust in case the compiler allows pre-C99 implicit function
declarations. If an x86 intrinsic is missing and gets treated as
implicit function, the linking step will very probably fail. This
isn't the only way to workaround implicit function declarations but
it might be the simplest and cleanest.

The problem hasn't been observed in the wild.

There are a couple more AC_COMPILE_IFELSE uses in configure.ac.
Of these, Landlock check calls prctl() and in theory could have
the same problem. In practice it doesn't as the check program
looks for several other things too. However, it was changed to
AC_LINK_IFELSE still to look more correct.

Similarly, m4/tuklib_cpucores.m4 and m4/tuklib_physmem.m4 were
updated although they haven't given any trouble either. They
have worked all these years because those check programs rely
on specific headers and types: if headers or types are missing,
compilation will fail. Using the linker makes these checks more
similar to the ones in cmake/tuklib_*.cmake which always link.

13 months agoBuild: Use AC_LINK_IFELSE instead of -Werror
Lasse Collin [Mon, 24 Jun 2024 20:35:59 +0000 (23:35 +0300)] 
Build: Use AC_LINK_IFELSE instead of -Werror

AC_COMPILE_IFELSE needed -Werror because Clang <= 14 would merely
warn about the unsupported attribute and implicit function declaration.
Changing to AC_LINK_IFELSE handles the implicit declaration because
the symbol __crc32d is unlikely to exist in libc.

Note that the other part of the check is that #include <arm_acle.h>
must work. If the header is missing, most compilers give an error
and the linking step won't be attempted.

Avoiding -Werror makes the check more robust in case CFLAGS contains
warning flags that break -Werror anyway (but this isn't the only check
in configure.ac that has this problem). Using AC_LINK_IFELSE also makes
the check more similar to how it is done in CMakeLists.txt.

13 months agoBuild: Sync the compile check changes from CMakeLists.txt
Lasse Collin [Mon, 24 Jun 2024 20:34:34 +0000 (23:34 +0300)] 
Build: Sync the compile check changes from CMakeLists.txt

It's nice to keep these in sync. The use of main() will later allow
AC_LINK_IFELSE usage too which may avoid the more fragile -Werror.

13 months agoCMake: Not experimental anymore
Lasse Collin [Mon, 24 Jun 2024 17:14:43 +0000 (20:14 +0300)] 
CMake: Not experimental anymore

While the CMake support has gotten a lot less testing than
the Autotools-based build, the supported features should now
be equal. The output may differ slightly, for example,
liblzma.pc may have

    Libs.private: -pthread -lpthread

with Autotools on GNU/Linux. CMake doesn't put any options
in Libs.private because on modern glibc the pthread functions
are in libc. The options options aren't required to link static
liblzma into an application.

Autotools-based build doesn't generate or install
lib/cmake/liblzma-*.cmake files. This means that on most
platforms one cannot rely on

    find_package(liblzma 5.2.5 REQUIRED CONFIG)

or such finding those files.

13 months agoCMake: Use configure_file() to copy a file
Lasse Collin [Tue, 25 Jun 2024 13:11:13 +0000 (16:11 +0300)] 
CMake: Use configure_file() to copy a file

I had missed this simpler method before. It does create a dependency
so that if .in.h changes the copying is done again.

13 months agoCMake: Always add pthread flags into CMAKE_REQUIRED_LIBRARIES
Lasse Collin [Tue, 25 Jun 2024 12:51:48 +0000 (15:51 +0300)] 
CMake: Always add pthread flags into CMAKE_REQUIRED_LIBRARIES

It was weird to add CMAKE_THREAD_LIBS_INIT in CMAKE_REQUIRED_LIBRARIES
only if CLOCK_MONOTONIC is available. Alternative would be to remove
the thread libs from CMAKE_REQUIRED_LIBRARIES after the check for
pthread_condattr_setclock() but keeping the libs should be fine too.
Then it's ready in case more pthread functions were wanted some day.

13 months agoCMake: Tweak comments
Sam James [Mon, 24 Jun 2024 18:25:30 +0000 (19:25 +0100)] 
CMake: Tweak comments

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
13 months agoCMake: Edit white space for consistency
Lasse Collin [Mon, 24 Jun 2024 19:42:01 +0000 (22:42 +0300)] 
CMake: Edit white space for consistency

13 months agoCMake: Fix three checks if building with -flto
Lasse Collin [Mon, 24 Jun 2024 19:41:10 +0000 (22:41 +0300)] 
CMake: Fix three checks if building with -flto

In CMake, check_c_source_compiles() always links too. With
link-time optimization, unused functions may get omitted if
main() doesn't depend on them. Consider the following which
tries to check if somefunction() is available when <someheader.h>
has been included:

    #include <someheader.h>
    int foo(void) { return somefunction(); }
    int main(void) { return 0; }

LTO may omit foo() completely because the program as a whole doesn't
need it and then the program will link even if the symbol somefunction
isn't available in libc or other library being linked in, and then
the test may pass when it shouldn't.

What happens if <someheader.h> doesn't declare somefunction()?
Shouldn't the test fail in the compilation phase already? It should
but many compilers don't follow the C99 and later standards that
prohibit implicit function declarations. Instead such compilers
assume that somefunction() exists, compilation succeeds (with a
warning), and then linker with LTO omits the call to somefunction().

Change the tests so that they are part of main(). If compiler accepts
implicitly declared functions, LTO cannot omit them because it has to
assume that they might have side effects and thus linking will fail.
On the other hand, if the functions/intrinsics being used are supported,
they might get optimized away but in that case it's fine because they
really are supported.

It is fine to use __attribute__((target(...))) for main(). At least
it works with GCC 4.9 to 14.1 on x86-64.

Reported-by: Sam James <sam@gentoo.org>
13 months agoCMake: Use MATCHES instead of multiple STREQUAL
Lasse Collin [Mon, 24 Jun 2024 18:19:14 +0000 (21:19 +0300)] 
CMake: Use MATCHES instead of multiple STREQUAL

13 months agoCMake: Improve the comment about LIBS
Lasse Collin [Mon, 24 Jun 2024 18:06:18 +0000 (21:06 +0300)] 
CMake: Improve the comment about LIBS

13 months agoCMake: Fix a typo in a message
Lasse Collin [Mon, 24 Jun 2024 17:01:25 +0000 (20:01 +0300)] 
CMake: Fix a typo in a message

It was spotted with codespell.

13 months agoDocument CMake options in INSTALL
Lasse Collin [Mon, 24 Jun 2024 16:58:54 +0000 (19:58 +0300)] 
Document CMake options in INSTALL

13 months agoCI: Don't omit crc32 from the list with CMake anymore
Lasse Collin [Mon, 24 Jun 2024 14:18:44 +0000 (17:18 +0300)] 
CI: Don't omit crc32 from the list with CMake anymore

XZ_CHECKS accepts it but works without too.

13 months agoCI: Workaround buggy config.guess on Ubuntu 22.04LTS and 24.04LTS
Lasse Collin [Mon, 24 Jun 2024 14:39:54 +0000 (17:39 +0300)] 
CI: Workaround buggy config.guess on Ubuntu 22.04LTS and 24.04LTS

Check for the wrong triplet from config.guess and override it with
the --build option on the configure command line. Then i386 assembly
autodetection will work.

These Ubuntu versions (and as of writing, also Debian unstable)
ship config.guess version 2022-01-09 which contains a bug that
was fixed in version 2022-05-08. It results in a wrong configure
triplet when using CC="gcc -m32" to build i386 binaries.

Upstream fix:
https://git.savannah.gnu.org/cgit/config.git/commit/?id=f56a7140386d08a531bcfd444d632b28c61a6329

More information:
https://mail.gnu.org/archive/html/config-patches/2022-05/msg00003.html

13 months agoCI: Use CC="gcc -m32" to get i386 compiler on x86-64
Lasse Collin [Mon, 24 Jun 2024 12:24:52 +0000 (15:24 +0300)] 
CI: Use CC="gcc -m32" to get i386 compiler on x86-64

The old method put it in CFLAGS which is a wrong place because
config.guess doesn't read CFLAGS.

13 months agoCI: Let CMake use the CC environment variable
Lasse Collin [Mon, 24 Jun 2024 11:54:17 +0000 (14:54 +0300)] 
CI: Let CMake use the CC environment variable

CC from environment is used to initialize CMAKE_C_COMPILER so
setting CMAKE_C_COMPILER explicitly isn't needed.

The syntax in ci_build.bash was broken in case one wished to put
spaces in CC.

13 months agoCMake: Add autodetection for 32-bit x86 CRC assembly usage
Lasse Collin [Thu, 20 Jun 2024 20:25:42 +0000 (23:25 +0300)] 
CMake: Add autodetection for 32-bit x86 CRC assembly usage

13 months agoCMake: Move option(XZ_ASM_I386) downwards a few lines
Lasse Collin [Thu, 20 Jun 2024 20:00:59 +0000 (23:00 +0300)] 
CMake: Move option(XZ_ASM_I386) downwards a few lines

13 months agoDOS: Update Makefile and config.h for the CRC changes
Lasse Collin [Thu, 20 Jun 2024 15:45:41 +0000 (18:45 +0300)] 
DOS: Update Makefile and config.h for the CRC changes

13 months agoliblzma: Tidy up crc_common.h
Lasse Collin [Sun, 23 Jun 2024 12:35:35 +0000 (15:35 +0300)] 
liblzma: Tidy up crc_common.h

Prefix ARM64_RUNTIME_DETECTION with CRC_ and reorder it to be with
the other ARM64-specific lines. That macro isn't used outside this
file.

ARM64 CLMUL implementation doesn't exist yet and thus CRC64_ARM64_CLMUL
isn't used anywhere yet.

It's not ideal that the single-letter CRC utility macros are here
as they pollute the namespace of the LZ encoder files. Those could
be moved their own crc_macros.h like they were in 5.2.x but in practice
this is fine enough already.

13 months agoliblzma: Move lzma_crcXX_table[][] declarations to crc_common.h
Lasse Collin [Sun, 23 Jun 2024 11:22:08 +0000 (14:22 +0300)] 
liblzma: Move lzma_crcXX_table[][] declarations to crc_common.h

LZ encoder needs lzma_crc32_table[0] but otherwise those tables
are private to the CRC code. In contrast, the other things in
check.h are needed in several places.

13 months agoliblzma: Make 32-bit x86 CRC assembly co-exist with CLMUL
Lasse Collin [Wed, 19 Jun 2024 15:38:22 +0000 (18:38 +0300)] 
liblzma: Make 32-bit x86 CRC assembly co-exist with CLMUL

Now runtime detection of CLMUL support can pick between the CLMUL and
the generic assembly implementations. Whatever overhead this has for
builds that omit CLMUL completely isn't important because builds for
any non-ancient system is likely to include the CLMUL code too.

Handle the CRC tables in crcXX_fast.c files because now these files
are built even when assembly code is used.

If 32-bit x86 assembly is enabled then it will always be built even
if compiler flags were such that CLMUL would be allowed unconditionally.
That is, runtime detection will be used anyway. This keeps the build
rules simpler.

In LZ encoder, build and use lzma_lz_hash_table[256] if CLMUL CRC
is used without runtime detection. Previously this wasn't needed
because crc32_table.c included the lzma_crc32_table[][] in the build
unless encoder support had been disabled. Including an 8 KiB table
was silly when only 1 KiB is actually used. So now liblzma is 7 KiB
smaller if CLMUL is enabled without runtime detection.

13 months agoliblzma: CRC: Rename crcXX_generic to lzma_crcXX_generic
Lasse Collin [Wed, 19 Jun 2024 14:44:41 +0000 (17:44 +0300)] 
liblzma: CRC: Rename crcXX_generic to lzma_crcXX_generic

This prepares for the possibility that lzma_crc32_generic and
lzma_crc64_generic are extern functions.

13 months agoCMake: Define HAVE_CRC_X86_ASM when 32-bit x86 CRC assembly is used
Lasse Collin [Thu, 20 Jun 2024 19:55:22 +0000 (22:55 +0300)] 
CMake: Define HAVE_CRC_X86_ASM when 32-bit x86 CRC assembly is used

13 months agoBuild: Define HAVE_CRC_X86_ASM when 32-bit x86 CRC assembly is used
Lasse Collin [Fri, 10 May 2024 13:00:26 +0000 (16:00 +0300)] 
Build: Define HAVE_CRC_X86_ASM when 32-bit x86 CRC assembly is used

This makes it easier to determine when the CRC tables are needed.

13 months agoCI: Update to the new renamed options in CMakeLists.txt
Lasse Collin [Thu, 20 Jun 2024 21:46:09 +0000 (00:46 +0300)] 
CI: Update to the new renamed options in CMakeLists.txt

13 months agoCMake: Add XZ_EXTERNAL_SHA256
Lasse Collin [Thu, 20 Jun 2024 15:12:22 +0000 (18:12 +0300)] 
CMake: Add XZ_EXTERNAL_SHA256

13 months agoCMake: Move threading detection a few lines up
Lasse Collin [Thu, 20 Jun 2024 15:12:21 +0000 (18:12 +0300)] 
CMake: Move threading detection a few lines up

It feels clearer this way, and when support for external SHA-256
is added, this will keep the order of the library detection the
same as in configure.ac (check for pthreads before libmd) although
it shouldn't matter in practice.

13 months agoCMake: Move the sandbox code out of the liblzma section
Lasse Collin [Thu, 20 Jun 2024 15:12:21 +0000 (18:12 +0300)] 
CMake: Move the sandbox code out of the liblzma section

Sandboxing is for the command line tools, not liblzma.
No functional changes.

13 months agoCMake: Keep existing options in LIBS when adding -lrt
Lasse Collin [Thu, 20 Jun 2024 15:12:21 +0000 (18:12 +0300)] 
CMake: Keep existing options in LIBS when adding -lrt

This makes no difference yet because -lrt is currently the only option
that might be added to LIBS.

13 months agoCMake: Don't install scripts if the xz tool isn't built
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Don't install scripts if the xz tool isn't built

The scripts need the xz tool.

13 months agoCMake: Add XZ_TOOL_XZDEC and XZ_TOOL_LZMADEC
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Add XZ_TOOL_XZDEC and XZ_TOOL_LZMADEC

13 months agoCMake: Add XZ_TOOL_LZMAINFO
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Add XZ_TOOL_LZMAINFO

13 months agoCMake: Add XZ_TOOL_XZ
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Add XZ_TOOL_XZ

13 months agoWindows: Drop Visual Studio 2013 support
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
Windows: Drop Visual Studio 2013 support

This simplifies things a little. Building liblzma with VS2013 probably
still worked but building the command line tools was not supported.

Microsoft ended support for VS2013 on 2024-04.

13 months agoCMake: Add XZ_TOOL_SCRIPTS
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Add XZ_TOOL_SCRIPTS

13 months agoCMake: Add XZ_DOC
Lasse Collin [Sat, 15 Jun 2024 15:07:04 +0000 (18:07 +0300)] 
CMake: Add XZ_DOC

13 months agoCMake: Refactor XZ_SYMBOL_VERSIONING to match configure.ac
Lasse Collin [Thu, 20 Jun 2024 18:53:03 +0000 (21:53 +0300)] 
CMake: Refactor XZ_SYMBOL_VERSIONING to match configure.ac

Make the available options and their behavior match
--enable-symbol-versions in configure.ac.

Don't enable symbol versions on Linux if not using glibc. Previously
the generic variant was selected on Microblaze or if using NVHPC
without checking that libc is glibc.

Leave the cache variable to "auto" or "yes" if that was specified
instead of setting it to the autodetected value by default. A downside
is that one cannot easily see which variant the autodetection code
has selected. The same applies to XZ_SANDBOX and XZ_THREADS though.