Skip to content

Commit 479afeb

Browse files
committed
experiment: no c++
1 parent aab947d commit 479afeb

25 files changed

Lines changed: 8523 additions & 1855 deletions

.github/workflows/bake.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ jobs:
2929
registry: ghcr.io
3030
username: ${{ github.actor }}
3131
password: ${{ secrets.GITHUB_TOKEN }}
32-
- name: Cache Vendor Build
33-
uses: actions/cache@v4
34-
with:
35-
path: vendor/_build
36-
key: ${{ runner.os }}-vendor-build
3732
- name: Set Bake Variables
3833
run: make bake-vars REGISTRY=ghcr.io/clickhouse PG_VERSIONS=${{ matrix.pgv }} >> $GITHUB_ENV
3934
- name: Build${{ startsWith(github.ref, 'refs/tags') && ' and Push' || '' }}

.github/workflows/clickhouse.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,5 @@ jobs:
3535
- name: Start ClickHouse
3636
env: { CH_RELEASE: "${{ matrix.ch }}" }
3737
run: .github/ubuntu/clickhouse.sh
38-
- name: Cache Dependencies
39-
uses: actions/cache@v5
40-
with:
41-
path: vendor/_build/*
42-
key: vendor-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.git/modules/clickhouse-cpp/refs/heads/master') }}
43-
# Required to prevent clickhouse-cpp from rebuilding because it depends
44-
# on this file in the Makefile. https://github.com/actions/checkout/issues/968
45-
- name: Reset Vendor Timestamp
46-
run: cd vendor/clickhouse-cpp && touch -d $(git log -1 --format="@%ct" CMakeLists.txt) CMakeLists.txt
47-
- name: Test DSO
38+
- name: Test
4839
run: pg-build-test
49-
- name: Clean
50-
run: make clean NO_VENDOR_CLEAN=1
51-
- name: Test Static
52-
run: pg-build-test
53-
env: { CH_BUILD: static }

.github/workflows/postgres.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,5 @@ jobs:
2626
with: { submodules: true }
2727
- name: Start ClickHouse
2828
run: .github/ubuntu/clickhouse.sh
29-
- name: Cache Dependencies
30-
uses: actions/cache@v5
31-
with:
32-
path: vendor/_build/*
33-
key: vendor-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.git/modules/clickhouse-cpp/refs/heads/master') }}
34-
# Required to prevent clickhouse-cpp from rebuilding because it depends
35-
# on this file in the Makefile. https://github.com/actions/checkout/issues/968
36-
- name: Reset Vendor Timestamp
37-
run: cd vendor/clickhouse-cpp && touch -d $(git log -1 --format="@%ct" CMakeLists.txt) CMakeLists.txt
38-
- name: Test DSO
29+
- name: Test
3930
run: pg-build-test
40-
- name: Clean
41-
run: make clean NO_VENDOR_CLEAN=1
42-
- name: Test Static
43-
run: pg-build-test
44-
env: { CH_BUILD: static }

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "clickhouse-cpp"]
2-
path = vendor/clickhouse-cpp
3-
url = https://github.com/ClickHouse/clickhouse-cpp.git

Makefile

Lines changed: 20 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -16,97 +16,37 @@ CURL_CONFIG ?= curl-config
1616
OS ?= $(shell uname -s | tr A-Z a-z)
1717
ARCH = $(shell uname -m)
1818

19-
# Collect all the C++ and C files to compile into MODULE_big.
20-
OBJS = $(subst .cpp,.o, $(wildcard src/*.cpp src/*/*.cpp)) \
21-
$(subst .c,.o, $(wildcard src/*.c src/*/*.c))
22-
23-
# Build static on Darwin by default.
24-
ifndef CH_BUILD
25-
# ifeq ($(OS),darwin)
26-
CH_BUILD = static
27-
# else
28-
# CH_BUILD = dynamic
29-
# endif
30-
endif
19+
# Collect all the C files to compile into MODULE_big.
20+
OBJS = $(subst .c,.o, $(wildcard src/*.c src/*/*.c))
3121

