]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
13 months agoliblzma: CRC CLMUL: Omit is_arch_extension_supported() when not needed 127/head
Lasse Collin [Sun, 16 Jun 2024 10:39:37 +0000 (13:39 +0300)] 
liblzma: CRC CLMUL: Omit is_arch_extension_supported() when not needed

On E2K the function compiles only due to compiler emulation but the
function is never used. It's cleaner to omit the function when it's
not needed even though it's a "static inline" function.

Thanks to Ilya Kurdyukov.

13 months agoliblzma: x86 CLMUL CRC: Rewrite
Lasse Collin [Sun, 16 Jun 2024 10:21:34 +0000 (13:21 +0300)] 
liblzma: x86 CLMUL CRC: Rewrite

It's faster with both tiny and large buffers and doesn't require
disabling any sanitizers. With large buffers the extra speed is
from folding four 16-byte chunks in parallel.

The 32-bit x86 with MSVC reportedly still needs a workaround.
Now the simpler "__asm mov ebx, ebx" trick is enough but it
needs to be in lzma_crc64() instead of crc64_arch_optimized().
Thanks to Iouri Kharon for testing and the fix.

Thanks to Ilya Kurdyukov for testing the speed with aligned and
unaligned buffers on a few x86 processors and on E2K v6.

Thanks to Sam James for general feedback.

Fixes: https://github.com/tukaani-project/xz/issues/112
Fixes: https://github.com/tukaani-project/xz/issues/122
13 months agosysdefs.h: Add alignas
Lasse Collin [Sat, 1 Jun 2024 11:44:04 +0000 (14:44 +0300)] 
sysdefs.h: Add alignas

13 months agoliblzma: Use a single macro to select CLMUL CRC to build
Lasse Collin [Tue, 11 Jun 2024 09:47:59 +0000 (12:47 +0300)] 
liblzma: Use a single macro to select CLMUL CRC to build

This way it's clearer that two things cannot be selected
at the same time.

13 months agoliblzma: CRC32 CLMUL: Refactor the constants and simplify
Lasse Collin [Mon, 10 Jun 2024 12:31:01 +0000 (15:31 +0300)] 
liblzma: CRC32 CLMUL: Refactor the constants and simplify

By using modulus scaled constants, the final reduction can
be simplified.

13 months agoliblzma: CRC64 CLMUL: Refactor the constants
Lasse Collin [Mon, 10 Jun 2024 12:12:48 +0000 (15:12 +0300)] 
liblzma: CRC64 CLMUL: Refactor the constants

Now it refers to crc_clmul_consts_gen.c. vfold8 was renamed to mu_p
and the p no longer has the lowest bit set (it makes no difference
as the output bits it affects are ignored).

13 months agoliblzma: Add crc_clmul_consts_gen.c
Lasse Collin [Mon, 10 Jun 2024 11:45:44 +0000 (14:45 +0300)] 
liblzma: Add crc_clmul_consts_gen.c

It's a standalone program that prints the required constants.
It's won't be a part of the normal build of the package.

13 months agoliblzma: Remove CRC_USE_GENERIC_FOR_SMALL_INPUTS
Lasse Collin [Thu, 9 May 2024 18:44:03 +0000 (21:44 +0300)] 
liblzma: Remove CRC_USE_GENERIC_FOR_SMALL_INPUTS

It was already commented out.

13 months agoliblzma: Remove crc_attr_no_sanitize_address
Lasse Collin [Thu, 9 May 2024 18:03:39 +0000 (21:03 +0300)] 
liblzma: Remove crc_attr_no_sanitize_address

It's not enough to silence the address sanitizer. Also memory and
thread sanitizers would need to be silenced. They, at least currently,
aren't smart enough to see that the extra bytes are discarded from
the xmm registers by later instructions.

Valgrind is smarter, possibly because this kind of code isn't weird
to write in assembly. Agner Fog's optimizing_assembly.pdf even mentions
this idea of doing an aligned read and then discarding the extra
bytes. The sanitizers don't instrument assembly code but Valgrind
checks all code.

It's better to change the implementation to avoid the sanitization
attributes which also look scary in the code. (Somehow they can look
more scary than __asm__ which is implictly unsanitized.)

See also:
https://github.com/tukaani-project/xz/issues/112
https://github.com/tukaani-project/xz/issues/122

13 months agoRevert "Build: Temporarily disable CRC CLMUL to silence OSS Fuzz"
Lasse Collin [Mon, 10 Jun 2024 12:37:49 +0000 (15:37 +0300)] 
Revert "Build: Temporarily disable CRC CLMUL to silence OSS Fuzz"

