1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00

219 Commits

Author SHA1 Message Date
Yann Collet
96be2ab78d build: mingw _WIN32_WINNT, pthread probe in a private directory, install installs what was built (checkpoint)
Prototype, not intended for a PR as is.

- lz4frame.c (Win32) : _WIN32_WINNT raised to 0x0600 (condition variables) when lower,
  instead of only when undefined : <_mingw.h>, included by standard headers, defines it
  to 0x502 on older mingw-w64, where CONDITION_VARIABLE was then undeclared.
  A higher user-defined value is preserved.
- lib/Makefile : the pthread probe runs within a private temporary directory (mktemp -d),
  instead of a fixed have_pthread.c in the source tree : concurrent invocations no longer
  collide (35 / 320 concurrent probes wrongly reported no threads, producing liblz4.so
  without multi-threading), and read-only source trees are supported.
  The build message mentions "(threads not detected)" when the probe fails.
- make install, as zstd : installs the libraries already built (lib, lib-mt, lib-nomt),
  and only builds them, with current settings, when absent :
  `make lib-mt && make install` now installs the multi-threaded libraries.
  liblz4.pc declares -pthread (Libs.private) when the installed liblz4.a requires it,
  deduced from its symbols (nm) ; when they can't be listed, whenever threads are available.
  Root Makefile : install is ordered after lib goals of the same command line
  (make -j all install, make -j lib-mt install), instead of always rebuilding lib.
- lib/README.md documents it.

Validated : full tests MT / no-MT, ASAN+UBSAN, TSAN, make test, wine, build policies,
Windows DLL through lib/Makefile (imports CreateThread), mingw with _WIN32_WINNT=0x0502,
10 install scenarios + test_install.sh, concurrent and read-only probes.
2026-10-22 04:26:50 -07:00
Yann Collet
02916432ee lz4frame: experimental multi-threaded one-shot compression (checkpoint)
Prototype, not intended for a PR as is.

- LZ4F_preferences_t.nbWorkers (replaces reserved[0], ABI preserved):
  LZ4F_compressFrame() and LZ4F_compressFrame_usingCDict() cut input into jobs,
  compressed by up to nbWorkers threads (inline fork-join, threads created per call).
  Output only depends on parameters, never on nbWorkers (>= 1) nor scheduling;
  identical to single-threaded with independent blocks, identical to the CLI -T output.
- LZ4F_MULTITHREAD build macro (default 0) : without it, jobs run serially, same output.
- build policy (zstd-like) : dynamic library multi-threaded by default, static library not
  (make lib-mt / lib-nomt / MULTITHREAD=, cmake LZ4_SHARED/STATIC_MULTITHREAD,
  meson shared-/static-multithread, VS2022 liblz4-dll).
- internal LZ4F_compressBlocks_internal() extracted from LZ4F_compressUpdateImpl().
- tests/frameMT.c (make -C tests test-frameMT) : validation + bench mode.

Known gaps : Win32 thread path never compiled; no persistent thread pool; no streaming.
2026-10-22 04:26:50 -07:00
hotschmoe
cde4b2b0fc make: install depends on lib and lz4
`install` builds the library and the CLI from its own sub-makes,
in lib/ and programs/, with no ordering relative to the `lib` and `lz4` targets.
When both are requested (`make all install`, parallel by default),
2 concurrent sub-makes build the same files in each directory's cachedObjs/,
and one of them can use an object, library or binary that the other one is still writing :
the link fails, or an empty or incomplete file gets installed.

Building `lib` and `lz4` first leaves nothing to rebuild for the install sub-makes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:15:26 +08:00
Yann Collet
b7e360402e fix race condition when building liblz4.a 2026-01-25 12:47:12 -08:00
Yann Collet
aa8694a11e make compilation uses multithreading by default 2026-01-25 10:59:16 -08:00
Yann Collet
6c6c95d764 fix ctocxxtest 2025-05-05 19:32:24 -07:00
Yann Collet
85d1c10ebe adjust cxxtest 2025-05-05 18:26:44 -07:00
Yann Collet
191efabe60 dynamic library built with multiconf.make
on posix.