32-
# clickhouse-cpp source and build directories.
33-
CH_CPP_DIR = vendor/clickhouse-cpp
34-
CH_CPP_BUILD_DIR = vendor/_build/$(OS)-$(ARCH)-$(CH_BUILD)-$(shell git submodule status $(CH_CPP_DIR) | awk '{print substr($$1, 0, 7)}')
35-
36-
# List the clickhouse-cpp libraries we require.
37-
CH_CPP_LIB = $(CH_CPP_BUILD_DIR)/clickhouse/libclickhouse-cpp-lib$(DLSUFFIX)
38-
CH_CPP_FLAGS = -D CMAKE_BUILD_TYPE=Release -D WITH_OPENSSL=ON
39-
40-
# Are we statically compiling clickhouse-cpp into the extension or no?
41-
ifeq ($(CH_BUILD), static)
42-
# We'll need all the clickhouse-cpp static libraries.
43-
CH_CPP_LIB = $(CH_CPP_BUILD_DIR)/clickhouse/libclickhouse-cpp-lib.a
44-
SHLIB_LINK = $(CH_CPP_LIB) \
45-
$(CH_CPP_BUILD_DIR)/contrib/cityhash/cityhash/libcityhash.a \
46-
$(CH_CPP_BUILD_DIR)/contrib/absl/absl/libabsl_int128.a \
47-
$(CH_CPP_BUILD_DIR)/contrib/lz4/lz4/liblz4.a \
48-
$(CH_CPP_BUILD_DIR)/contrib/zstd/zstd/libzstdstatic.a
49-
else
50-
# Build and install the shared library.
51-
SHLIB_LINK = -L$(CH_CPP_BUILD_DIR)/clickhouse -lclickhouse-cpp-lib
52-
CH_CPP_FLAGS += -D BUILD_SHARED_LIBS=ON
53-
endif
22+
# clickhouse-c is a header-only single-header library. Override
23+
# CH_C_DIR to point elsewhere when developing against a local checkout.
24+
CH_C_DIR ?= vendor/clickhouse-c
5425

5526
# Add include directories.
56-
PG_CPPFLAGS = -I./src/include -I$(CH_CPP_DIR) -I$(CH_CPP_DIR)/contrib/absl
57-
58-
# Include other libraries compiled into clickhouse-cpp.
59-
PG_LDFLAGS = -lstdc++ -lssl -lcrypto $(shell $(CURL_CONFIG) --libs)
27+
PG_CPPFLAGS = -I./src/include -I$(CH_C_DIR)
6028

61-
# clickhouse-cpp requires C++ v17.
62-
PG_CXXFLAGS = -std=c++17
63-
64-
# Suppress annoying pre-c99 warning and include curl flags.
65-
PG_CFLAGS = -Wno-declaration-after-statement -Werror=type-limits $(shell $(CURL_CONFIG) --cflags)
29+
# Link OpenSSL (for TLS in the binary driver), curl (for the HTTP driver),
30+
# and libuuid (for http_streaming.c's query-id generator).
31+
PG_LDFLAGS = -lssl -lcrypto $(shell $(CURL_CONFIG) --libs)
6632

67-
# We'll need libuuid except on darwin, where it's included in the OS.
33+
# libuuid is provided by the OS on darwin; explicit link elsewhere.
6834
ifneq ($(OS),darwin)
6935
PG_LDFLAGS += -luuid
7036
endif
7137

72-
# Clean up the clickhouse-cpp build directory and generated files.
38+
# Suppress annoying pre-c99 warning and include curl flags.
39+
PG_CFLAGS = -Wno-declaration-after-statement -Werror=type-limits $(shell $(CURL_CONFIG) --cflags)
40+
41+
# Clean up generated files.
7342
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql src/include/version.h compile_commands.json test/schedule $(EXTENSION)-$(DISTVERSION).zip
74-
ifndef NO_VENDOR_CLEAN
75-
EXTRA_CLEAN += $(CH_CPP_BUILD_DIR)
76-
endif
7743

7844
# Import PGXS.
7945
PGXS := $(shell $(PG_CONFIG) --pgxs)
8046
include $(PGXS)
8147