This reverts commit 9f1a6d6f9a258886933a22239a5b81af34b28199.

13 months agoCMake: Prefer C11 with a fallback to C99
Lasse Collin [Wed, 12 Jun 2024 11:26:44 +0000 (14:26 +0300)] 
CMake: Prefer C11 with a fallback to C99

There is no need to make a similar change in configure.ac.
With Autoconf 2.72, the deprecated macro AC_PROG_CC_C99
is an alias for AC_PROG_CC which prefers a C11 compiler.

13 months agoUpdate THANKS
Lasse Collin [Wed, 12 Jun 2024 11:20:21 +0000 (14:20 +0300)] 
Update THANKS

14 months agoTests: Improve the CRC32 test
Lasse Collin [Tue, 11 Jun 2024 08:15:49 +0000 (11:15 +0300)] 
Tests: Improve the CRC32 test

A similar one was already there for CRC64 but nowadays also CRC32
has a CLMUL implementation, so it's good to test it better too.

14 months agoxz: Fix white space
Lasse Collin [Tue, 11 Jun 2024 19:42:26 +0000 (22:42 +0300)] 
xz: Fix white space

14 months agoliblzma: Fix a typo in a comment
Lasse Collin [Tue, 11 Jun 2024 18:59:09 +0000 (21:59 +0300)] 
liblzma: Fix a typo in a comment

Thanks to Sam James for spotting it.

Fixes: f644473a211394447824ea00518d0a214ff3f7f2
14 months agoliblzma: Fix a comment indentation
Lasse Collin [Fri, 10 May 2024 12:52:26 +0000 (15:52 +0300)] 
liblzma: Fix a comment indentation

14 months agoliblzma: Fix white space
Lasse Collin [Thu, 9 May 2024 19:09:12 +0000 (22:09 +0300)] 
liblzma: Fix white space

14 months agotuklib: __STDC_VERSION__ in C23 is 202311
Lasse Collin [Sat, 1 Jun 2024 11:25:29 +0000 (14:25 +0300)] 
tuklib: __STDC_VERSION__ in C23 is 202311

14 months agoFix typos
RainRat [Wed, 5 Jun 2024 22:21:49 +0000 (15:21 -0700)] 
Fix typos

Closes: https://github.com/tukaani-project/xz/pull/124
14 months agotuklib_integer: Fix building on OpenBSD/sparc64 that uses GCC 4.2
Lasse Collin [Fri, 7 Jun 2024 12:47:20 +0000 (15:47 +0300)] 
tuklib_integer: Fix building on OpenBSD/sparc64 that uses GCC 4.2

GCC 4.2 doesn't have __builtin_bswap16() and friends so tuklib_integer.h
tries to use OS-specific byte swap methods instead. On OpenBSD those
macros are swap16/32/64 instead of bswap16/32/64 like on other *BSDs
and Darwin.

An alternative to "#ifdef __OpenBSD__" could be "#ifdef swap16" as it
is a macro. But since OpenBSD seems to be a special case under this
special case of "*BSDs and Darwin", checking for __OpenBSD__ seems
the more conservative choice now.

Thanks to Christian Weisgerber and Brad Smith who both submitted
the same patch a few hours apart.

Co-authored-by: Christian Weisgerber <naddy@mips.inka.de>
Co-authored-by: Brad Smith <brad@comstyle.com>
Closes: https://github.com/tukaani-project/xz/pull/126
14 months agoliblzma: Add ARM64 CRC32 instruction support detection on OpenBSD
Lasse Collin [Fri, 7 Jun 2024 12:06:59 +0000 (15:06 +0300)] 
liblzma: Add ARM64 CRC32 instruction support detection on OpenBSD

The C code is from Christian Weisgerber, I merely reordered the OSes.
Then I added the build system checks without testing them.

Also thanks to Brad Smith who submitted a similar patch on GitHub
a few hours after Christian had sent his via email.

Co-authored-by: Christian Weisgerber <naddy@mips.inka.de>
Closes: https://github.com/tukaani-project/xz/pull/125
14 months agoUpdate THANKS
Lasse Collin [Wed, 5 Jun 2024 10:55:43 +0000 (13:55 +0300)] 
Update THANKS

14 months agoCMake: Include the "alpha" or "beta" suffix in PACKAGE_VERSION
Lasse Collin [Wed, 5 Jun 2024 10:42:47 +0000 (13:42 +0300)] 
CMake: Include the "alpha" or "beta" suffix in PACKAGE_VERSION

This way the version string gets into xzgrep and other scripts
in full and also into liblzma.pc.

For the project() command, a suffixless string is required though.