Windows build is more complex.
It's doubtful if it's worth forcing its integration within multiconf.make.
2025-05-05 17:33:38 -07:00
Yann Collet
c9c9bf8c12 added multiconf doc 2025-05-01 16:53:52 -07:00
Yann Collet
5c434d38cc break dependency of programs/lz4 from lib/liblz4.a
now builds its own object files,
thus offering greater flexibility and control over compilation flags.
2025-05-01 09:29:23 -07:00
Yann Collet
741b9edb31 fixed mingw exe generation 2025-04-30 20:25:23 -07:00
Yann Collet
0944754f4c improve propagation test of standard Makefile variable 2025-04-30 19:31:09 -07:00
Yann Collet
a337f582cb fixed StandardVariables test
since quantity of compilation lines displayed has changed with new build macros.
2025-04-30 17:36:43 -07:00
Yann Collet
5387a1595c support *_SRCDIRS 2025-04-30 17:06:44 -07:00
Yann Collet
5edb4bfa22 fixed a minor ubsan warning 2025-02-24 22:26:29 -08:00
Yann Collet
15c30728ea update Github Actions tests
removed redundant tests
2023-12-30 23:02:52 -08:00
Yann Collet
a2d5ce407d fix standard_variables test 2023-12-28 21:30:42 -08:00
Yann Collet
c6762ec1c0 fixed meson build
and make it build the MT version of lz4
with an option that is enabled by default but can be disabled on demand.

Also :
- added make target mesonbuild, for easy local build
- made huge tests friendlier to MT variant, for faster testing time
2023-12-28 20:22:23 -08:00
Yann Collet
a49ca22195 fix cmake recipe
though it still builds single-threaded lz4
2023-12-28 17:14:15 -08:00
Yann Collet
cbe7211b9c make: fix lz4 mt compilation on linux/posix
now lz4 build defaults to single-thread mode
2023-12-28 16:26:01 -08:00
Yann Collet
f91702fb25 use make -j more often for CI 2023-12-24 20:02:27 -08:00
Yann Collet
5e663b90dd refactor C++ tests 2023-12-24 17:33:07 -08:00
Yann Collet
5c9e349c4a changed test name cpp->cxx
cpp evokes the C PreProcessor, rather than C++
2023-12-24 17:09:52 -08:00
Yann Collet
7b7cecd14a fix attempt for ppc64 test on circleci 2023-12-23 01:05:53 -08:00
Yann Collet
e52a82644f link final binary rather than copy
whenever possible (i.e. posix)
2023-12-17 15:23:22 -08:00
LocalSpook
f99c4382c7 Use -Wpedantic instead of -pedantic 2023-10-12 20:49:02 -07:00
Yann Collet
8c06506ee1 removed travis script and reference
travis is no longer accessible
2023-04-22 09:17:57 -07:00
Yann Collet
4dafb855a6 fixed usan32 tests
the sanitizer was not enabled,
due to environment variables not being passed.
2022-10-01 00:36:24 -07:00
Takayuki Matsuoka
4b74762203 Add test-freestanding to Makefile 2022-08-08 18:04:48 +09:00
Yann Collet
684ebfd4be Test support of Standard Makefile Variables
to detect issues such as #958
2022-07-15 11:29:50 +02:00
Yann Collet
42233d68f8 updated cmake test
use `cmake --build` instead of `make` directly
2022-02-03 16:27:02 -08:00
Yann Collet
596c747211 make UNAME externally definable
on top of providing a central definition place, which eases maintenance,
it might also help for #1021.

Also : updated doc
2021-08-16 16:43:17 -07:00
Takayuki Matsuoka
6443b85af4 Split c_standards into multiple Makefile targets
To support older compiler which doesn't have explicit dialect option
for C90 (gcc-4.4),  this change set split "c_standards" into multiple
part.

Original "make c_standards" still works as intended.  But this change
gives extra freedom of choice for external program  For example, CI
can choose test for standards which is supported by specimen compiler.

With this separation, we can also introduce C17 smoothly.
2021-05-30 17:10:19 +09:00
Takayuki Matsuoka
0d2570b7c5 Add CC propagation to 'make usan'
The following command doesn't work as intended

```
cd
git clone https://github.com/lz4/lz4.git
cd lz4
make usan MOREFLAGS='-Wcomma -Werror'
```

