Skip to content

Commit

Permalink
Updated zlib to v1.3.1
Browse files Browse the repository at this point in the history
Added Apple Silicon ARM build for Mac OS
Fixed Clang 15 compilation on newer MacOS images
  • Loading branch information
cbnolok committed May 6, 2024
1 parent 19d9b91 commit 3b2c4d9
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 85 deletions.
68 changes: 63 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
with:
name: Build-win-x86_64
path: SphereSvrX-win-x86_64-nightly.zip
overwrite: true


windows-x86:
Expand All @@ -44,7 +45,7 @@ jobs:
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v2
- name: CMake
run: cmake -G "Visual Studio 17 2022" -A Win32 .\
- name: MSBuild
Expand All @@ -63,6 +64,7 @@ jobs:
with:
name: Build-win-x86
path: SphereSvrX-win-x86-nightly.zip
overwrite: true


linux-x86_64:
Expand Down Expand Up @@ -107,6 +109,7 @@ jobs:
with:
name: Build-linux-x86_64
path: SphereSvrX-linux-x86_64-nightly.tar.gz
overwrite: true

linux-x86:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -184,13 +187,14 @@ jobs:
with:
name: Build-linux-x86
path: SphereSvrX-linux-x86-nightly.tar.gz
overwrite: true


macos-x86_64:
runs-on: macos-12
runs-on: macos-13 # intel
env:
CMAKE_GEN: Ninja
CMAKE_TCH_64: cmake/toolchains/OSX-AppleClang-x86_64.cmake
CMAKE_TCH: cmake/toolchains/OSX-AppleClang-x86_64.cmake

steps:
- name: Checkout repository
Expand All @@ -214,7 +218,7 @@ jobs:
- name: CMake
run: |
mkdir -p build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE="Nightly" -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TCH_64" -S . -B ./build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE="Nightly" -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TCH" -S . -B ./build
- name: Ninja
run: cd build && ninja -v && cd ..
- name: Create package
Expand All @@ -233,12 +237,65 @@ jobs:
with:
name: Build-osx-x86_64
path: SphereSvrX-osx-x86_64-nightly.zip
overwrite: true


macos-arm64:
runs-on: macos-14 # apple silicon
env:
CMAKE_GEN: Ninja
CMAKE_TCH: cmake/toolchains/OSX-AppleClang-native.cmake

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install prerequisites
run: |
sw_vers
echo && echo "** Setting up compiler" && echo
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew install ninja mariadb-connector-c
- name: Report building tools
run: |
echo "Apple Clang:" && clang --version
echo && echo "CMake:" && cmake --version
echo && echo "Ninja:" && ninja --version
- name: CMake
run: |
mkdir -p build
cmake -G "Ninja" -DCMAKE_BUILD_TYPE="Nightly" -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TCH" -S . -B ./build
- name: Ninja
run: cd build && ninja -v && cd ..
- name: Create package
run: |
pwd
mkdir accounts logs save scripts
zip -r SphereSvrX-osx-arm64-nightly.zip accounts/ logs/ save/ scripts/
zip SphereSvrX-osx-arm64-nightly.zip src/sphere.ini src/sphereCrypt.ini build/bin-native64/*
# Upload artifact linked to the workflow run - only if the run is for a pull request, or for selected branches
- name: Upload artifact
if: contains(fromJson('["master", "main", "dev"]'), github.ref_name) || ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Build-osx-x86_64
path: SphereSvrX-osx-arm64-nightly.zip
overwrite: true


upload:
needs: [windows-x86_64, windows-x86, linux-x86_64, linux-x86, macos-x86_64]
needs: [windows-x86_64, windows-x86, linux-x86_64, linux-x86, macos-x86_64, macos-arm64]
# Upload artifact linked to GitHub RELEASE we are creating - only if the run is for a pull request, or for selected branches
if: contains(fromJson('["master", "main", "dev"]'), github.ref_name) || ${{ github.event_name == 'pull_request' }}

runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down Expand Up @@ -269,3 +326,4 @@ jobs:
SphereSvrX-linux-x86_64-nightly.tar.gz
SphereSvrX-linux-x86-nightly.tar.gz
SphereSvrX-osx-x86_64-nightly.zip
SphereSvrX-osx-arm64-nightly.zip
1 change: 1 addition & 0 deletions cmake/toolchains/OSX-AppleClang_common.inc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ unreachable,nonnull-attribute,returns-nonnull-attribute \
HINT
"/usr/local/opt/mariadb-connector-c/lib/mariadb"
"/opt/homebrew/var/mariadb-connector-c/lib/mariadb"
"/opt/homebrew/lib/mariadb"
)
ENDFOREACH ()

Expand Down
34 changes: 19 additions & 15 deletions lib/zlib/deflate.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand Down Expand Up @@ -52,7 +52,7 @@
#include "deflate.h"

const char deflate_copyright[] =
" deflate 1.3.0.1 Copyright 1995-2023 Jean-loup Gailly and Mark Adler ";
" deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
Expand Down Expand Up @@ -493,11 +493,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
* symbols from which it is being constructed.
*/

