Monday, October 31, 2022

devel/cargo: MODCARGO_WANTLIB introduction

Hi,

I intent to add MODCARGO_WANTLIB variable in devel/cargo module to help a bit
for WANTLIB.

Any Rust programs using the Rust std library are linked with: c, pthread and
c++abi/libgcc.

As c++abi/libgcc is a bit particular (only sparc64 link to libgcc statically,
others archs are using c++abi dynamically), it is regular source of questions
regarding WANTLIB and COMPILER_LIBCXX (as c++abi usually comes from here).

It was done this way, as sparc64 is using estdc++ for C++ stuff, and so linking
with c++abi could be problematic when C++ is also involved.


WANTLIB variable isn't modified automatically.

port modification to use MODCARGO_WANTLIB could be done smoothly on port update.
a direct modification requires a bump, as WANTLIB value will change on sparc64.

Comments or OK ?
--
Sebastien Marie

diff /data/semarie/repos/openbsd/ports
commit - ec68a50a503667234d64a20f8fdd92b06f887b74
path + /data/semarie/repos/openbsd/ports
blob - 843c9e9a8bd2f5dd2296eedc636a4c521e30a294
file + devel/cargo/cargo.port.mk
--- devel/cargo/cargo.port.mk
+++ devel/cargo/cargo.port.mk
@@ -23,6 +23,19 @@ MODCARGO_CARGOTOML ?= ${WRKSRC}/Cargo.toml
# Default path for cargo manifest.
MODCARGO_CARGOTOML ?= ${WRKSRC}/Cargo.toml

+# WANTLIB for Rust compiled code
+# it should be kept in sync with lang/rust code
+# - c/pthread : all syscalls
+# - c++abi / libgcc.a : unwind
+MODCARGO_WANTLIB = c pthread
+
+.if "${MARCHINE_ARCH}" != "sparc64"
+MODCARGO_WANTLIB += c++abi
+.else
+# libgcc.a is static
+MODCARGO_WANTLIB +=
+.endif
+
# Define MASTER_SITES_CRATESIO for crates.io
MASTER_SITES_CRATESIO = https://crates.io/api/v1/crates/

No comments:

Post a Comment