Skip to content

Commit

Permalink
Move to -std=c++17 only
Browse files Browse the repository at this point in the history
This commit also deprecate old clickhouse-cpp 1.0.0
  • Loading branch information
renecannao committed Aug 2, 2023
1 parent c1ef56e commit 73e18cb
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 108 deletions.
44 changes: 22 additions & 22 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ endif


# determine good compiler version for stdc++17
IS_CXX17 := 0
ifeq ($(CXX),clang++)
CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
IS_CXX17 := 1
endif
else
GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
IS_CXX17 := 1
endif
endif
#IS_CXX17 := 0
#ifeq ($(CXX),clang++)
# CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
# IS_CXX17 := 1
#endif
#else
# GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
# IS_CXX17 := 1
#endif
#endif


PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE))
Expand Down Expand Up @@ -191,17 +191,17 @@ lz4: lz4/lz4/lib/liblz4.a

clickhouse-cpp/clickhouse-cpp/clickhouse/libclickhouse-cpp-lib-static.a:
cd clickhouse-cpp && rm -rf clickhouse-cpp-*/ || true
ifeq ($(IS_CXX17), 1)
echo ">>> Clickhouse CXX17"
#ifeq ($(IS_CXX17), 1)
# echo ">>> Clickhouse CXX17"
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
else
echo ">>> Clickhouse CXX11"
cd clickhouse-cpp && ln -fs clickhouse-cpp-1.0.0 clickhouse-cpp
cd clickhouse-cpp && tar -zxf v1.0.0.tar.gz && sync
cd clickhouse-cpp && sed -i -e 's/SET (CMAKE_CXX_STANDARD_REQUIRED ON)//' clickhouse-cpp/cmake/cpp17.cmake
endif
#else
# echo ">>> Clickhouse CXX11"
# cd clickhouse-cpp && ln -fs clickhouse-cpp-1.0.0 clickhouse-cpp
# cd clickhouse-cpp && tar -zxf v1.0.0.tar.gz && sync
# cd clickhouse-cpp && sed -i -e 's/SET (CMAKE_CXX_STANDARD_REQUIRED ON)//' clickhouse-cpp/cmake/cpp17.cmake
#endif
cd clickhouse-cpp/clickhouse-cpp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .
cd clickhouse-cpp/clickhouse-cpp && CC=${CC} CXX=${CXX} ${MAKE}

Expand Down
Binary file removed deps/clickhouse-cpp/v1.0.0.tar.gz
Binary file not shown.
24 changes: 12 additions & 12 deletions include/proxysql_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#define ETIME ETIMEDOUT
#endif

#ifdef CXX17
//#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
template<class...> struct conjunction : std::true_type { };
template<class B1> struct conjunction<B1> : B1 { };
template<class B1, class... Bn>
struct conjunction<B1, Bn...>
: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
#endif // CXX17
//#else
//template<class...> struct conjunction : std::true_type { };
//template<class B1> struct conjunction<B1> : B1 { };
//template<class B1, class... Bn>
//struct conjunction<B1, Bn...>
// : std::conditional<bool(B1::value), conjunction<Bn...>, 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.
Expand All @@ -43,11 +43,11 @@ struct conjunction<B1, Bn...>
*/
template<
typename... Args,
#ifdef CXX17
//#ifdef CXX17
typename std::enable_if<std::conjunction<std::is_trivial<Args>...>::value,int>::type = 0
#else
typename std::enable_if<conjunction<std::is_trivial<Args>...>::value,int>::type = 0
#endif // CXX17
//#else
// typename std::enable_if<conjunction<std::is_trivial<Args>...>::value,int>::type = 0
//#endif // CXX17
>
int string_format(const std::string& str, std::string& result, Args... args) {
int size = snprintf(nullptr, 0, str.c_str(), args...);
Expand Down
4 changes: 0 additions & 4 deletions lib/ClickHouse_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ inline void ClickHouse_to_MySQL(const Block& block) {
is_null = 0;
} else {
auto s_t = bi.Column()->As<ColumnNullable>();
#ifdef CXX17
cc = s_t->Nested()->GetType().GetCode();
#else
cc = s_t->Type()->GetNestedType()->GetCode();
#endif // CXX17
}

if (
Expand Down
45 changes: 23 additions & 22 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,31 @@ endif


# determine good compiler version for stdc++17
IS_CXX17 := 0
ifeq ($(CXX),clang++)
CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
IS_CXX17 := 1
endif
else
GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
IS_CXX17 := 1
endif
endif
#IS_CXX17 := 0
#ifeq ($(CXX),clang++)
# CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
# IS_CXX17 := 1
#endif
#else
# GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
# IS_CXX17 := 1
#endif
#endif


PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE))
PSQLCH=
ifeq ($(PROXYSQLCLICKHOUSE),1)
PSQLCH=-DPROXYSQLCLICKHOUSE
ifeq ($(IS_CXX17),1)
PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17
endif
endif
PSQLCH=-DPROXYSQLCLICKHOUSE
#PSQLCH=
#ifeq ($(PROXYSQLCLICKHOUSE),1)
# PSQLCH=-DPROXYSQLCLICKHOUSE
#ifeq ($(IS_CXX17),1)
# PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17
#endif
#endif