#ifdef LIT_MEM
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 5);
#else
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
#endif
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
s->pending_buf_size = (ulg)s->lit_bufsize * 4;

if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
Expand Down Expand Up @@ -1310,7 +1306,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);

if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
ds->pending_buf == Z_NULL) {
Expand All @@ -1321,7 +1317,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);

ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
#ifdef LIT_MEM
Expand Down Expand Up @@ -1560,13 +1556,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
*/
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* check that the match is indeed a match */
if (zmemcmp(s->window + match,
s->window + start, length) != EQUAL) {
fprintf(stderr, " start %u, match %u, length %d\n",
start, match, length);
Bytef *back = s->window + (int)match, *here = s->window + start;
IPos len = length;
if (match == (IPos)-1) {
/* match starts one byte before the current window -- just compare the
subsequent length-1 bytes */
back++;
here++;
len--;
}
if (zmemcmp(back, here, len) != EQUAL) {
fprintf(stderr, " start %u, match %d, length %d\n",
start, (int)match, length);
do {
fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
} while (--length != 0);
fprintf(stderr, "(%02x %02x)", *back++, *here++);
} while (--len != 0);
z_error("invalid match");
}
if (z_verbose > 1) {
Expand Down
4 changes: 3 additions & 1 deletion lib/zlib/deflate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2018 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand Down Expand Up @@ -222,9 +222,11 @@ typedef struct internal_state {
*/

#ifdef LIT_MEM
# define LIT_BUFS 5
ushf *d_buf; /* buffer for distances */
uchf *l_buf; /* buffer for literals/lengths */
#else
# define LIT_BUFS 4
uchf *sym_buf; /* buffer for distances and literals/lengths */
#endif

Expand Down
16 changes: 10 additions & 6 deletions lib/zlib/gzguts.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
* Copyright (C) 2004-2019 Mark Adler
* Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

// Manually patched for SphereServer
#ifndef _WIN32
#include <unistd.h>
// Fixing some errors for newer Clang versions, like:
// error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
#endif


#ifdef _LARGEFILE64_SOURCE
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
Expand Down Expand Up @@ -210,9 +218,5 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
value -- needed when comparing unsigned to z_off64_t, which is signed
(possible z_off64_t types off_t, off64_t, and long are all signed) */
#ifdef INT_MAX
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
#else
unsigned ZLIB_INTERNAL gz_intmax(void);
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
#endif
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
12 changes: 6 additions & 6 deletions lib/zlib/gzlib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
* Copyright (C) 2004-2019 Mark Adler
* Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand Down Expand Up @@ -563,20 +563,20 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
#endif
}

#ifndef INT_MAX
/* portably return maximum value for an int (when limits.h presumed not
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax(void) {
unsigned p, q;

p = 1;
#ifdef INT_MAX
return INT_MAX;
#else
unsigned p = 1, q;
do {
q = p;
p <<= 1;
p++;
} while (p > q);
return q >> 1;
}
#endif
}
6 changes: 3 additions & 3 deletions lib/zlib/inftrees.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2023 Mark Adler
* Copyright (C) 1995-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand All @@ -9,7 +9,7 @@
#define MAXBITS 15

const char inflate_copyright[] =
" inflate 1.3.0.1 Copyright 1995-2023 Mark Adler ";
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
Expand Down Expand Up @@ -57,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 70, 200};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
Expand Down
4 changes: 2 additions & 2 deletions lib/zlib/inftrees.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ typedef struct {
examples/enough.c found in the zlib distribution. The arguments to that
program are the number of symbols, the initial root table size, and the
maximum bit length of a code. "enough 286 9 15" for literal/length codes
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
The initial root table size (9 or 6) is found in the fifth argument of the
returns 852, and "enough 30 6 15" for distance codes returns 592. The
initial root table size (9 or 6) is found in the fifth argument of the
inflate_table() calls in inflate.c and infback.c. If the root table size is
changed, then these maximum sizes would be need to be recalculated and
updated. */
Expand Down
4 changes: 2 additions & 2 deletions lib/zlib/trees.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
* Copyright (C) 1995-2021 Jean-loup Gailly
* Copyright (C) 1995-2024 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
Expand Down Expand Up @@ -938,7 +938,7 @@ local void compress_block(deflate_state *s, const ct_data *ltree,

/* Check for no overlay of pending_buf on needed symbols */
#ifdef LIT_MEM
Assert(s->pending < (s->lit_bufsize << 1) + sx, "pendingBuf overflow");
Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
#else
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
#endif
Expand Down
10 changes: 1 addition & 9 deletions lib/zlib/zconf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/

Expand Down Expand Up @@ -300,14 +300,6 @@
# endif
#endif

#ifndef Z_ARG /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define Z_ARG(args) args
# else
# define Z_ARG(args) ()
# endif
#endif

/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
Expand Down
Loading

0 comments on commit 3b2c4d9

Please sign in to comment.