14 months agoCMake: Fix wrong version variable
Lasse Collin [Wed, 5 Jun 2024 10:30:28 +0000 (13:30 +0300)] 
CMake: Fix wrong version variable

liblzma_VERSION has never existed in the repository. xz_VERSION from
the project() command was used for liblzma SOVERSION so use xz_VERSION
here too.

The wrong variable did no harm in practice as PROJECT_VERSION
was used as the fallback. It has the same value as xz_VERSION.

Fixes: 7e3493d40eac0c3fa3d5124097745a70e15c41f6
14 months agoCMake: Set only "prefix" as an absolute path in liblzma.pc
Lasse Collin [Wed, 5 Jun 2024 09:59:59 +0000 (12:59 +0300)] 
CMake: Set only "prefix" as an absolute path in liblzma.pc

CMake provides variables that are relative to CMAKE_INSTALL_PREFIX
so use them instead of repeating the full path.

14 months agoCMake: Fix liblzma filename in Windows environments
Lasse Collin [Tue, 4 Jun 2024 20:59:29 +0000 (23:59 +0300)] 
CMake: Fix liblzma filename in Windows environments

This is a mess because liblzma DLL outside Cygwin and MSYS2
is liblzma.dll instead of lzma.dll to avoid a conflict with
lzma.dll from LZMA SDK.

On Cygwin the name was "liblzma-5.dll" while "cyglzma-5.dll"
would have been correct (and match what Libtool produces).
MSYS2 likely was broken too as it uses the "msys-" prefix.

This change has no effect with MinGW-w64 because with that
the "lib" prefix was correct already.