# 'libhttpserver': Add 'ENABLE_EPOLL' by default for all platforms except
Expand All @@ -139,7 +140,7 @@ ENABLE_EPOLL=-DENABLE_EPOLL
endif

MYCFLAGS=$(IDIRS) $(OPTZ) $(DEBUG) -Wall -DGITVERSION=\"$(GIT_VERSION)\" $(NOJEM) $(WGCOV) $(WASAN)
MYCXXFLAGS=-std=c++11 $(MYCFLAGS) $(PSQLCH) $(ENABLE_EPOLL)
MYCXXFLAGS=-std=c++17 $(MYCFLAGS) $(PSQLCH) $(ENABLE_EPOLL)

default: libproxysql.a
.PHONY: default
Expand Down
45 changes: 23 additions & 22 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,31 @@ endif


# determine good compiler version for stdc++17
IS_CXX17 := 0
ifeq ($(CXX),clang++)
CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
IS_CXX17 := 1
endif
else
GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
IS_CXX17 := 1
endif
endif
#IS_CXX17 := 0
#ifeq ($(CXX),clang++)
# CLANG_VERSION := $(shell clang -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# CLANG_MIN_VER := $(shell echo 14.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(CLANG_MIN_VER),$(firstword $(sort $(CLANG_VERSION) $(CLANG_MIN_VER))))
# IS_CXX17 := 1
#endif
#else
# GCC_VERSION := $(shell gcc -dumpfullversion 2>/dev/null || gcc -dumpversion | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
# GCC_MIN_VER := $(shell echo 8.2.0 | tr '.' ' ' | awk '{ printf("%04d.%04d.%04d", $$1, $$2, $$3) }')
#ifeq ($(GCC_MIN_VER),$(firstword $(sort $(GCC_VERSION) $(GCC_MIN_VER))))
# IS_CXX17 := 1
#endif
#endif


PROXYSQLCLICKHOUSE := $(shell echo $(PROXYSQLCLICKHOUSE))
PSQLCH=
ifeq ($(PROXYSQLCLICKHOUSE),1)
PSQLCH=-DPROXYSQLCLICKHOUSE
ifeq ($(IS_CXX17),1)
PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17
endif
endif
PSQLCH=-DPROXYSQLCLICKHOUSE
#PSQLCH=
#ifeq ($(PROXYSQLCLICKHOUSE),1)
# PSQLCH=-DPROXYSQLCLICKHOUSE
#ifeq ($(IS_CXX17),1)
# PSQLCH=-DPROXYSQLCLICKHOUSE -std=c++17 -DCXX17
#endif
#endif


WITHGCOVVAR := $(shell echo $(WITHGCOV))
Expand All @@ -145,7 +146,7 @@ ifeq ($(TEST_WITHASANVAR),1)
WASAN+= -DTEST_WITHASAN
endif

MYCXXFLAGS=-std=c++11
MYCXXFLAGS=-std=c++17
ifeq ($(CXX),clang++)
MYCXXFLAGS+= -fuse-ld=lld
endif
Expand Down
2 changes: 1 addition & 1 deletion test/tap/tap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ debug: OPT = -O0 -DDEBUG -ggdb
debug: libtap.a

libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h cpp-dotenv
g++ -c tap.cpp command_line.cpp utils.cpp -std=c++11 $(INCLUDEDIRS) $(OPT)
g++ -c tap.cpp command_line.cpp utils.cpp -std=c++17 $(INCLUDEDIRS) $(OPT)
ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o $$(find $(DOTENV_DIR)/ -name '*.o')

cpp-dotenv/cpp-dotenv/libcpp_dotenv.a:
Expand Down
Loading

0 comments on commit 73e18cb

Please sign in to comment.