mirror of https://github.com/sysown/proxysql
Merge pull request #5308 from sysown/v3.0_mac
Support for ProxySQL compilation on macOS (Darwin/Apple Silicon)pull/5348/head
commit
a360dc22ae
@ -0,0 +1,35 @@
|
||||
--- external/zlib/zutil.c.orig 2024-05-22 17:34:00.000000000 +0200
|
||||
+++ external/zlib/zutil.c 2024-05-22 17:34:00.000000000 +0200
|
||||
@@ -132,8 +132,7 @@
|
||||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
-const char * ZEXPORT zError(err)
|
||||
- int err;
|
||||
+const char * ZEXPORT zError(int err)
|
||||
{
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
@@ -304,10 +304,7 @@
|
||||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
-voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
|
||||
- voidpf opaque;
|
||||
- unsigned items;
|
||||
- unsigned size;
|
||||
+voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
|
||||
{
|
||||
(void)opaque;
|
||||
return sizeof(uInt) > 2 ? (voidpf)malloc((long) items * size) :
|
||||
@@ -315,9 +312,7 @@
|
||||
(voidpf)calloc(items, size);
|
||||
}
|
||||
|
||||
-void ZLIB_INTERNAL zcfree(opaque, ptr)
|
||||
- voidpf opaque;
|
||||
- voidpf ptr;
|
||||
+void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
|
||||
{
|
||||
(void)opaque;
|
||||
free(ptr);
|
||||
@ -0,0 +1,13 @@
|
||||
--- external/zlib/zutil.h.orig 2024-05-22 17:34:00.000000000 +0200
|
||||
+++ external/zlib/zutil.h 2024-05-22 17:34:00.000000000 +0200
|
||||
@@ -143,9 +143,7 @@
|
||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||
# include <unix.h> /* for fdopen */
|
||||
# else
|
||||
-# ifndef fdopen
|
||||
-# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||
-# endif
|
||||
+
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@ -0,0 +1,63 @@
|
||||
# Compiling ProxySQL on macOS
|
||||
|
||||
This guide provides step-by-step instructions for compiling ProxySQL from source on macOS (Intel or Apple Silicon) using Homebrew.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Ensure you have [Homebrew](https://brew.sh/) installed.
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
Run the following command to install the required build tools and libraries:
|
||||
|
||||
```bash
|
||||
brew install automake bzip2 cmake make git gpatch gnutls openssl@3 icu4c pkg-config libiconv zlib
|
||||
```
|
||||
|
||||
## Compilation Steps
|
||||
|
||||
To compile ProxySQL, you must set the following environment variables so the build system can locate OpenSSL and other Homebrew-provided libraries.
|
||||
|
||||
### 1. Set Environment Variables
|
||||
|
||||
```bash
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export OPENSSL_ROOT_DIR="/opt/homebrew/opt/openssl@3"
|
||||
```
|
||||
|
||||
### 2. Run the Build
|
||||
|
||||
You can now run the standard build command:
|
||||
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
Or for a debug build:
|
||||
|
||||
```bash
|
||||
make debug
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Linking Issues
|
||||
If the linker fails to find `libssl` or `libcrypto`, ensure that `OPENSSL_ROOT_DIR` and `PKG_CONFIG_PATH` are correctly set to point to your Homebrew OpenSSL installation.
|
||||
|
||||
### Missing ICU Headers
|
||||
The build system is configured to find `icu4c` via Homebrew. If you encounter errors related to ICU, ensure `icu4c` is installed and the Homebrew prefix is correct.
|
||||
|
||||
### Building TAP Tests (Optional)
|
||||
|
||||
If you wish to run the TAP tests, you need to build the test dependencies first:
|
||||
|
||||
```bash
|
||||
export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
|
||||
make build_tap_test_debug
|
||||
```
|
||||
|
||||
This will automatically:
|
||||
1. Build the main ProxySQL debug binary.
|
||||
2. Download and build MariaDB and MySQL connectors (patched for macOS compatibility).
|
||||
3. Build the TAP test framework.
|
||||
@ -0,0 +1,178 @@
|
||||
--- libs/mysql/serialization/archive.h 2024-04-10 08:26:28
|
||||
+++ libs/mysql/serialization/archive.h 2026-01-21 00:07:15
|
||||
@@ -81,14 +81,15 @@
|
||||
/// @note To be implemented in Archive_derived_type
|
||||
template <typename Type>
|
||||
static std::size_t get_size(Type &&arg) {
|
||||
- return Archive_derived_type::template get_size(std::forward<Type>(arg));
|
||||
+ return Archive_derived_type::template get_size<Type>(
|
||||
+ std::forward<Type>(arg));
|
||||
}
|
||||
|
||||
/// @brief Returns archive size - size of data written to the archive
|
||||
/// @return archive size - size of data written to the archive
|
||||
/// @note To be implemented in Archive_derived_type
|
||||
inline std::size_t get_size_written() const {
|
||||
- return Archive_derived_type::template get_size_written();
|
||||
+ return Archive_derived_type::get_size_written();
|
||||
}
|
||||
|
||||
/// @brief Function returns maximum size of the Type
|
||||
--- libs/mysql/serialization/serializer_impl.hpp 2024-04-10 08:26:28
|
||||
+++ libs/mysql/serialization/serializer_impl.hpp 2026-01-21 00:07:15
|
||||
@@ -51,8 +51,8 @@
|
||||
Serializer<Serializer_derived_type, Archive_type>::get_size_field_def(
|
||||
Field_id_type field_id,
|
||||
const Field_definition<Field_type, field_size_defined> &field_definition) {
|
||||
- return Serializer_derived_type::template get_size_field_def(field_id,
|
||||
- field_definition);
|
||||
+ return Serializer_derived_type::template get_size_field_def<
|
||||
+ Field_type, field_size_defined>(field_id, field_definition);
|
||||
}
|
||||
|
||||
template <class Serializer_derived_type, class Archive_type>
|
||||
@@ -61,8 +61,8 @@
|
||||
Serializer<Serializer_derived_type, Archive_type>::get_size_serializable(
|
||||
Field_id_type field_id, const Serializable_concrete_type &serializable,
|
||||
bool skip_id) {
|
||||
- return Serializer_derived_type::template get_size_serializable(
|
||||
- field_id, serializable, skip_id);
|
||||
+ return Serializer_derived_type::template get_size_serializable<
|
||||
+ Serializable_concrete_type>(field_id, serializable, skip_id);
|
||||
}
|
||||
|
||||
template <class Serializer_derived_type, class Archive_type>
|
||||
@@ -83,8 +83,8 @@
|
||||
|
||||
template <class Serializer_derived_type, class Archive_type>
|
||||
template <typename T>
|
||||
-Serializer<Serializer_derived_type, Archive_type>
|
||||
- &Serializer<Serializer_derived_type, Archive_type>::operator>>(T &arg) {
|
||||
+Serializer<Serializer_derived_type, Archive_type> &
|
||||
+Serializer<Serializer_derived_type, Archive_type>::operator>>(T &arg) {
|
||||
Field_id_type field_id = serialization_format_version;
|
||||
// passing 0 as serializable_end_pos
|
||||
decode_serializable(m_level, field_id, 0, arg, false);
|
||||
@@ -101,12 +101,11 @@
|
||||
void Serializer<Serializer_derived_type, Archive_type>::
|
||||
encode_serializable_fields(const Serializable_type &serializable,
|
||||
Level_type level) {
|
||||
- auto process_serializable =
|
||||
- [ this, level ](const auto &field, auto field_id) -> auto {
|
||||
+ auto process_serializable = [this, level](const auto &field,
|
||||
+ auto field_id) -> auto {
|
||||
this->encode_serializable(level, field_id, field, false);
|
||||
};
|
||||
- auto process_field =
|
||||
- [ this, level ](const auto &field, auto field_id) -> auto {
|
||||
+ auto process_field = [this, level](const auto &field, auto field_id) -> auto {
|
||||
this->encode_field(level, field_id, field);
|
||||
++field_id;
|
||||
};
|
||||
@@ -139,13 +138,13 @@
|
||||
decode_serializable_fields(Serializable_type &serializable,
|
||||
Level_type level,
|
||||
std::size_t serializable_end_pos) {
|
||||
- auto process_serializable = [ this, level, serializable_end_pos ](
|
||||
- auto &field, auto field_id) -> auto {
|
||||
+ auto process_serializable = [this, level, serializable_end_pos](
|
||||
+ auto &field, auto field_id) -> auto {
|
||||
this->decode_serializable(level, field_id, serializable_end_pos, field,
|
||||
false);
|
||||
};
|
||||
- auto process_field = [ this, level, serializable_end_pos ](
|
||||
- auto &field, auto field_id) -> auto {
|
||||
+ auto process_field = [this, level, serializable_end_pos](
|
||||
+ auto &field, auto field_id) -> auto {
|
||||
this->decode_field(level, field_id, serializable_end_pos, field);
|
||||
|
||||
++field_id;
|
||||
--- libs/mysql/serialization/serializer_default_impl.hpp 2024-04-10 08:26:28
|
||||
+++ libs/mysql/serialization/serializer_default_impl.hpp 2026-01-21 00:11:38
|
||||
@@ -205,8 +205,8 @@
|
||||
template <class Field_type, Field_size field_size_defined, typename Enabler>
|
||||
void Serializer_default<Archive_concrete_type>::encode_field(
|
||||
const Field_type &field, Serializer_array_tag) {
|
||||
- using value_type = std::remove_reference_t<decltype(
|
||||
- *std::begin(std::declval<Field_type &>()))>;
|
||||
+ using value_type = std::remove_reference_t<decltype(*std::begin(
|
||||
+ std::declval<Field_type &>()))>;
|
||||
for (const auto &internal_field : field) {
|
||||
// we use default size for internal fields (0)
|
||||
encode_field<value_type, 0>(internal_field);
|
||||
@@ -219,8 +219,8 @@
|
||||
template <class Field_type, Field_size field_size_defined, typename Enabler>
|
||||
void Serializer_default<Archive_concrete_type>::decode_field(
|
||||
Field_type &field, Serializer_array_tag) {
|
||||
- using value_type = std::remove_reference_t<decltype(
|
||||
- *std::begin(std::declval<Field_type &>()))>;
|
||||
+ using value_type = std::remove_reference_t<decltype(*std::begin(
|
||||
+ std::declval<Field_type &>()))>;
|
||||
for (auto &internal_field : field) {
|
||||
// we use default size for internal fields (0)
|
||||
decode_field<value_type, 0>(internal_field);
|
||||
@@ -233,7 +233,8 @@
|
||||
template <class Field_type, Field_size field_size_defined, typename Enabler>
|
||||
std::size_t Serializer_default<Archive_concrete_type>::get_field_size(
|
||||
const Field_type &field) {
|
||||
- return Archive_concrete_type::template get_size(
|
||||
+ return Archive_concrete_type::template get_size<
|
||||
+ Field_wrapper<const Field_type, field_size_defined>>(
|
||||
Field_wrapper<const Field_type, field_size_defined>(field));
|
||||
}
|
||||
|
||||
@@ -304,8 +305,8 @@
|
||||
std::size_t Serializer_default<Archive_concrete_type>::get_field_size(
|
||||
const Field_type &field, Serializer_array_tag) {
|
||||
std::size_t field_size = 0;
|
||||
- using value_type = std::remove_reference_t<decltype(
|
||||
- *std::begin(std::declval<Field_type &>()))>;
|
||||
+ using value_type = std::remove_reference_t<decltype(*std::begin(
|
||||
+ std::declval<Field_type &>()))>;
|
||||
for (const auto &internal_field : field) {
|
||||
field_size += get_field_size<value_type, 0>(internal_field);
|
||||
}
|
||||
@@ -397,7 +398,7 @@
|
||||
}
|
||||
};
|
||||
auto func_f = [&last_non_ignorable_field_id](
|
||||
- const auto &field, auto processed_field_id) -> auto {
|
||||
+ const auto &field, auto processed_field_id) -> auto {
|
||||
if (field.run_encode_predicate() && field.is_field_ignorable() == false) {
|
||||
last_non_ignorable_field_id = processed_field_id + 1;
|
||||
}
|
||||
@@ -473,8 +474,8 @@
|
||||
std::size_t calculated_size = 0;
|
||||
bool is_provided = field_definition.run_encode_predicate();
|
||||
if (is_provided) {
|
||||
- auto size_id_type = Archive_concrete_type::template get_size(
|
||||
- create_varlen_field_wrapper(field_id));
|
||||
+ auto size_id_type = Archive_concrete_type::template get_size<
|
||||
+ Field_wrapper<Field_id_type, 0>>(create_varlen_field_wrapper(field_id));
|
||||
calculated_size = get_field_size<Field_type, field_size_defined>(
|
||||
field_definition.get_ref()) +
|
||||
size_id_type;
|
||||
@@ -489,18 +490,19 @@
|
||||
bool skip_id) {
|
||||
std::size_t serializable_overhead_type = 0;
|
||||
if (skip_id == false) {
|
||||
- serializable_overhead_type = Archive_concrete_type::template get_size(
|
||||
- create_varlen_field_wrapper(field_id));
|
||||
+ serializable_overhead_type = Archive_concrete_type::template get_size<
|
||||
+ Field_wrapper<Field_id_type, 0>>(create_varlen_field_wrapper(field_id));
|
||||
}
|
||||
auto serializable_size = serializable.template get_size_internal<Base_type>();
|
||||
- auto serializable_overhead_size = Archive_concrete_type::template get_size(
|
||||
+ auto serializable_overhead_size = Archive_concrete_type::template get_size<
|
||||
+ Field_wrapper<decltype(serializable_size), 0>>(
|
||||
create_varlen_field_wrapper(serializable_size));
|
||||
|
||||
Field_id_type last_non_ignorable_field_id =
|
||||
find_last_non_ignorable_field_id(serializable);
|
||||
|
||||
auto serializable_overhead_last_non_ignorable_field_id =
|
||||
- Archive_concrete_type::template get_size(
|
||||
+ Archive_concrete_type::template get_size<Field_wrapper<Field_id_type, 0>>(
|
||||
create_varlen_field_wrapper(last_non_ignorable_field_id));
|
||||
return serializable_overhead_type + serializable_overhead_size +
|
||||
serializable_overhead_last_non_ignorable_field_id + serializable_size;
|
||||
Loading…
Reference in new issue