Index | Thread | Search

From:
Bjorn Ketelaars <bket@openbsd.org>
Subject:
devel/cargo/cargo.port.mk: use pkg-config for libsqlite3-sys
To:
ports@openbsd.org
Cc:
Sebastien Marie <semarie@openbsd.org>
Date:
Mon, 4 May 2026 16:54:06 +0200

Download raw body.

Thread
For whenever the ports tree is unlocked again:

The diff below refines how we handle the libsqlite3-sys crate in
cargo.port.mk.

Currently, we remove the entire sqlite3/ directory within the crate.
However, this directory contains glue code/binding that the crate's
build.rs expects to find, even when linking against a system library.
Deleting the whole tree leads to unnecessary build complications.

Changes:
- Set LIBSQLITE3_SYS_USE_PKG_CONFIG=1 in MODCARGO_ENV to force the crate
  to use the system's sqlite3 via pkg-config.
- Change the cleanup logic to only remove .c and .h files. This ensures
  the bundled C source cannot be used while keeping the directory
  structure and any non-C files intact for the Rust bindings.

This brings libsqlite3-sys in line with how we handle similar crates
like libz-sys or zstd-sys.

Tested on amd64 with several ports relying on libsqlite3-sys.

Comments / OK (when ports tree is unlocked)?


diff --git cargo.port.mk cargo.port.mk
index bea935b258d..0d63b67e6cd 100644
--- cargo.port.mk
+++ cargo.port.mk
@@ -135,9 +135,10 @@ MODCARGO_post-extract += \
 	rm -f -- ${MODCARGO_VENDOR_DIR}/${_cratename}-${_cratever}/libsodium-*.tar.gz ;
 
 .    elif "${_cratename}" == "libsqlite3-sys"
+MODCARGO_ENV +=	LIBSQLITE3_SYS_USE_PKG_CONFIG=1
 MODCARGO_post-extract += \
 	${ECHO_MSG} "[modcargo] Removing libsrc for ${_cratename}-${_cratever}" ; \
-	rm -rf -- ${MODCARGO_VENDOR_DIR}/${_cratename}-${_cratever}/sqlite3 ;
+	rm -f -- ${MODCARGO_VENDOR_DIR}/${_cratename}-${_cratever}/sqlite3/*.{c,h} ;
 
 .    elif "${_cratename}" == "libssh2-sys"
 MODCARGO_ENV +=	LIBSSH2_SYS_USE_PKG_CONFIG=1