Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build on darwin #4527

Open
wants to merge 10 commits into
base: v2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
shyim marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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
shyim marked this conversation as resolved.
Show resolved Hide resolved
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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -331,4 +326,3 @@ cleanall:
cd cityhash && rm -rf cityhash-*/ || true
cd coredumper && rm -rf coredumper-*/ || true
.PHONY: cleanall

29 changes: 17 additions & 12 deletions deps/curl/configure.patch
Original file line number Diff line number Diff line change
@@ -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
-
18 changes: 9 additions & 9 deletions include/proxysql_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
#define ETIME ETIMEDOUT
#endif

#ifdef CXX17
template<class...> struct conjunction : std::true_type { };
template<class B1> struct std::conjunction<B1> : B1 { };
template<class B1, class... Bn>
struct std::conjunction<B1, Bn...>
: std::conditional<bool(B1::value), std::conjunction<Bn...>, B1>::type {};
#else
// #ifdef CXX17
shyim marked this conversation as resolved.
Show resolved Hide resolved
// template<class...> struct conjunction : std::true_type { };
// template<class B1> struct std::conjunction<B1> : B1 { };
// template<class B1, class... Bn>
// struct std::conjunction<B1, Bn...>
// : std::conditional<bool(B1::value), std::conjunction<Bn...>, B1>::type {};
// #else
template<class...> struct conjunction : std::true_type { };
shyim marked this conversation as resolved.
Show resolved Hide resolved
template<class B1> struct conjunction<B1> : B1 { };
template<class B1, class... Bn>
struct conjunction<B1, Bn...>
struct conjunction<B1, Bn...>
: std::conditional<bool(B1::value), conjunction<Bn...>, 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.
Expand Down
2 changes: 1 addition & 1 deletion lib/ProxySQL_GloVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
shyim marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
15 changes: 12 additions & 3 deletions lib/sha256crypt.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/* SHA256-based Unix crypt implementation.
Released into the Public Domain by Ulrich Drepper <[email protected]>. */

#include <endian.h>
#include <cstring>
#if defined __APPLE__
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>

// define 64 bit macros
#define htole64(x) OSSwapHostToLittleInt64(x)
#else
#include <endian.h>
shyim marked this conversation as resolved.
Show resolved Hide resolved
#endif
#include <errno.h>
#include <limits.h>
#include <stdint.h>
Expand Down Expand Up @@ -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);
shyim marked this conversation as resolved.
Show resolved Hide resolved
cp = (char *)memcpy (cp, temp_result, 32);
memcpy (cp, temp_result, cnt);

/* Start computation of S byte sequence. */
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)