From b2e969bc1cb6c042c07a13a701c9d12ae8a6709e Mon Sep 17 00:00:00 2001 From: semarie Date: Mon, 1 Jan 2024 14:14:49 +0000 Subject: [PATCH] lang/rust: add a module to cope with SYSTEM_VERSION-rust lang/rust module is intented to be only minimal. makes devel/cargo module to use lang/rust module. - makes MODCARGO_WANTLIB re-exports MODRUST_WANTLIB - it changes the WANTLIB to the right value for sparc64, but as SYSTEM_VERSION-rust is bumped, it should be fine adds SYSTEM_VERSION-rust ?= 0 to arch-defines.mk - this way, when lang/rust isn't used, -V 0 is passed (it is a no-op), and else, it is the value defined in lang/rust module. while here, correct few ports to use the right WANTLIB value ok tb@ "I'm happy with it" espie@ (regarding the usage of _SYSTEM_VERSION-rust) --- databases/influxdb/Makefile | 5 ++++- devel/cargo/cargo.port.mk | 12 ++++-------- infrastructure/mk/arch-defines.mk | 6 +++++- lang/rust/rust.port.mk | 29 +++++++++++++++++++++++++++++ mail/stalwart/jmap/Makefile | 2 +- net/synapse/Makefile | 2 +- www/newsboat/Makefile | 2 +- x11/gnome/librsvg/Makefile | 2 +- 8 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 lang/rust/rust.port.mk diff --git a/databases/influxdb/Makefile b/databases/influxdb/Makefile index 4e1ecd9c10a..c100ef82345 100644 --- a/databases/influxdb/Makefile +++ b/databases/influxdb/Makefile @@ -29,9 +29,12 @@ MODCARGO_BUILD = No MODCARGO_INSTALL = No MODCARGO_CARGOTOML = ${WRKDIR}/go/pkg/mod/github.com/influxdata/flux@v0.194.3/libflux/Cargo.toml MODCARGO_TARGET_DIR = ${WRKDIR}/go/pkg/mod/github.com/influxdata/flux@v0.194.3/libflux/target + +.if ${MACHINE_ARCH} != "sparc64" # needed to make sure unwind* symbols are found -MODCARGO_RUSTFLAGS +=-C link-arg=-lc++abi CGO_LDFLAGS=-lc++abi +.endif + MAKE_ENV += ${MODCARGO_ENV} CGO_LDFLAGS=${CGO_LDFLAGS} MAKE_ENV += PKG_CONFIG=${WRKSRC}/scripts/pkg-config.sh .include "crates.inc" diff --git a/devel/cargo/cargo.port.mk b/devel/cargo/cargo.port.mk index 671ffabee88..76490fd0a12 100644 --- a/devel/cargo/cargo.port.mk +++ b/devel/cargo/cargo.port.mk @@ -1,4 +1,4 @@ -CATEGORIES += lang/rust +MODULES += lang/rust # List of static dependencies. The format is cratename-version. # MODCARGO_CRATES will be downloaded from SITES_CRATESIO. @@ -24,8 +24,7 @@ MODCARGO_VENDOR_DIR ?= ${WRKSRC}/modcargo-crates MODCARGO_CARGOTOML ?= ${WRKSRC}/Cargo.toml # WANTLIB for Rust compiled code -# TODO: c++abi shouldn't be present on sparc64 -MODCARGO_WANTLIB = c pthread c++abi +MODCARGO_WANTLIB = ${MODRUST_WANTLIB} CHECK_LIB_DEPENDS_ARGS += -S MODCARGO_WANTLIB="${MODCARGO_WANTLIB}" @@ -268,9 +267,6 @@ MODCARGO_configure += ; # devel/cargo-generate-vendor is mandatory for hooks. BUILD_DEPENDS += devel/cargo-generate-vendor -# using devel/cargo modules implies using lang/rust to build -BUILD_DEPENDS += lang/rust - # Location of cargo binary (default to devel/cargo binary) MODCARGO_CARGO_BIN ?= ${LOCALBASE}/bin/cargo @@ -292,8 +288,8 @@ MODCARGO_ENV += \ CARGO_BUILD_JOBS=${MAKE_JOBS} \ CARGO_TARGET_DIR=${MODCARGO_TARGET_DIR} \ RUST_BACKTRACE=full \ - RUSTC=${LOCALBASE}/bin/rustc \ - RUSTDOC=${LOCALBASE}/bin/rustdoc \ + RUSTC=${MODRUST_RUSTC_BIN} \ + RUSTDOC=${MODRUST_RUSTDOC_BIN} \ RUSTFLAGS="${MODCARGO_RUSTFLAGS}" # Helper to shorten cargo calls. diff --git a/infrastructure/mk/arch-defines.mk b/infrastructure/mk/arch-defines.mk index dacb59716e3..1b0ace89745 100644 --- a/infrastructure/mk/arch-defines.mk +++ b/infrastructure/mk/arch-defines.mk @@ -1,4 +1,4 @@ -# $OpenBSD: arch-defines.mk,v 1.100 2023/11/20 19:20:32 sthen Exp $ +# $OpenBSD: arch-defines.mk,v 1.101 2024/01/01 14:14:49 semarie Exp $ # # ex:ts=4 sw=4 filetype=make: # @@ -105,6 +105,10 @@ _SYSTEM_VERSION-clang = 2 _SYSTEM_VERSION-go = ${_MODGO_SYSTEM_VERSION} .endif +# defined in rust.port.mk; added to version for all rust arches so that +# rust-compiled packages can be updated easily for a new rust compiler/stdlib +_SYSTEM_VERSION-rust ?= 0 + # @version = ${_SYSTEM_VERSION} + ${_SYSTEM_VERSION-${MACHINE_ARCH}} _PKG_ARGS_VERSION += -V ${_SYSTEM_VERSION} -V ${_SYSTEM_VERSION-${MACHINE_ARCH}} .if ${ARCH} != ${MACHINE_ARCH} diff --git a/lang/rust/rust.port.mk b/lang/rust/rust.port.mk new file mode 100644 index 00000000000..29b2859be8d --- /dev/null +++ b/lang/rust/rust.port.mk @@ -0,0 +1,29 @@ +# increment after rust compiler update to trigger updates of +# all compiled rust packages (see arch-defines.mk) +_SYSTEM_VERSION-rust = 1 + +CATEGORIES += lang/rust + +# WANTLIB for Rust compiled code +# it should be kept in sync with lang/rust code +# - c/pthread : all syscalls +# - c++abi / libgcc.a : unwind +MODRUST_WANTLIB += c pthread + +.if "${MACHINE_ARCH}" != "sparc64" +MODRUST_WANTLIB += c++abi +.else +# libgcc.a is static +MODRUST_WANTLIB += +.endif + +CHECK_LIB_DEPENDS_ARGS += -S MODRUST_WANTLIB="${MODRUST_WANTLIB}" + +MODRUST_BUILDDEP ?= Yes +.if ${MODRUST_BUILDDEP:L} == "yes" +BUILD_DEPENDS += lang/rust +.endif + +# Location of rustc/rustdoc binaries +MODRUST_RUSTC_BIN = ${LOCALBASE}/bin/rustc +MODRUST_RUSTDOC_BIN = ${LOCALBASE}/bin/rustdoc diff --git a/mail/stalwart/jmap/Makefile b/mail/stalwart/jmap/Makefile index 5eb4520db22..391d3131228 100644 --- a/mail/stalwart/jmap/Makefile +++ b/mail/stalwart/jmap/Makefile @@ -29,7 +29,7 @@ MAKE_ENV += DEP_BZIP2_INCLUDE=${LOCALBASE}/include LIB_DEPENDS += archivers/zstd \ archivers/bzip2 -WANTLIB += ${COMPILER_LIBCXX} bz2 c m zstd +WANTLIB += ${MODCARGO_WANTLIB} ${COMPILER_LIBCXX} bz2 m zstd post-install: mv ${PREFIX}/bin/export ${PREFIX}/bin/stalwart-export diff --git a/net/synapse/Makefile b/net/synapse/Makefile index 3e00c9939ff..7626eee6d99 100644 --- a/net/synapse/Makefile +++ b/net/synapse/Makefile @@ -17,7 +17,7 @@ PERMIT_PACKAGE = Yes MODULES = devel/cargo \ lang/python -WANTLIB += ${COMPILER_LIBCXX} +WANTLIB += ${MODCARGO_WANTLIB} MODPY_PYBUILD = poetry-core diff --git a/www/newsboat/Makefile b/www/newsboat/Makefile index e49c263539f..d46f93cfb54 100644 --- a/www/newsboat/Makefile +++ b/www/newsboat/Makefile @@ -12,7 +12,7 @@ MAINTAINER = Frederic Cambus # MIT PERMIT_PACKAGE = Yes -WANTLIB += ${COMPILER_LIBCXX} c crypto curl curses iconv intl +WANTLIB += ${COMPILER_LIBCXX} ${MODCARGO_WANTLIB} crypto curl curses iconv intl WANTLIB += json-c m sqlite3 ssl stfl xml2 SITES = https://www.newsboat.org/releases/$V/ diff --git a/x11/gnome/librsvg/Makefile b/x11/gnome/librsvg/Makefile index 04355683ea0..78c1f8645ef 100644 --- a/x11/gnome/librsvg/Makefile +++ b/x11/gnome/librsvg/Makefile @@ -31,7 +31,7 @@ BUILD_DEPENDS= textproc/py-docutils${MODPY_FLAVOR} PKG_ARGS= -Dold=0 -Dstable=1 MAKE_ENV += ${MODCARGO_ENV} MAKE_FLAGS += V=1 -WANTLIB += ${COMPILER_LIBCXX} Xau Xdmcp cairo-gobject jpeg +WANTLIB += ${MODCARGO_WANTLIB} ${COMPILER_LIBCXX} Xau Xdmcp cairo-gobject jpeg .else ### old REVISION= 5