82-
# We'll need the clickhouse-cpp library and rpath so it can be found.
83-
SHLIB_LINK += -Wl,-rpath,$(pkglibdir)/
84-
85-
# PostgreSQL 15 and earlier violate a C++ v17 storage specifier error.
86-
ifeq ($(shell test $(MAJORVERSION) -lt 16; echo $$?),0)
87-
PG_CXXFLAGS += -Wno-register
88-
endif
89-
90-
# Add the flags to the bitcode compiler variables.
91-
COMPILE.cc.bc += $(PG_CPPFLAGS)
92-
COMPILE.cxx.bc += $(PG_CXXFLAGS)
93-
94-
# shlib is the final output product: clickhouse-cpp and all .o dependencies.
95-
$(shlib): $(CH_CPP_LIB) $(OBJS)
96-
97-
# Clone clickhouse-cpp submodule.
98-
$(CH_CPP_DIR)/CMakeLists.txt:
99-
git submodule update --init
100-
101-
# Require the vendored clickhouse-cpp and the version header.
102-
$(OBJS): $(CH_CPP_LIB) src/include/version.h
103-
104-
# Build clickhouse-cpp.
105-
$(CH_CPP_LIB): export CXXFLAGS=-fPIC
106-
$(CH_CPP_LIB): export CFLAGS=-fPIC
107-
$(CH_CPP_LIB): $(CH_CPP_DIR)/CMakeLists.txt # Sync with "Reset Vendor Timestamp" steps in workflows.
108-
cmake -B $(CH_CPP_BUILD_DIR) -S $(CH_CPP_DIR) $(CH_CPP_FLAGS) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
109-
cmake --build $(CH_CPP_BUILD_DIR) --parallel $$(nproc) --target all
48+
# Require the version header.
49+
$(OBJS): src/include/version.h
11050

11151
# Require the versioned C source and SQL script.
11252
all: sql/$(EXTENSION)--$(EXTVERSION).sql
@@ -119,17 +59,6 @@ sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
11959
src/include/version.h: src/include/version.h.in
12060
sed -e 's,__VERSION__,$(DISTVERSION),g' $< > $@
12161

122-
# Configure install/uninstall of the clickhouse-cpp library.
123-
ifneq ($(CH_BUILD), static)
124-
# Copy all dynamic files; use -a to preserve symlinks.
125-
install-ch-cpp: $(CH_CPP_LIB) $(shlib)
126-
cp -a $(CH_CPP_BUILD_DIR)/clickhouse/libclickhouse-cpp-lib*$(DLSUFFIX)* $(DESTDIR)$(pkglibdir)/
127-
uninstall-ch-cpp:
128-
rm -f $(DESTDIR)$(pkglibdir)/libclickhouse-cpp-lib*$(DLSUFFIX)*
129-
install: install-ch-cpp
130-
uninstall: uninstall-ch-cpp
131-
endif
132-
13362
# Build a PGXN distribution bundle.
13463
dist: $(EXTENSION)-$(DISTVERSION).zip
13564

@@ -187,7 +116,7 @@ bake-vars:
187116
@echo "revision=$(REVISION)"
188117
@echo "pg_versions=$(PG_VERSIONS)"
189118

190-
# Format the .c, .h, and .hh files according to the PostgreSQL indentation
119+
# Format the .c and .h files according to the PostgreSQL indentation
191120
# standard. Requires `pg_bsd_indent` to be in the path.
192121
indent: dev/indent.sh
193122
@$<
@@ -199,7 +128,7 @@ lint: .pre-commit-config.yaml
199128

200129
.PHONY: clang-tidy # Run clang-tidy static analysis (requires compile_commands.json)
201130
clang-tidy: compile_commands.json
202-
clang-tidy -p . $(wildcard src/*.c src/*.cpp)
131+
clang-tidy -p . $(wildcard src/*.c)
203132

204133
## .git/hooks/pre-commit: Install the pre-commit hook
205134
.git/hooks/pre-commit:
@@ -216,8 +145,8 @@ lsp: compile_commands.json
216145

217146
# Requires https://github.com/rizsotto/Bear.
218147
compile_commands.json:
219-
$(MAKE) clean -j $$(nproc) NO_VENDOR_CLEAN=$(NO_VENDOR_CLEAN)
220-
bear -- $(MAKE) all -j $$(nproc) NO_VENDOR_CLEAN=$(NO_VENDOR_CLEAN)
148+
$(MAKE) clean -j $$(nproc)
149+
bear -- $(MAKE) all -j $$(nproc)
221150

222151
# ClickHouse Docker Containers
223152
start-containers: dev/Makefile dev/docker-compose.yml

dev/indent.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ for fn in src/**/*.h* src/**/*.h.in src/*.c; do
77
pg_bsd_indent -bad -bap -bbb -bc -bl -cli1 -cp33 -cdb -nce -d0 -di12 -nfc1 -i4 -l79 -lp -lpl -nip -npro -sac -tpg -ts4 "$fn"
88
done
99
rm -f ./*.BAK
10-
11-
clang-format --style=file:.clang-format -i src/binary.cpp

0 commit comments

Comments
 (0)