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 clang compilation for tests dep 'cppdotenv' #4468

Merged
merged 19 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

GIT_VERSION ?= $(shell git describe --long --abbrev=7)
ifndef GIT_VERSION
$(error GIT_VERSION is not set)
$(error GIT_VERSION is not set)
endif

### NOTES:
Expand Down Expand Up @@ -47,7 +47,7 @@ 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')
LEGACY_BUILD := 1
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
$(error Compiler must support at least c++11)
endif
endif
STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)
Expand Down
2 changes: 1 addition & 1 deletion deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep
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')
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
$(error Compiler must support at least c++11)
endif
endif
STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: "2.0"
version: "3.0"
services:

####################################################################################################
####################################################################################################
_build:
image: none
network_mode: bridge
privileged: true
environment:
- MAKE
- MAKEOPT
Expand Down
4 changes: 2 additions & 2 deletions include/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ class btree : public Params::key_compare {
typedef typename node_type::root_fields root_fields;
typedef typename Params::is_key_compare_to is_key_compare_to;

friend class btree_internal_locate_plain_compare;
friend class btree_internal_locate_compare_to;
friend struct btree_internal_locate_plain_compare;
friend struct btree_internal_locate_compare_to;
typedef typename if_<
is_key_compare_to::value,
btree_internal_locate_compare_to,
Expand Down
8 changes: 4 additions & 4 deletions include/gen_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ class PtrSizeArray {
}
};

typedef struct {
void* data = nullptr;
size_t len = 0;
struct buffer_t {
void * data = nullptr;
size_t len = 0;
size_t capacity = 0;
} buffer_t;
};

class FixedSizeQueue : public std::queue<buffer_t> {
private:
Expand Down
5 changes: 2 additions & 3 deletions lib/ClickHouse_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,8 @@ void ClickHouse_Server_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t
}

if (
(
(query_no_space_length > 40) &&
strncasecmp("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC",query_no_space,strlen("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC") == 0))
(query_no_space_length > 40) &&
(strncasecmp("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC", query_no_space, strlen("SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SC")) == 0)
) {
l_free(query_length,query);
query=l_strdup("SELECT 'utf8_general_ci' AS DEFAULT_COLLATION_NAME");
Expand Down
12 changes: 8 additions & 4 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

GIT_VERSION ?= $(shell git describe --long --abbrev=7)
ifndef GIT_VERSION
$(error GIT_VERSION is not set)
$(error GIT_VERSION is not set)
endif

DEPS_PATH := ../deps
Expand Down Expand Up @@ -77,6 +77,10 @@ ifeq ($(WITHASAN),1)
WASAN := -fsanitize=address
# Force the disable of JEMALLOC, since ASAN isn't compatible.
export NOJEMALLOC=1
# workaroud ASAN limitation ASLR > 28bits
# https://github.com/google/sanitizers/issues/1716
# sudo sysctl vm.mmap_rnd_bits=28
$(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.)
endif

NOJEM :=
Expand All @@ -95,7 +99,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep
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')
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
$(error Compiler must support at least c++11)
endif
endif
STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)
Expand All @@ -122,8 +126,8 @@ default: libproxysql.a
.PHONY: default