With MSVC builds this is a small breaking change that requires developers
to adjust the library name when linking against liblzma. The liblzma.dll
name is kept as is but the import library and static library are now
lzma.lib instead of liblzma.lib. This is helpful when using pkgconf
because "pkgconf --msvc-syntax --libs liblzma" outputs "lzma.lib"
(it's converted from "-llzma" in liblzma.pc). It would be easy to
keep the liblzma.lib naming but the pkgconf compatibility seems worth
it in the long run. The lzma.lib name is compatible with MinGW-w64
too as -llzma will find also lzma.lib.

vcpkg had been patching CMakeLists.txt this way since 2022 but I
learned this only recently. The reasoning for the patch makes sense,
and while this is a small breaking change with MSVC, it seems like
a decent compromise as it keeps the DLL name the same.

2022 patch in vcpkg: https://github.com/microsoft/vcpkg/blob/0707a17ecf1466d64cf1a3c1ee18c8ff02aadb2d/ports/liblzma/win_output_name.patch
See the discussion: https://github.com/microsoft/vcpkg/pull/39024

Thanks to Vincent Torri for confirming the naming issue on Cygwin.

14 months agoFix version.sh compatiblity with Solaris
Lasse Collin [Mon, 3 Jun 2024 13:55:03 +0000 (16:55 +0300)] 
Fix version.sh compatiblity with Solaris

The ancient /bin/tr on Solaris doesn't support '\n'.
With /usr/xpg4/bin/tr it works but it might not be in PATH.

Another problem was that sed was given input that didn't have a newline
at the end. Text files must end with a newline to be portable.

Fix both problems:

  - Handle multiline input within sed itself to avoid one tr invocation.
    The default sed even on Solaris does understand \n.

  - Use octals in tr -d. \012 works for ASCII "line feed", it's even
    used as an example in the Solaris man page. But we must strip
    also ASCII "carriage return" \015 and EBCDIC "next line" \025.
    The EBCDIC case got handled with \n previously. Stripping \012
    and \015 on EBCDIC system won't matter as those control chars
    won't be present in the string in the first place.

An awk-based solution could be an alternative but it might need
special casing on Solaris to used nawk instead of awk. The changes
in this commit are smaller and should have a smaller risk for
regressions. It's also possible that version.sh will be dropped
entirely at some point.

14 months agoCI: Don't require po4a on Solaris
Lasse Collin [Mon, 3 Jun 2024 14:07:11 +0000 (17:07 +0300)] 
CI: Don't require po4a on Solaris

14 months agoCI: Use set -e on Solaris too
Lasse Collin [Mon, 3 Jun 2024 12:08:15 +0000 (15:08 +0300)] 
CI: Use set -e on Solaris too

14 months agoCMake: Install liblzma.pc even with MSVC
Lasse Collin [Mon, 3 Jun 2024 14:44:50 +0000 (17:44 +0300)] 
CMake: Install liblzma.pc even with MSVC

I had misunderstood that it wouldn't be useful with MSVC.
vcpkg had been installing liblzma.pc with custom rules since 2020,
years before liblzma.pc support was added to CMakeLists.txt.

See:
https://github.com/microsoft/vcpkg/blob/eb895b95aac6fd7485373702f29f508c42a180a0/ports/liblzma/portfile.cmake
https://github.com/microsoft/vcpkg/pull/39024#issuecomment-2145064670

14 months agoci: don't pin official GH actions via commit, just tag
Sam James [Mon, 3 Jun 2024 05:16:23 +0000 (06:16 +0100)] 
ci: don't pin official GH actions via commit, just tag

There's no real value in doing it via commit for official GH actions. We
can keep using pinned commits for unofficial actions. It's hassle for no
gain.

Maybe going forward we can limit this further by only being paranoid
for the jobs with any access to tokens.

14 months agoci: set -e on openbsd
Christoph Junghans [Tue, 30 Apr 2024 13:49:26 +0000 (07:49 -0600)] 
ci: set -e on openbsd

Closes: https://github.com/tukaani-project/xz/pull/116
14 months agoci: set -e on netbsd
Christoph Junghans [Tue, 30 Apr 2024 13:48:58 +0000 (07:48 -0600)] 
ci: set -e on netbsd

14 months agoci: actually fail on FreeBSD
Christoph Junghans [Thu, 25 Apr 2024 21:56:06 +0000 (14:56 -0700)] 
ci: actually fail on FreeBSD

Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72

14 months agoUpdated actions
Andrew Murray [Wed, 24 Apr 2024 23:24:46 +0000 (09:24 +1000)] 
Updated actions

Closes: https://github.com/tukaani-project/xz/pull/115
14 months agoci: add po4a
Sam James [Mon, 3 Jun 2024 01:49:40 +0000 (02:49 +0100)] 
ci: add po4a

14 months agoci: add Solaris
Sam James [Sat, 13 Apr 2024 20:02:04 +0000 (21:02 +0100)] 
ci: add Solaris

Inspired by https://github.com/RsyncProject/rsync/commit/3f2a38b01184cae9a931280b534acf5a3dae2e94.

It runs on Solaris 5.11 via a VirtualBox VM.

14 months agoxz: list: suppress -Wformat-nonliteral for Solaris
Sam James [Sun, 14 Apr 2024 07:08:00 +0000 (08:08 +0100)] 
xz: list: suppress -Wformat-nonliteral for Solaris

Solaris' GCC can't understand that our use is fine, unlike modern compilers:
```
list.c: In function 'print_totals_basic':
list.c:1191:4: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
  uint64_to_str(totals.files, 0));
  ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

It's presumably because of older gettext missing format attributes.

This is with `gcc (GCC) 7.3.0`.

14 months agolicense-check.sh: Fix reporting of unclear license info
Lasse Collin [Mon, 3 Jun 2024 08:44:28 +0000 (11:44 +0300)] 
license-check.sh: Fix reporting of unclear license info

The main feature was broken because an old variable name hadn't
been updated to match the rest of the script.

14 months agoUpdate THANKS
Lasse Collin [Fri, 31 May 2024 18:36:26 +0000 (21:36 +0300)] 
Update THANKS

14 months agoTranslations: Run po4a/update-po
Lasse Collin [Wed, 29 May 2024 14:47:13 +0000 (17:47 +0300)] 
Translations: Run po4a/update-po

Now the files are in the new formatting without source file
line numbers. Future updates should keep the diffs much smaller.

14 months agoTranslations: Run "make -C po update-po"
Lasse Collin [Wed, 29 May 2024 14:44:53 +0000 (17:44 +0300)] 
Translations: Run "make -C po update-po"

In the past this wasn't done before releases; the Git repository
just contained the files from the Translation Project. But this
way it is clearer when comparing release tarballs against the
Git repository. In future releases this might no longer be necessary
within a stable branch as the .po files won't change so easily anymore
when creating a tarball.

14 months agoAdd NEWS for 5.6.2
Lasse Collin [Wed, 29 May 2024 15:03:04 +0000 (18:03 +0300)] 
Add NEWS for 5.6.2

14 months agoAdd NEWS for 5.4.7
Lasse Collin [Wed, 29 May 2024 15:03:04 +0000 (18:03 +0300)] 
Add NEWS for 5.4.7

14 months agoAdd NEWS for 5.2.13
Lasse Collin [Wed, 29 May 2024 15:03:04 +0000 (18:03 +0300)] 
Add NEWS for 5.2.13

14 months agoBuild: Update po/*.po files only when needed
Lasse Collin [Wed, 29 May 2024 13:33:24 +0000 (16:33 +0300)] 
Build: Update po/*.po files only when needed

When po/xz.pot doesn't exist, running "make" or "make dist" will
create it. Then the .po files will be updated but only if they
actually would change more than the POT-Creation-Date line.
Then the .gmo files would be generated from the .po files.
This is the case before and after this commit.

However, "make dist" and thus "make mydist" did a forced update
to the files, updating them even if the only change was the
POT-Creation-Date line. This had pros and cons: It made it clear
that the .po file really is in sync with the recent strings in
the package. On the other hand, it added noise in form of changed
files in the source tree and distribution tarballs. It can be
ignored with something like "diff -I'^"POT-Creation-Date: '" but
it's still a minor annoyance *if* there's not enough value in
having the most recent timestamp.

Setting DIST_DEPENDS_ON_UPDATE_PO = no means that such forced
update won't happen in "make dist" anymore. However, the "mydist"
target will use xz.pot-update target which is the same target that
is run when xz.pot doesn't exist at all yet. Thus "mydist" will
ensure that the translations are up to date, without noise from
changes that would affect only the POT-Creation-Date line.

Note that po4a always uses msgmerge with --update, so POT-Creation-Date
in the man page translations is never the only change in .po files.
In that sense this commit makes the message translations behave more
similarly to the man page translations.

Distribution tarballs will still have non-reproducible POT-Creation-Date
in po/xz.pot and po4a/xz-man.pot but those are just two files. Even they
could be made reproducible from a Git timestamp if desired.

14 months agopo4a/update-po: Disable wrapping in .pot and .po files
Lasse Collin [Tue, 28 May 2024 18:10:33 +0000 (21:10 +0300)] 
po4a/update-po: Disable wrapping in .pot and .po files

The .po files from the Translation Project come with unwrapped
strings so this matches it.

This may reduce the noise in diffs too. When the beginning of
a paragraph had changed, the rest of the lines got rewrapped
in msgsid. Now it's just one very long line that changes when
a paragraph has been edited.

The --add-location=file option was removed as redundant. The line
numbers don't exist in the .pot file due to --porefs file and thus
they cannot get copied to the .po files either.

14 months agoUpdate contact info in README
Lasse Collin [Tue, 28 May 2024 15:36:53 +0000 (18:36 +0300)] 
Update contact info in README

14 months agoTranslations: Use --package-name=xz-man with po4a
Lasse Collin [Tue, 28 May 2024 10:25:07 +0000 (13:25 +0300)] 
Translations: Use --package-name=xz-man with po4a

This is to match reality. See the added comment.

14 months agoTranslations: Omit --package-name from po/Makevars
Lasse Collin [Tue, 28 May 2024 10:03:40 +0000 (13:03 +0300)] 
Translations: Omit --package-name from po/Makevars

This is closer to the reality in the po/*.po files.

14 months agolicense-check.sh: Use '--' with slightly untrusted filenames
Lasse Collin [Mon, 27 May 2024 14:45:51 +0000 (17:45 +0300)] 
license-check.sh: Use '--' with slightly untrusted filenames

Names from git ls-files should be safe but if one runs it on
a tree without the .git dir and there are extra files, it's
safer to have the end of arguments marked with '--'.

14 months agolicense-check.sh: Use xargs -0 instead of -d
Lasse Collin [Mon, 27 May 2024 14:41:37 +0000 (17:41 +0300)] 
license-check.sh: Use xargs -0 instead of -d

Neither are in POSIX but -0 is much more portable in practice.

Despite the old comment, the grep usage should be portable already.

14 months agoTranslations: Omit man page line numbers from .pot and .po files
Lasse Collin [Mon, 27 May 2024 22:17:45 +0000 (01:17 +0300)] 
Translations: Omit man page line numbers from .pot and .po files

14 months agoTranslations: Use the xgettext option --add-location=file
Lasse Collin [Mon, 27 May 2024 22:06:30 +0000 (01:06 +0300)] 
Translations: Use the xgettext option --add-location=file

14 months agoTranslations: Use the msgmerge option --add-location=file
Lasse Collin [Mon, 27 May 2024 21:43:53 +0000 (00:43 +0300)] 
Translations: Use the msgmerge option --add-location=file

This way the PO file diffs are less noisy but the locations of the
strings are still present at file level, just without line numbers.

The option is available since gettext 0.19 (2014).
configure.ac requires 0.19.6.

14 months agoBuild: Use $(SHELL) instead of sh to run scripts in Makefile.am
Lasse Collin [Mon, 27 May 2024 09:22:08 +0000 (12:22 +0300)] 
Build: Use $(SHELL) instead of sh to run scripts in Makefile.am

14 months agoTranslations: Change the home page URLs in man page translations
Lasse Collin [Thu, 23 May 2024 14:25:13 +0000 (17:25 +0300)] 
Translations: Change the home page URLs in man page translations

Since the source strings have changed, these would get marked as
fuzzy and the original string would be used instead. The original
and translated strings are identical in this case so it wouldn't
matter. But patching the translations helps still because then
po4a will show the correct translation percentage.

14 months agoCMake: Add manual support for 32-bit x86 assembly files
Lasse Collin [Thu, 23 May 2024 12:15:18 +0000 (15:15 +0300)] 
CMake: Add manual support for 32-bit x86 assembly files

One has to pass -DENABLE_X86_ASM=ON to cmake to enable the
CRC assembly code. Autodetection isn't done. Looking at
CMAKE_SYSTEM_PROCESSOR might not work as it comes from uname
unless cross-compilation is done using a CMake toolchain file.

On top of this, if the code is run on modern processors that support
the CLMUL instruction, then the C code should be faster (but then
one should also be using a x86-64 build if possible).

14 months agoCMake: Rename USE_DOXYGEN to ENABLE_DOXYGEN
Lasse Collin [Thu, 23 May 2024 11:26:45 +0000 (14:26 +0300)] 
CMake: Rename USE_DOXYGEN to ENABLE_DOXYGEN

It's more consistent with the other option() uses.

14 months agoMention license-check.sh in COPYING
Lasse Collin [Wed, 22 May 2024 12:21:53 +0000 (15:21 +0300)] 
Mention license-check.sh in COPYING

14 months agoUse more confident language in COPYING
Lasse Collin [Wed, 22 May 2024 12:21:53 +0000 (15:21 +0300)] 
Use more confident language in COPYING

14 months agoBuild: Run license-check.sh in "mydist" and "dist-hook"
Lasse Collin [Wed, 22 May 2024 12:21:53 +0000 (15:21 +0300)] 
Build: Run license-check.sh in "mydist" and "dist-hook"

In mydist the point is to check using the file list from the Git
repository. In dist-hook it is to check that the TARBALL_IGNORE
patterns work when the .git dir or the "git" command aren't available.

Refuse to create a distribution tarball if license issues are found.

14 months agoAdd build-aux/license-check.sh
Lasse Collin [Wed, 22 May 2024 12:21:53 +0000 (15:21 +0300)] 
Add build-aux/license-check.sh

This helps in spotting files that lack SPDX license identifier
and which haven't been explicitly white listed either. The script
requires the .git directory to be present as only the files that
are in the Git repository are checked.

XZ Utils isn't FSFE REUSE compliant for now.

14 months agoAdd SPDX license identifiers to files under tests/ossfuzz
Lasse Collin [Mon, 29 Apr 2024 14:16:38 +0000 (17:16 +0300)] 
Add SPDX license identifiers to files under tests/ossfuzz

14 months agoAdd SPDX license identifier to .codespellrc
Lasse Collin [Mon, 29 Apr 2024 14:16:06 +0000 (17:16 +0300)] 
Add SPDX license identifier to .codespellrc

14 months agoMove entries po4a/.gitignore to the top level .gitignore
Lasse Collin [Wed, 22 May 2024 12:12:09 +0000 (15:12 +0300)] 
Move entries po4a/.gitignore to the top level .gitignore

The po4a directory is in EXTRA_DIST and thus all files there
are included in the package. .gitignore doesn't belong in the
package so keep that file out of the po4a directory.

14 months agoTests: Make the config.h grep patterns Meson compatible
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
Tests: Make the config.h grep patterns Meson compatible

Now the test scripts detect both

    #define HAVE_DECODER_ARM
    #define HAVE_DECODER_ARM 1

as support for the ARM filter without confusing it with these:

    #define HAVE_DECODER_ARM64
    #define HAVE_DECODER_ARM64 1

Previously only the ones ending with " 1" were accepted for
the macros where this kind of confusion was possible.

This should help with Meson support because Meson's built-in
features produce config.h entries that are either

    #define FOO 1
    #define FOO 0

or:

    #define FOO
    #undef FOO

The former method has a benefit that one can use "#if FOO" and -Wundef
will catch if a #define is missing (for example, it helps catching
typos). But XZ Utils has to use the latter since it has been
convenient with Autoconf's default behavior.[*] While it's easy to
emulate the Autoconf style (#define FOO 1 vs. no #define at all)
in Meson, it results in clumsy code. Thus it's better to change
the few places in the tests where this difference matters.

[*] While most checks in Autoconf default to the second style above,
    a few things use the first style (like AC_CHECK_DECLS). The mix
    of both styles is the most confusing as one has to remember which
    macro needs #ifdef and which #if. Currently HAVE_VISIBILITY is
    only such config.h entry that is 1 or 0. It comes unmodified
    from Gnulib's visibility.m4.

14 months agoCMake: Add comments
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
CMake: Add comments

14 months agoCMake: Remove the note that some tests aren't run
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
CMake: Remove the note that some tests aren't run

They are now in the common build configurations.

14 months agoCMake: Add support for test_files.sh
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
CMake: Add support for test_files.sh

14 months agoTests: Make test_files.sh more flexible
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
Tests: Make test_files.sh more flexible

Add a new optional argument to specify the directory of the xz and
xzdec executables.

If ../config.h doesn't exist, assume that all encoders and decoders
are available.

14 months agoCMake: Add support for test_compress.sh tests
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
CMake: Add support for test_compress.sh tests

14 months agoTests: Make test_compress.sh more flexible
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
Tests: Make test_compress.sh more flexible

Add a new optional second argument: directory of the xz and xzdec
executables. This is need with the CMake build where the binaries
end up in the top-level build directory.

If ../config.h doesn't exist, assume that all encoders and decoders
are available. This will make this script usable from CMake in the
most common build configuration.

NOTE: Since the existence of ../config.h is checked, the working
directory of the test script must be a subdir in the build tree!
Otherwise ../config.h would look outside the build tree.

Use the default check type instead of forcing CRC32 or CRC64.
Now the script doesn't need to check if CRC64 is available.

14 months agoCMake: Prepare to support the test_*.sh tests
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
CMake: Prepare to support the test_*.sh tests

This is a bit hacky since the scripts grep config.h to know which
features were built but the CMake build doesn't create config.h.
So instead those test scripts will be run only when all relevant
features have been enabled.

14 months agoTests: test_suffix.sh: Add a comment
Lasse Collin [Mon, 20 May 2024 13:55:00 +0000 (16:55 +0300)] 
Tests: test_suffix.sh: Add a comment

14 months agoFix typos
Lasse Collin [Fri, 17 May 2024 21:34:07 +0000 (00:34 +0300)] 
Fix typos

Thanks to xx on #tukaani.

14 months agoliblzma: Fix white space
Lasse Collin [Fri, 17 May 2024 21:23:52 +0000 (00:23 +0300)] 
liblzma: Fix white space

Thanks to xx on #tukaani.

14 months agoBuild: Temporarily disable CRC CLMUL to silence OSS Fuzz
Lasse Collin [Wed, 15 May 2024 20:14:17 +0000 (23:14 +0300)] 
Build: Temporarily disable CRC CLMUL to silence OSS Fuzz

The code makes aligned 16-byte reads which may read up to 15 bytes
before the beginning or past the end of the buffer if the buffer
is misaligned. The unneeded bytes are then ignored. It cannot cross
page boundaries and thus cannot cause access violations.

This inherently trips address sanitizer which was already disabled
with __attribute__((__no_sanitize_address__)). However, it also
trips memory sanitizer if the extra bytes are uninitialized because
memory sanitizer doesn't see that those bytes then get ignored by
byte shuffling in the xmm registers.

The plan is to change the code so that all sanitizers pass but it's
not finished yet (performance shouldn't get worse) so as a temporary
measure to keep OSS Fuzz happy, the CLMUL CRC is now disabled even
though I think think the code is fine to use (and easy enough to review
the memory accesses in it too).

14 months agoxz: Document the static function get_chains_memusage()
Lasse Collin [Mon, 13 May 2024 14:15:04 +0000 (17:15 +0300)] 
xz: Document the static function get_chains_memusage()

14 months agoxz: Rename filters_memusage_max() to get_chains_memusage()
Lasse Collin [Mon, 13 May 2024 14:07:22 +0000 (17:07 +0300)] 
xz: Rename filters_memusage_max() to get_chains_memusage()

14 months agoxz: Rename filter_memusages to chains_memusages
Lasse Collin [Mon, 13 May 2024 14:04:05 +0000 (17:04 +0300)] 
xz: Rename filter_memusages to chains_memusages

14 months agoxz: Simplify the memory usage scaling code
Lasse Collin [Sun, 12 May 2024 19:26:30 +0000 (22:26 +0300)] 
xz: Simplify the memory usage scaling code

This is closer to what it was before the --filtersX support was added,
just extended to support for scaling all filter chains. The method
before this commit was an extended version of the original too but
it was done in a more complex way for no clear reason. In case of
an error, the complex version printed fewer informative messages
(a good thing) but it's not a sigificant benefit.

In the limit is too low even for single-threaded mode, the required
amount of memory is now reported like in 5.4.x instead of like in
5.5.1alpha - 5.6.1 which showed the original non-scaled usage. It
had been a FIXME in the old code but it's not clear what message
makes the most sense.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
14 months agoxz: Edit comments
Lasse Collin [Mon, 13 May 2024 09:14:00 +0000 (12:14 +0300)] 
xz: Edit comments

14 months agoxz: Rename chain_idx to chain_num
Lasse Collin [Mon, 13 May 2024 09:03:51 +0000 (12:03 +0300)] 
xz: Rename chain_idx to chain_num

14 months agoxz: Edit coding style
Lasse Collin [Sun, 12 May 2024 19:29:11 +0000 (22:29 +0300)] 
xz: Edit coding style

14 months agoxz: Edit comments
Lasse Collin [Sun, 12 May 2024 19:16:05 +0000 (22:16 +0300)] 
xz: Edit comments

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
14 months agoxz: Fix grammar in a comment
Lasse Collin [Sun, 12 May 2024 18:57:49 +0000 (21:57 +0300)] 
xz: Fix grammar in a comment

Fixes: cb3111e3ed84152912b5138d690c8d9f00c6ef02
14 months agoxz: Rename filter_memusages to encoder_memusages
Lasse Collin [Sun, 12 May 2024 18:46:56 +0000 (21:46 +0300)] 
xz: Rename filter_memusages to encoder_memusages

14 months agoxz: Edit coding style
Lasse Collin [Sun, 12 May 2024 18:42:05 +0000 (21:42 +0300)] 
xz: Edit coding style

14 months agoxz: Rename filters_index to chain_num
Lasse Collin [Sun, 12 May 2024 18:31:02 +0000 (21:31 +0300)] 
xz: Rename filters_index to chain_num

The reason is the same as in bd0782c1f13e52cd0fd8415208e30e47004a4c68.

14 months agoxz: Replace a few uint32_t with "unsigned" to reduce the number of casts
Lasse Collin [Sun, 12 May 2024 18:22:43 +0000 (21:22 +0300)] 
xz: Replace a few uint32_t with "unsigned" to reduce the number of casts

These hold only tiny values.

14 months agoxz: Rename filters_used_mask to chains_used_mask
Lasse Collin [Sun, 12 May 2024 18:10:45 +0000 (21:10 +0300)] 
xz: Rename filters_used_mask to chains_used_mask

The reason is the same as in bd0782c1f13e52cd0fd8415208e30e47004a4c68.

14 months agoxz: Move the setting of "check" in coder_set_compression_settings()
Lasse Collin [Sun, 12 May 2024 14:14:43 +0000 (17:14 +0300)] 
xz: Move the setting of "check" in coder_set_compression_settings()

It's more logical to do it in the beginning instead of in the middle
of the filter chain handling.

Fixes: d6af7f347077b22403133239592e478931307759
14 months agoxz: Rename "filters" to "chains"
Lasse Collin [Sun, 12 May 2024 14:09:17 +0000 (17:09 +0300)] 
xz: Rename "filters" to "chains"

The convention is that

    lzma_filter filters[LZMA_FILTERS_MAX + 1];

contains the filters of a single filter chain.
It was so here as well before the commit
d6af7f347077b22403133239592e478931307759.
It changes "filters" to a ten-element array of filter chains.
It's clearer to call this array-of-arrays "chains".

This also renames "filter_idx" to "chain_idx" which is used
as an index as in chains[chain_idx].

14 months agoxz: Clean up a comment
Lasse Collin [Sun, 12 May 2024 13:56:15 +0000 (16:56 +0300)] 
xz: Clean up a comment

14 months agoxz: Add clarifying assertions
Lasse Collin [Sun, 12 May 2024 13:52:09 +0000 (16:52 +0300)] 
xz: Add clarifying assertions

14 months agoxz: Add a clarifying assertion
Lasse Collin [Fri, 10 May 2024 17:23:33 +0000 (20:23 +0300)] 
xz: Add a clarifying assertion

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
14 months agoxz: Clarify a comment
Lasse Collin [Sun, 12 May 2024 13:47:17 +0000 (16:47 +0300)] 
xz: Clarify a comment

14 months agoxz: Use the info collected in parse_block_list()
Lasse Collin [Sun, 12 May 2024 13:28:25 +0000 (16:28 +0300)] 
xz: Use the info collected in parse_block_list()

This is slightly simpler and it avoids looping through
the opt_block_list array.

14 months agoxz: Remember the filter chains and the largest Block in parse_block_list()
Lasse Collin [Sun, 12 May 2024 12:48:45 +0000 (15:48 +0300)] 
xz: Remember the filter chains and the largest Block in parse_block_list()