```
Cleaning completed
cc: error: unrecognized command line option ‘-Wcomma’; did you mean ‘-Wcomment’?
make[3]: *** [<builtin>: ../lib/lz4.o] Error 1
make[2]: *** [Makefile:65: lz4] Error 2
make[1]: *** [Makefile:133: test] Error 2
make: *** [Makefile:158: usan] Error 2
```

Because the following part of the `Makefile` doesn't propagate `CC`, `CFLAGS` and `LDFLAGS` to child `$(MAKE)` properly.

```
.PHONY: usan
usan: CC      = clang
usan: CFLAGS  = -O3 -g -fsanitize=undefined -fno-sanitize-recover=undefined -fsanitize-recover=pointer-overflow
usan: LDFLAGS = $(CFLAGS)
usan: clean
        $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
```

We need explicit propagation for child process

```
-       $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
+       CC=$(CC) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
```

After that, `make usan` works and it shows expected runtime error.

```
$ make usan MOREFLAGS='-Wcomma -Werror'
Cleaning completed

../lib/lz4frame.c:907:25: runtime error: applying non-zero offset 65536 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/lz4frame.c:907:25 in
../lib/lz4frame.c:907:58: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/lz4frame.c:907:58 in

...
```

Please note that `make usan` is working at travis-ci.  Because `.travis.yml` has the following [explicit `compiler:` setting](7a966c1511/.travis.yml (L66)).

```
    - name: (Trusty) USan test
      dist: trusty
      compiler: clang
      script:
        - make usan MOREFLAGS=-Wcomma -Werror
```
2021-05-27 21:02:34 +09:00
Yann Collet
7d8d1075e6 fixed incorrect propagation of default CFLAGS 2021-04-26 22:40:40 -07:00
Yann Collet
4b7a327068 fix strange printf formatting warning
so now, `%p` _requires_ a `void*` pointer ?
2020-12-01 08:05:19 -08:00
Yann Collet
16bad2caaf fix scanbuild test
seems to require explicit environment variables
2020-11-30 18:13:05 -08:00
Yann Collet
19564bce78 fix CFLAGS unexport issue 2020-11-30 17:42:36 -08:00
Yann Collet
e585a438c7 refactor Makefile
remove usage of include Makefile.inc in too Makefile
as it seems to somehow unexport CFLAGS ...
2020-11-30 16:06:50 -08:00
Yann Collet
a88c8fb438 make it possible to select SCANBUILD binary on command line 2020-10-01 23:27:02 -07:00
Yann Collet
03f006a7ea make scan-build accept assert() 2020-10-01 10:48:22 -07:00
Yann Collet
4f57219a22 fixed ubsan tests with dynamic library 2020-09-17 16:49:21 -07:00
Yann Collet
b223f11b21 ubsan: make pointer overflow recoverable
the way `base` is used must allow 2-complement address overflow.
`base` is effectively a virtual pointer, never dereferenced directly.
What matters is `base + index`.
This is the address that will be dereference and must be valid (it is properly validated).
2020-09-17 15:34:03 -07:00
Yann Collet
b4a64e0eac fix ubsan test
which now fails with a clear error as intended
(not just print a status and move on).
should be reproduced on travisCI
2020-09-17 10:29:31 -07:00
Nick Terrell
31d477db07 [build] Move CMake and Visual build systems to build/
Fixes #852.
2020-08-19 18:08:43 -07:00
Max Dymond
02b5b3c242 Move to using C rather than C++ for compilation 2019-06-28 23:48:33 +01:00
Max Dymond
a5cf079d4d Add a fuzzing target that compiles in the oss-fuzz environment 2019-06-28 08:30:02 +01:00
Yann Collet
e2527ad725 updated tests
- only play listTest with `make test`, not `make all` which is limited to build
- update `clangtest`, so that it's possible to disable O3 optimization, for faster processing
2019-05-16 16:46:16 -07:00
JPeterMugaas
2acddd9918 Fix a test for mingw 2019-04-22 16:06:04 -04:00
JPeterMugaas
b48f823f90 Try to put some tests I made in ONE place. I also moved a test for "install" in one place to try to isolate it. 2019-04-22 15:48:48 -04:00