_OBJ_CXX := ProxySQL_GloVars.oo network.oo debug.oo configfile.oo Query_Cache.oo SpookyV2.oo MySQL_Authentication.oo gen_utils.oo sqlite3db.oo mysql_connection.oo MySQL_HostGroups_Manager.oo mysql_data_stream.oo MySQL_Thread.oo MySQL_Session.oo MySQL_Protocol.oo mysql_backend.oo Query_Processor.oo ProxySQL_Admin.oo ProxySQL_Config.oo ProxySQL_Restapi.oo MySQL_Monitor.oo MySQL_Logger.oo thread.oo MySQL_PreparedStatement.oo ProxySQL_Cluster.oo ClickHouse_Authentication.oo ClickHouse_Server.oo ProxySQL_Statistics.oo Chart_bundle_js.oo ProxySQL_HTTP_Server.oo ProxySQL_RESTAPI_Server.oo font-awesome.min.css.oo main-bundle.min.css.oo set_parser.oo MySQL_Variables.oo c_tokenizer.oo proxysql_utils.oo proxysql_coredump.oo proxysql_sslkeylog.oo \
sha256crypt.oo \
proxysql_find_charset.oo ProxySQL_Poll.oo
sha256crypt.oo \
proxysql_find_charset.oo ProxySQL_Poll.oo
OBJ_CXX := $(patsubst %,$(ODIR)/%,$(_OBJ_CXX))
HEADERS := ../include/*.h ../include/*.hpp

Expand Down
2 changes: 1 addition & 1 deletion lib/MySQL_HostGroups_Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ bool MySQL_HostGroups_Manager::commit(

if (atoi(r->fields[4])!=atoi(r->fields[14])) {
if (GloMTH->variables.hostgroup_manager_verbose)
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Changing weight for server %d:%s:%d (%s:%d) from %d (%d) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[4]) , mysrvc->weight , atoi(r->fields[14]));
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Changing weight for server %d:%s:%d (%s:%d) from %d (%ld) to %d\n" , mysrvc->myhgc->hid , mysrvc->address, mysrvc->port, r->fields[1], atoi(r->fields[2]), atoi(r->fields[4]) , mysrvc->weight , atoi(r->fields[14]));
mysrvc->weight=atoi(r->fields[14]);
}
if (atoi(r->fields[5])!=atoi(r->fields[15])) {
Expand Down
12 changes: 6 additions & 6 deletions lib/ProxySQL_Admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4370,18 +4370,18 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {
}
if (GloMTH->variables.ssl_p2s_ca == NULL &&
GloMTH->variables.ssl_p2s_capath == NULL) {
SPA->send_MySQL_ERR(&sess->client_myds->myprot, "'mysql-ssl_p2s_ca' and 'mysql-ssl_p2s_capath' have not been configured");
SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"'mysql-ssl_p2s_ca' and 'mysql-ssl_p2s_capath' have not been configured");
break;
}
char msg[256];
uint64_t duration = 0ULL;
if (SPA->ProxySQL_Test___CA_Certificate_Load_And_Verify(&duration, test_arg1, GloMTH->variables.ssl_p2s_ca,
GloMTH->variables.ssl_p2s_capath)) {
sprintf(msg, "Took %llums in loading and verifying CA Certificate for %d times\n", duration, test_arg1);
sprintf(msg, "Took %lums in loading and verifying CA Certificate for %d times\n", duration, test_arg1);
SPA->send_MySQL_OK(&sess->client_myds->myprot, msg);
}
else {
SPA->send_MySQL_ERR(&sess->client_myds->myprot, "Unable to verify CA Certificate");
SPA->send_MySQL_ERR(&sess->client_myds->myprot, (char *)"Unable to verify CA Certificate");
}
}
break;
Expand Down Expand Up @@ -9745,13 +9745,13 @@ void ProxySQL_Admin::stats___memory_metrics() {
uint64_t prep_stmt_backend_mem_usage;
GloMyStmt->get_memory_usage(prep_stmt_metadata_mem_usage, prep_stmt_backend_mem_usage);
vn = (char*)"prepare_statement_metadata_memory";
sprintf(bu, "%llu", prep_stmt_metadata_mem_usage);
sprintf(bu, "%lu", prep_stmt_metadata_mem_usage);
query=(char*)malloc(strlen(a)+strlen(vn)+strlen(bu)+16);
sprintf(query, a, vn, bu);
statsdb->execute(query);
free(query);
vn = (char*)"prepare_statement_backend_memory";
sprintf(bu, "%llu", prep_stmt_backend_mem_usage);
sprintf(bu, "%lu", prep_stmt_backend_mem_usage);
query=(char*)malloc(strlen(a)+strlen(vn)+strlen(bu)+16);
sprintf(query, a, vn, bu);
statsdb->execute(query);
Expand Down Expand Up @@ -15049,7 +15049,7 @@ bool ProxySQL_Admin::ProxySQL_Test___CA_Certificate_Load_And_Verify(uint64_t* du
uint64_t t2 = monotonic_time();
SSL_CTX_free(ctx);
*duration = ((t2/1000) - (t1/1000));
proxy_info("Duration: %llums\n", *duration);
proxy_info("Duration: %lums\n", *duration);
return true;
}
#endif //DEBUG
10 changes: 5 additions & 5 deletions lib/ProxySQL_GloVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ ProxySQL_GlobalVariables::ProxySQL_GlobalVariables() :
global.gr_bootstrap_ssl_key = nullptr;
global.gr_bootstrap_ssl_mode = nullptr;
global.ssl_keylog_enabled = false;
opt=new ez::ezOptionParser();
opt->overview="High Performance Advanced Proxy for MySQL";
opt->syntax="proxysql [OPTIONS]";
opt = new ez::ezOptionParser();
opt->overview = "High Performance Advanced Proxy for MySQL";
opt->syntax = "proxysql [OPTIONS]";
std::string s = "\n\nProxySQL " ;
const char *build_year = __DATE__ + 7;
const char *build_year = &__DATE__[7];
s = s + "rev. " + PROXYSQL_VERSION + " -- " + __TIMESTAMP__ + "\nCopyright (C) 2013-" + string(build_year) + " ProxySQL LLC\nThis program is free and without warranty\n";
opt->footer =s.c_str();
opt->footer = s.c_str();

opt->add((const char *)"",0,0,0,(const char *)"Display usage instructions.",(const char *)"-h",(const char *)"-help",(const char *)"--help",(const char *)"--usage");
opt->add((const char *)"",0,0,0,(const char *)"Print version",(const char *)"-V",(const char *)"--version");
Expand Down
8 changes: 6 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

GIT_VERSION ?= $(shell git describe --long --abbrev=7)
ifndef GIT_VERSION
$(error GIT_VERSION is not set)
$(error GIT_VERSION is not set)
endif

CENTOSVER := Unknown
Expand Down Expand Up @@ -109,7 +109,7 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep
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')
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
$(error Compiler must support at least c++11)
endif
endif
STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)
Expand Down Expand Up @@ -140,6 +140,10 @@ ifeq ($(WITHASAN),1)
WASAN := -fsanitize=address
# Force the disable of JEMALLOC, since ASAN isn't compatible.
export NOJEMALLOC=1
# workaroud ASAN limitation ASLR > 28bits
# https://github.com/google/sanitizers/issues/1716
# sudo sysctl vm.mmap_rnd_bits=28
$(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.)
endif
ifeq ($(TEST_WITHASAN),1)
WASAN += -DTEST_WITHASAN
Expand Down
20 changes: 14 additions & 6 deletions test/tap/tap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

GIT_VERSION ?= $(shell git describe --long --abbrev=7)
ifndef GIT_VERSION
$(error GIT_VERSION is not set)
$(error GIT_VERSION is not set)
endif


Expand Down Expand Up @@ -42,14 +42,20 @@ CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep
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')
ifneq ($(CPLUSPLUS),201103L)
$(error Compiler must support at least c++11)
$(error Compiler must support at least c++11)
endif
endif
STDCPP := -std=c++$(shell echo $(CPLUSPLUS) | cut -c3-4) -DCXX$(shell echo $(CPLUSPLUS) | cut -c3-4)

WASAN :=
ifeq ($(WITHASAN),1)
WASAN := -fsanitize=address
# Force the disable of JEMALLOC, since ASAN isn't compatible.
export NOJEMALLOC=1
# workaroud ASAN limitation ASLR > 28bits
# https://github.com/google/sanitizers/issues/1716
# sudo sysctl vm.mmap_rnd_bits=28
$(warning ASAN needs ASLR =< 28bits, make sure 'sysctl vm.mmap_rnd_bits=28' is set.)
endif

OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WASAN)
Expand All @@ -70,19 +76,19 @@ debug: libtap.a libtap.so
### helper targets

command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c command_line.cpp $(IDIRS) $(OPT)
$(CXX) -fPIC -c command_line.cpp $(IDIRS) $(OPT)

utils.o: utils.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c utils.cpp $(IDIRS) $(OPT)
$(CXX) -fPIC -c utils.cpp $(IDIRS) $(OPT)

tap.o: tap.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c tap.cpp $(IDIRS) $(OPT)
$(CXX) -fPIC -c tap.cpp $(IDIRS) $(OPT)

libtap.a: tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a
ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o

libtap.so: libtap.a cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so
gcc -shared -o libtap.so -Wl,--whole-archive libtap.a -Wl,--no-whole-archive
$(CXX) -shared -o libtap.so -Wl,--whole-archive libtap.a -Wl,--no-whole-archive


### tap deps targets
Expand All @@ -104,6 +110,7 @@ cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a:
cd cpp-dotenv/static && tar -zxf ../cpp-dotenv-*.tar.gz
cd cpp-dotenv/static/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch
cd cpp-dotenv/static/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch
cd cpp-dotenv/static/cpp-dotenv && patch -p0 < ../../nm_clang_fix.patch
cd cpp-dotenv/static/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/static/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}

Expand All @@ -112,6 +119,7 @@ cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so:
cd cpp-dotenv/dynamic && tar -zxf ../cpp-dotenv-*.tar.gz
cd cpp-dotenv/dynamic/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch
cd cpp-dotenv/dynamic/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch
cd cpp-dotenv/dynamic/cpp-dotenv && patch -p0 < ../../nm_clang_fix.patch
cd cpp-dotenv/dynamic/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_RPATH="../tap:../../tap" -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}

Expand Down
12 changes: 12 additions & 0 deletions test/tap/tap/cpp-dotenv/nm_clang_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git src/dotenv.cpp src/dotenv.cpp
index 89bd3c1..1dcaf5a 100644
--- src/dotenv.cpp
+++ src/dotenv.cpp
@@ -8,7 +8,6 @@


using namespace std;
-using namespace dotenv;


dotenv::dotenv& dotenv::dotenv::load_dotenv(const string& dotenv_path, const bool overwrite, const bool interpolate)
Loading
Loading