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)
This commit is contained in:
semarie 2024-01-01 14:14:49 +00:00
parent 447005de2f
commit b2e969bc1c
8 changed files with 46 additions and 14 deletions

View File

@ -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"

View File

@ -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.

View File

@ -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}

29
lang/rust/rust.port.mk Normal file
View File

@ -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

View File

@ -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

View File

@ -17,7 +17,7 @@ PERMIT_PACKAGE = Yes
MODULES = devel/cargo \
lang/python
WANTLIB += ${COMPILER_LIBCXX}
WANTLIB += ${MODCARGO_WANTLIB}
MODPY_PYBUILD = poetry-core

View File

@ -12,7 +12,7 @@ MAINTAINER = Frederic Cambus <fcambus@openbsd.org>
# 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/

View File

@ -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