From 61031f4818baf3ac10b00a5730e9708d8ab4b966 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 17:20:42 +0200 Subject: [PATCH 01/10] fix: build on darwin --- deps/Makefile | 16 +++++----------- deps/curl/configure.patch | 29 +++++++++++++++++------------ include/proxysql_utils.h | 18 +++++++++--------- lib/ProxySQL_GloVars.cpp | 2 +- lib/sha256crypt.cpp | 15 ++++++++++++--- src/Makefile | 3 +-- 6 files changed, 45 insertions(+), 38 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 7e4235dc97..97be1744f4 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -60,11 +60,7 @@ ifneq ($(CENTOSVER),6) cd libinjection/libinjection && patch -p1 < ../update-build-py3.diff cd libinjection/libinjection && patch -p1 < ../libinjection_sqli.c.patch endif -ifeq ($(SYS_KERN),Darwin) - sed -i '' 's/CC=/CC?=/' libinjection/libinjection/src/Makefile -else sed -i -e 's/CC=/CC?=/' libinjection/libinjection/src/Makefile -endif cd libinjection/libinjection && CC=${CC} CXX=${CXX} ${MAKE} libinjection: libinjection/libinjection/src/libinjection.a @@ -94,6 +90,9 @@ libhttpserver/libhttpserver/build/src/.libs/libhttpserver.a: libmicrohttpd/libmi cd libhttpserver/libhttpserver && patch -p0 < ../replace_static_global_strings.patch ifeq ($(UNAME_S),FreeBSD) sed -i -e 's/\/bin\/bash/\/usr\/local\/bin\/bash/' libhttpserver/libhttpserver/bootstrap +endif +ifeq ($(SYS_KERN),Darwin) + sed -i -e 's/glibtoolize/libtoolize/' libhttpserver/libhttpserver/bootstrap endif cd libhttpserver/libhttpserver && ./bootstrap && mkdir build cd libhttpserver/libhttpserver/build && LDFLAGS=-L$(shell pwd)/libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/ CPPFLAGS=-I$(shell pwd)/libmicrohttpd/libmicrohttpd/src/include ../configure --disable-doxygen-doc --disable-doxygen-dot --disable-doxygen-man --disable-doxygen-html --enable-fastopen=false --disable-examples @@ -245,7 +244,8 @@ sqlite3/sqlite3/sqlite3.o: cd sqlite3 && tar -zxf sqlite-amalgamation-*.tar.gz cd sqlite3/sqlite3 && patch -p1 < ../from_unixtime.patch cd sqlite3/sqlite3 && patch sqlite3.c < ../sqlite3.c-multiplication-overflow.patch - cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch +# FIX ME +# cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch cd sqlite3/sqlite3 && ${CC} ${MYCFLAGS} -fPIC -c -o sqlite3.o sqlite3.c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_DLL=1 cd sqlite3/sqlite3 && ${CC} -shared -o libsqlite3.so sqlite3.o @@ -280,13 +280,8 @@ re2/re2/obj/libre2.a: # cd re2/re2 && sed -i -e 's/-O3 -g /-O3 -fPIC /' Makefile # cd re2/re2 && patch util/mutex.h < ../mutex.h.patch cd re2/re2 && patch re2/onepass.cc < ../onepass.cc-multiplication-overflow.patch -ifeq ($(SYS_KERN),Darwin) - cd re2/re2 && sed -i '' -e 's/-O3 -g/-O3 -g -${STDCPP} -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile -# cd re2/re2 && sed -i '' -e 's/RE2_CXXFLAGS?=-std=c++11 /RE2_CXXFLAGS?=-std=c++11 -fPIC /' Makefile -else cd re2/re2 && sed -i -e 's/-O3 -g/-O3 -g ${STDCPP} -fPIC -DMEMORY_SANITIZER -DRE2_ON_VALGRIND /' Makefile # cd re2/re2 && sed -i -e 's/RE2_CXXFLAGS?=-std=c++11 /RE2_CXXFLAGS?=-std=c++11 -fPIC /' Makefile -endif cd re2/re2 && CC=${CC} CXX=${CXX} ${MAKE} re2: re2/re2/obj/libre2.a @@ -331,4 +326,3 @@ cleanall: cd cityhash && rm -rf cityhash-*/ || true cd coredumper && rm -rf coredumper-*/ || true .PHONY: cleanall - diff --git a/deps/curl/configure.patch b/deps/curl/configure.patch index 1a60f5c559..292abd2d2a 100644 --- a/deps/curl/configure.patch +++ b/deps/curl/configure.patch @@ -1,18 +1,23 @@ -@@ -34014,7 +34014,7 @@ - else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +@@ -34590,7 +34590,7 @@ + else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } - as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 -+# as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 - ++ #as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 + ;; + esac fi - rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ -@@ -34049,7 +34049,7 @@ - else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +@@ -34629,7 +34629,7 @@ + else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } - as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 -+# as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 - ++ #as_fn_error $? "one or more libs available at link-time are not available run-time. Libs used at link-time: $LIBS" "$LINENO" 5 + ;; + esac fi - rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ +@@ -49329,4 +49329,3 @@ + WARNING: $experimental enabled but marked EXPERIMENTAL. Use with caution! + _EOF + fi +- diff --git a/include/proxysql_utils.h b/include/proxysql_utils.h index 2e127e57c4..3b0f6a0547 100644 --- a/include/proxysql_utils.h +++ b/include/proxysql_utils.h @@ -25,19 +25,19 @@ #define ETIME ETIMEDOUT #endif -#ifdef CXX17 -template struct conjunction : std::true_type { }; -template struct std::conjunction : B1 { }; -template -struct std::conjunction - : std::conditional, B1>::type {}; -#else +// #ifdef CXX17 +// template struct conjunction : std::true_type { }; +// template struct std::conjunction : B1 { }; +// template +// struct std::conjunction +// : std::conditional, B1>::type {}; +// #else template struct conjunction : std::true_type { }; template struct conjunction : B1 { }; template -struct conjunction +struct conjunction : std::conditional, B1>::type {}; -#endif // CXX17 +// #endif // CXX17 /** * @brief Stores the result of formatting the first parameter with the provided * arguments, into the std::string reference provided in the second parameter. diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index b01c62f893..4b2a28210c 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -321,7 +321,7 @@ void update_string_var_if_set(char** cur_val, ez::ezOptionParser* opt, const cha void update_ulong_var_if_set(uint64_t& cur_val, ez::ezOptionParser* opt, const char* cmd_opt) { if (opt->isSet(cmd_opt)) { - opt->get(cmd_opt)->getULong(cur_val); + //opt->get(cmd_opt)->getULong(cur_val); } } diff --git a/lib/sha256crypt.cpp b/lib/sha256crypt.cpp index 1eafd5fb2b..2bf82275a0 100644 --- a/lib/sha256crypt.cpp +++ b/lib/sha256crypt.cpp @@ -1,7 +1,16 @@ /* SHA256-based Unix crypt implementation. Released into the Public Domain by Ulrich Drepper . */ -#include +#include +#if defined __APPLE__ + #include + #include + + // define 64 bit macros + #define htole64(x) OSSwapHostToLittleInt64(x) +#else + #include +#endif #include #include #include @@ -424,7 +433,7 @@ extern "C" char * sha256_crypt_r (const char *key, const char *salt, char *buffe /* Create byte sequence P. */ cp = p_bytes = (char *)alloca (key_len); for (cnt = key_len; cnt >= 32; cnt -= 32) - cp = (char *)mempcpy (cp, temp_result, 32); + cp = (char *)memcpy (cp, temp_result, 32); memcpy (cp, temp_result, cnt); /* Start computation of S byte sequence. */ @@ -440,7 +449,7 @@ extern "C" char * sha256_crypt_r (const char *key, const char *salt, char *buffe /* Create byte sequence S. */ cp = s_bytes = (char *)alloca (salt_len); for (cnt = salt_len; cnt >= 32; cnt -= 32) - cp = (char *) mempcpy (cp, temp_result, 32); + cp = (char *) memcpy (cp, temp_result, 32); memcpy (cp, temp_result, cnt); /* Repeatedly run the collected hash value through SHA256 to burn diff --git a/src/Makefile b/src/Makefile index 40480140b9..01a10c739c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -158,7 +158,7 @@ endif MYCXXFLAGS := $(STDCPP) ifeq ($(CXX),clang++) - MYCXXFLAGS += -fuse-ld=lld + #MYCXXFLAGS += -fuse-ld=lld endif MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN) @@ -243,4 +243,3 @@ default: $(EXECUTABLE) clean: rm -rf *.pid $(ODIR)/*.o $(ODIR)/*.gcno $(ODIR)/*.gcda *~ core perf.data* heaptrack.proxysql.* $(EXECUTABLE) $(EXECUTABLE).sha1 $(ODIR) - From a2eb1b37b8e553f976c6201e4e2dc7ab76f40d06 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 17:56:08 +0200 Subject: [PATCH 02/10] fix: data type for getULong --- include/proxysql_glovars.hpp | 6 +++--- lib/ProxySQL_GloVars.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/proxysql_glovars.hpp b/include/proxysql_glovars.hpp index b2b2066fc3..faa6c8f5ba 100644 --- a/include/proxysql_glovars.hpp +++ b/include/proxysql_glovars.hpp @@ -106,7 +106,7 @@ class ProxySQL_GlobalVariables { bool restart_on_error; int restart_delay; std::mutex ssl_mutex; - SSL_CTX *ssl_ctx; + SSL_CTX *ssl_ctx; SSL_CTX *tmp_ssl_ctx; // these two buffers are used for the web interface char * ssl_key_pem_mem; @@ -121,9 +121,9 @@ class ProxySQL_GlobalVariables { char* gr_bootstrap_account; char* gr_bootstrap_account_create; char* gr_bootstrap_account_host; - uint64_t gr_bootstrap_password_retries; + unsigned long gr_bootstrap_password_retries; char* gr_bootstrap_conf_bind_address; - uint64_t gr_bootstrap_conf_base_port; + unsigned long gr_bootstrap_conf_base_port; bool gr_bootstrap_conf_use_sockets; bool gr_bootstrap_conf_skip_tcp; char* gr_bootstrap_ssl_ca; diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index 4b2a28210c..d3c5ff2312 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -319,9 +319,9 @@ void update_string_var_if_set(char** cur_val, ez::ezOptionParser* opt, const cha } } -void update_ulong_var_if_set(uint64_t& cur_val, ez::ezOptionParser* opt, const char* cmd_opt) { +void update_ulong_var_if_set(unsigned long& cur_val, ez::ezOptionParser* opt, const char* cmd_opt) { if (opt->isSet(cmd_opt)) { - //opt->get(cmd_opt)->getULong(cur_val); + opt->get(cmd_opt)->getULong(cur_val); } } From 7b908bbce386beca3ac5aa2c2473d70d5aa106b7 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 18:01:58 +0200 Subject: [PATCH 03/10] fix: compile error with clang 16 --- include/proxysql_utils.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/include/proxysql_utils.h b/include/proxysql_utils.h index 3b0f6a0547..77b8ab4063 100644 --- a/include/proxysql_utils.h +++ b/include/proxysql_utils.h @@ -25,19 +25,12 @@ #define ETIME ETIMEDOUT #endif -// #ifdef CXX17 -// template struct conjunction : std::true_type { }; -// template struct std::conjunction : B1 { }; -// template -// struct std::conjunction -// : std::conditional, B1>::type {}; -// #else template struct conjunction : std::true_type { }; template struct conjunction : B1 { }; template struct conjunction : std::conditional, B1>::type {}; -// #endif // CXX17 + /** * @brief Stores the result of formatting the first parameter with the provided * arguments, into the std::string reference provided in the second parameter. From a7593ff515bf859326cecc84bf2406c065bac468 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 19:12:39 +0200 Subject: [PATCH 04/10] fix: sqlite mysql auth patch --- deps/Makefile | 9 ++++----- deps/sqlite3/sqlite3_pass_exts.patch | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 97be1744f4..24501d5331 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -239,17 +239,16 @@ endif mariadb_client: mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a -sqlite3/sqlite3/sqlite3.o: +sqlite3/sqlite3/libsqlite3.so: cd sqlite3 && rm -rf sqlite-amalgamation-*/ || true cd sqlite3 && tar -zxf sqlite-amalgamation-*.tar.gz cd sqlite3/sqlite3 && patch -p1 < ../from_unixtime.patch cd sqlite3/sqlite3 && patch sqlite3.c < ../sqlite3.c-multiplication-overflow.patch -# FIX ME -# cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch + cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch cd sqlite3/sqlite3 && ${CC} ${MYCFLAGS} -fPIC -c -o sqlite3.o sqlite3.c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_DLL=1 - cd sqlite3/sqlite3 && ${CC} -shared -o libsqlite3.so sqlite3.o + cd sqlite3/sqlite3 && ${CC} -shared -Wl,-U,_ERR_error_string -Wl,-U,_RAND_bytes -Wl,-U,_SHA1 -Wl,-U,_sha256_crypt_r -Wl,-U,_ERR_get_error -o libsqlite3.so sqlite3.o -sqlite3: sqlite3/sqlite3/sqlite3.o +sqlite3: sqlite3/sqlite3/libsqlite3.so libconfig/libconfig/lib/.libs/libconfig++.a: diff --git a/deps/sqlite3/sqlite3_pass_exts.patch b/deps/sqlite3/sqlite3_pass_exts.patch index 467a363616..12a9853c5a 100644 --- a/deps/sqlite3/sqlite3_pass_exts.patch +++ b/deps/sqlite3/sqlite3_pass_exts.patch @@ -3,7 +3,7 @@ @@ -25168,6 +25168,183 @@ sqlite3ResultStrAccum(context, &sRes); } - + +#define DEF_SALT_SIZE 20 +#define SHA_DIGEST_LENGTH 20 + @@ -11,7 +11,7 @@ +//////////////////////////////////////////////////////////////////////////////// + +// ctype.h -+extern int toupper (int __c) __THROW; ++extern int toupper (int __c); + +// SHA256_crypt +char * sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen); From e5440d0dbf49ba55cf1e17c271f3fb2e6568a1f5 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 19:16:26 +0200 Subject: [PATCH 05/10] ci: add basic darwin workflow --- .github/workflows/CI-darwin.yml | 19 +++++++++++++++++++ INSTALL.md | 4 ++-- Makefile | 8 ++++---- deps/Makefile | 12 +++++++----- lib/Makefile | 4 ++-- src/Makefile | 8 +++++--- 6 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/CI-darwin.yml diff --git a/.github/workflows/CI-darwin.yml b/.github/workflows/CI-darwin.yml new file mode 100644 index 0000000000..67d2daaf73 --- /dev/null +++ b/.github/workflows/CI-darwin.yml @@ -0,0 +1,19 @@ +name: Darwin + +on: + push: + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: brew install automake bzip2 cmake git gpatch gnutls ossp-uuid libtool + + - name: Build + run: make + + - name: Show version + run: ./src/proxysql --version diff --git a/INSTALL.md b/INSTALL.md index e7d5cfed02..677c65088e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -26,7 +26,7 @@ The list of currently supported operating systems for native packaging is: - Fedora 33,24 - OpenSUSE 15 - AlmaLinux 8,9 - + Download a __deb__ or __rpm__ installer file for your OS and architecture from: https://github.com/sysown/proxysql/releases @@ -111,7 +111,7 @@ https://github.com/ProxySQL/docker-images/tree/main/build-clang-images On modern Mac OSX, ProxySQL's dependencies are not fully satisfied by the tools included with the XCode/clang toolkit. Using the [Homebrew](https://brew.sh/) OSX package manager, dependencies can be installed and located on OSX like this: ```bash -brew install automake bzip2 cmake make git gpatch gnutls ossp-uuid +brew install automake bzip2 cmake make git gpatch gnutls ossp-uuid libtool ``` Go to the directory where you cloned the repo (or unpacked the tarball) and run: diff --git a/Makefile b/Makefile index a067414c08..4607fc6f8f 100644 --- a/Makefile +++ b/Makefile @@ -42,9 +42,9 @@ export MAKE export CURVER ### detect compiler support for c++11/17 -CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201703L) - CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | cut -d' ' -f3) LEGACY_BUILD := 1 ifneq ($(CPLUSPLUS),201103L) $(error Compiler must support at least c++11) @@ -235,7 +235,7 @@ build_tap_test_debug: build_tap_tests_debug build_tap_tests_debug: build_src_debug cd test/tap && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} debug -# ClickHouse build targets are now default build targets. +# ClickHouse build targets are now default build targets. # To maintain backward compatibility, ClickHouse targets are still available. .PHONY: build_deps_clickhouse build_deps_clickhouse: build_deps_default @@ -289,7 +289,7 @@ SYS_ARCH := $(shell uname -m) REL_ARCH := $(subst x86_64,amd64,$(subst aarch64,arm64,$(SYS_ARCH))) RPM_ARCH := .$(SYS_ARCH) DEB_ARCH := _$(REL_ARCH) -REL_VERS := $(shell echo ${GIT_VERSION} | grep -Po '(?<=^v|^)[\d\.]+') +REL_VERS := $(shell echo ${GIT_VERSION} | awk -F'[.-]' '{print $1"."$2"."$3}') RPM_VERS := -$(REL_VERS)-1 DEB_VERS := _$(REL_VERS) diff --git a/deps/Makefile b/deps/Makefile index 24501d5331..2d61b2ebfc 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -28,9 +28,9 @@ endif ### detect compiler support for c++11/17 -CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201703L) - CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201103L) $(error Compiler must support at least c++11) endif @@ -74,7 +74,7 @@ libssl/openssl/libssl.a: # cd libssl/openssl && patch crypto/asn1/a_time.c < ../a_time.c-multiplication-overflow.patch cd libssl/openssl && ./config no-ssl3 no-tests cd libssl/openssl && CC=${CC} CXX=${CXX} ${MAKE} - cd libssl/openssl && ln -fsT . lib # curl wants this path + cd libssl/openssl && ln -fs . lib # curl wants this path libssl: libssl/openssl/libssl.a @@ -92,7 +92,9 @@ ifeq ($(UNAME_S),FreeBSD) sed -i -e 's/\/bin\/bash/\/usr\/local\/bin\/bash/' libhttpserver/libhttpserver/bootstrap endif ifeq ($(SYS_KERN),Darwin) - sed -i -e 's/glibtoolize/libtoolize/' libhttpserver/libhttpserver/bootstrap +ifeq (, $(shell which glibtoolize)) + sed -i -e 's/glibtoolize/libtoolize/' libhttpserver/libhttpserver/bootstrap +endif endif cd libhttpserver/libhttpserver && ./bootstrap && mkdir build cd libhttpserver/libhttpserver/build && LDFLAGS=-L$(shell pwd)/libmicrohttpd/libmicrohttpd/src/microhttpd/.libs/ CPPFLAGS=-I$(shell pwd)/libmicrohttpd/libmicrohttpd/src/include ../configure --disable-doxygen-doc --disable-doxygen-dot --disable-doxygen-man --disable-doxygen-html --enable-fastopen=false --disable-examples @@ -159,7 +161,7 @@ lz4: lz4/lz4/lib/liblz4.a clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a: cd clickhouse-cpp && rm -rf clickhouse-cpp-*/ || true - cd clickhouse-cpp && ln -fsT clickhouse-cpp-2.3.0 clickhouse-cpp + cd clickhouse-cpp && ln -fs clickhouse-cpp-2.3.0 clickhouse-cpp cd clickhouse-cpp && tar -zxf v2.3.0.tar.gz && sync cd clickhouse-cpp/clickhouse-cpp && patch clickhouse/base/wire_format.h < ../wire_format.patch cd clickhouse-cpp/clickhouse-cpp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . diff --git a/lib/Makefile b/lib/Makefile index 58b17c29eb..798968c6fb 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -95,9 +95,9 @@ endif ### detect compiler support for c++11/17 -CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201703L) - CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201103L) $(error Compiler must support at least c++11) endif diff --git a/src/Makefile b/src/Makefile index 01a10c739c..363d810439 100644 --- a/src/Makefile +++ b/src/Makefile @@ -105,9 +105,9 @@ endif ### detect compiler support for c++11/17 -CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') +CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201703L) - CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') + CPLUSPLUS := $(shell ${CC} -std=c++11 -dM -E -x c++ /dev/null 2>/dev/null| grep -F __cplusplus | cut -d' ' -f3) ifneq ($(CPLUSPLUS),201103L) $(error Compiler must support at least c++11) endif @@ -158,7 +158,9 @@ endif MYCXXFLAGS := $(STDCPP) ifeq ($(CXX),clang++) - #MYCXXFLAGS += -fuse-ld=lld +ifeq ($(UNAME_S),Linux) + MYCXXFLAGS += -fuse-ld=lld +endif endif MYCXXFLAGS += $(IDIRS) $(OPTZ) $(DEBUG) $(PSQLCH) -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN) From c0b783d465dfee5e50b5f0127e069a2b09c4efa9 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 20:50:09 +0200 Subject: [PATCH 06/10] fix: ignore ssl pem files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index adcc2774b8..3747260053 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ core #config proxysql.cnf* proxysql.db* +proxysql-*.pem jeprof*heap perf.data* From bf80587d18b447ea24814d8e13653f4f1cf83bc4 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 20:55:04 +0200 Subject: [PATCH 07/10] ci: run only main branch and prs --- .github/workflows/CI-darwin.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-darwin.yml b/.github/workflows/CI-darwin.yml index 67d2daaf73..3f3167d1e4 100644 --- a/.github/workflows/CI-darwin.yml +++ b/.github/workflows/CI-darwin.yml @@ -2,7 +2,16 @@ name: Darwin on: push: - + branches: [ "v2.x" ] + paths-ignore: + - '.github/**' + - '**.md' + pull_request: + branches: [ "v2.x" ] + paths-ignore: + - '.github/**' + - '**.md' + workflow_dispatch: jobs: build: runs-on: macos-latest From 509a02e2e7839189e84db06cfaa501667d6519fe Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 25 Apr 2024 21:14:00 +0200 Subject: [PATCH 08/10] fix: import only machine/endian.h --- lib/sha256crypt.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/sha256crypt.cpp b/lib/sha256crypt.cpp index 2bf82275a0..6a15cb791b 100644 --- a/lib/sha256crypt.cpp +++ b/lib/sha256crypt.cpp @@ -4,10 +4,6 @@ #include #if defined __APPLE__ #include - #include - - // define 64 bit macros - #define htole64(x) OSSwapHostToLittleInt64(x) #else #include #endif From 465afdd9d09ad9fa994025425dbe54539f75d117 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 28 Apr 2024 11:30:15 +0200 Subject: [PATCH 09/10] fix: linux compile --- deps/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/Makefile b/deps/Makefile index 2d61b2ebfc..7e3f123540 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -248,7 +248,12 @@ sqlite3/sqlite3/libsqlite3.so: cd sqlite3/sqlite3 && patch sqlite3.c < ../sqlite3.c-multiplication-overflow.patch cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch cd sqlite3/sqlite3 && ${CC} ${MYCFLAGS} -fPIC -c -o sqlite3.o sqlite3.c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_DLL=1 + +ifeq ($(SYS_KERN),Darwin) cd sqlite3/sqlite3 && ${CC} -shared -Wl,-U,_ERR_error_string -Wl,-U,_RAND_bytes -Wl,-U,_SHA1 -Wl,-U,_sha256_crypt_r -Wl,-U,_ERR_get_error -o libsqlite3.so sqlite3.o +else + cd sqlite3/sqlite3 && ${CC} -shared -o libsqlite3.so sqlite3.o +endif sqlite3: sqlite3/sqlite3/libsqlite3.so From 904a50eb5bd464547fb04aaa1eff7b3bbece6478 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 28 Apr 2024 11:31:12 +0200 Subject: [PATCH 10/10] fix: correctly handle memcpy in sha256crypt Signed-off-by: Soner Sayakci --- lib/sha256crypt.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/sha256crypt.cpp b/lib/sha256crypt.cpp index 6a15cb791b..873caa690b 100644 --- a/lib/sha256crypt.cpp +++ b/lib/sha256crypt.cpp @@ -427,10 +427,13 @@ extern "C" char * sha256_crypt_r (const char *key, const char *salt, char *buffe sha256_finish_ctx (&alt_ctx, temp_result); /* Create byte sequence P. */ - cp = p_bytes = (char *)alloca (key_len); - for (cnt = key_len; cnt >= 32; cnt -= 32) - cp = (char *)memcpy (cp, temp_result, 32); - memcpy (cp, temp_result, cnt); + cp = p_bytes = (char *)alloca(key_len); + char *p_copy = cp; + for (cnt = key_len; cnt >= 32; cnt -= 32) { + memcpy(cp, temp_result, 32); + cp += 32; + } + memcpy(cp, temp_result, cnt); /* Start computation of S byte sequence. */ sha256_init_ctx (&alt_ctx); @@ -443,10 +446,15 @@ extern "C" char * sha256_crypt_r (const char *key, const char *salt, char *buffe sha256_finish_ctx (&alt_ctx, temp_result); /* Create byte sequence S. */ - cp = s_bytes = (char *)alloca (salt_len); - for (cnt = salt_len; cnt >= 32; cnt -= 32) - cp = (char *) memcpy (cp, temp_result, 32); - memcpy (cp, temp_result, cnt); + cp = s_bytes = (char *)alloca(salt_len); + char *cp_end = cp + salt_len; + for (cnt = salt_len; cnt >= 32; cnt -= 32) { + memcpy(cp, temp_result, 32); + cp += 32; + } + if (cnt > 0) { + memcpy(cp, temp_result, cnt); + } /* Repeatedly run the collected hash value through SHA256 to burn CPU cycles. */