Add a build system

This commit is contained in:
2026-04-29 22:28:21 +01:00
parent 5cb47a17a2
commit fb83c3114f
22 changed files with 761 additions and 93 deletions

View File

@@ -20,36 +20,55 @@ It is a high performance cross platform Windows and Linux compatible program, it
* Fallback to buffered I/O if there is errors in the IO Ring path.
# Building
## Windows
### Release
**Note**: Make sur to use UCRT64 environment from MSYS2 instead of the standard MinGW environment.
## Windows
**Requirements**: Make sur to use UCRT64 environment from MSYS2 instead of the standard MinGW environment.
UCRT64 uses the modern Universal C Runtime (ucrtbase.dll), which supports the newest APIs,
the standard MSYS2 uses the legacy msvcrt.dll and does not support IO Ring.
To install:
pacman -S mingw-w64-ucrt-x86_64-gcc
pacman -S mingw-w64-ucrt-x86_64-clang
pacman -Syu
pacman -S mingw-w64-ucrt-x86_64-clang
pacman -S mingw-w64-ucrt-x86_64-cmake
pacman -Syu
And add to path:
C:\msys64\ucrt64\bin
gcc -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -o file_hasher
clang -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -o file_hasher
### Using a build system
| Command | Description|
| :--- | :--- |
| ./build.bat | Build Release with best available compiler |
| ./build.bat Debug | Build Debug |
| ./build.bat clean | Clean and build Release |
| ./build.bat Debug clean | Clean and build Debug |
### Release
gcc -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -o filehasher
clang -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -o filehasher
clang-cl /O2 file_hasher.c xxhash.c xxh_x86dispatch.c
### Debug
gcc -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -o file_hasher
clang -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -o file_hasher
gcc -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -o filehasher
clang -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -o filehasher
clang-cl /Zi /Od file_hasher.c xxhash.c xxh_x86dispatch.c
## Linux
**Requirements**: GCC, CMake and Ninja
### Using a build system
| Command | Description|
| :--- | :--- |
| ./build.sh | Build Release with best available compiler |
| ./build.sh Debug | Build Debug |
| ./build.sh clean | Clean and build Release |
| ./build.sh Debug clean | Clean and build Debug |
### Release
gcc -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o file_hasher
clang -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o file_hasher
gcc -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o filehasher
clang -O3 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o filehasher
### Debug
gcc -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o file_hasher
clang -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o file_hasher
gcc -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o filehasher
clang -g -O0 file_hasher.c xxhash.c xxh_x86dispatch.c -pthread -luring -o filehasher
# Notes about the IO Ring implementations
## IO Ring