Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ jobs:
- name: Build pg_duckdb extension
id: build
working-directory: duckdb
run: ERROR_ON_WARNING=1 make -j8 install
run: |
if [ '${{ matrix.version }}' = REL_17_STABLE ]; then
ERROR_ON_WARNING=1 make -j8 install DUCKDB_BUILD=Static
Comment on lines +118 to +119
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems error-prone to only build one version that way no?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too worried about the static library build of DuckDB working for one PG version, but not for another. I mainly added this CI coverage to make sure we don't accidentally break the static build logic in our makefile completely. So I think running it for just one version is fine. I'll add a code comment explaining that though.

else
ERROR_ON_WARNING=1 make -j8 install
fi


- name: Run make installcheck
id: installcheck
Expand Down
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,27 @@ DUCKDB_BUILD_TYPE=
ifeq ($(DUCKDB_BUILD), Debug)
DUCKDB_BUILD_CXX_FLAGS = -g -O0 -D_GLIBCXX_ASSERTIONS
DUCKDB_BUILD_TYPE = debug
DUCKDB_MAKE_TARGET = debug
else ifeq ($(DUCKDB_BUILD), Static)
DUCKDB_BUILD_CXX_FLAGS =
DUCKDB_BUILD_TYPE = release
DUCKDB_MAKE_TARGET = bundle-library
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static vs dynamic and debug vs release are orthogonal concepts.
Can we have ReleaseStatic instead? (and we'll add DebugStatic if/when need be.
(I don't think it's worth it to rename Release/Debug into ReleaseDynamic/DebugDynamic)

Copy link
Copy Markdown
Collaborator

@JelteF JelteF Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree, but DuckDB its make targets don't. There's no way to build a "debug" static library version currently, because the bundle-library hardcodes the release path. I'll rename it to ReleaseStatic though, because I agree that's clearer.

else
DUCKDB_BUILD_CXX_FLAGS =
DUCKDB_BUILD_TYPE = release
DUCKDB_MAKE_TARGET = release
endif

DUCKDB_LIB = libduckdb$(DLSUFFIX)
FULL_DUCKDB_LIB = third_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src/$(DUCKDB_LIB)
PG_DUCKDB_LINK_FLAGS = -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lstdc++ -llz4
DUCKDB_BUILD_DIR = third_party/duckdb/build/$(DUCKDB_BUILD_TYPE)

ifeq ($(DUCKDB_BUILD), Static)
PG_DUCKDB_LINK_FLAGS += third_party/duckdb/build/release/libduckdb_bundle.a
FULL_DUCKDB_LIB = $(DUCKDB_BUILD_DIR)/$(DUCKDB_LIB)
else
PG_DUCKDB_LINK_FLAGS += -lduckdb
FULL_DUCKDB_LIB = $(DUCKDB_BUILD_DIR)/src/$(DUCKDB_LIB)/libduckdb$(DLSUFFIX)
endif

ERROR_ON_WARNING ?=
ifeq ($(ERROR_ON_WARNING), 1)
Expand All @@ -54,7 +68,7 @@ override PG_CXXFLAGS += -std=c++17 ${DUCKDB_BUILD_CXX_FLAGS} ${COMPILER_FLAGS} -
# changes to the vendored code in one place.
override PG_CFLAGS += -Wno-declaration-after-statement

SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lduckdb -lstdc++ -llz4
SHLIB_LINK += $(PG_DUCKDB_LINK_FLAGS)

include Makefile.global

Expand Down Expand Up @@ -102,10 +116,14 @@ $(FULL_DUCKDB_LIB): .git/modules/third_party/duckdb/HEAD
DISABLE_ASSERTIONS=$(DUCKDB_DISABLE_ASSERTIONS) \
EXTENSION_CONFIGS="../pg_duckdb_extensions.cmake" \
$(MAKE) -C third_party/duckdb \
$(DUCKDB_BUILD_TYPE)
$(DUCKDB_MAKE_TARGET)

ifeq ($(DUCKDB_BUILD), Static)
install-duckdb: $(FULL_DUCKDB_LIB) $(shlib)
else
install-duckdb: $(FULL_DUCKDB_LIB) $(shlib)
$(install_bin) -m 755 $(FULL_DUCKDB_LIB) $(DESTDIR)$(PG_LIB)
endif

clean-duckdb:
rm -rf third_party/duckdb/build
Expand Down
2 changes: 2 additions & 0 deletions docs/compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ To build and install, run:
make install
```

If you want to link `libduckdb` statically, set `DUCKDB_BUILD=Static` when interacting with `make(1)`.

Add `pg_duckdb` to the `shared_preload_libraries` in your `postgresql.conf` file:

```ini
Expand Down