Opened 6 years ago

Closed 6 years ago

#57214 closed defect (fixed)

cargo links with libssh2 but does not declare dependency

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), l2dy (Zero King)
Port: cargo

Description

cargo seems to opportunistically link with libssh2 but does not declare a dependency on it; this caused l2dy's build of mpv on the Mojave buildbot worker to fail at librsvg:

cd ./rust &&						\
	PKG_CONFIG_ALLOW_CROSS=1						\
	PKG_CONFIG='/opt/local/bin/pkg-config'						\
	CARGO_TARGET_DIR=/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_graphics_librsvg/librsvg/work/librsvg-2.42.2/rust/target			\
	cargo build --verbose  --release
dyld: Library not loaded: /opt/local/lib/libssh2.1.dylib
  Referenced from: /opt/local/bin/cargo
  Reason: image not found
/bin/sh: line 1: 20881 Abort trap: 6           PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG='/opt/local/bin/pkg-config' CARGO_TARGET_DIR=/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_graphics_librsvg/librsvg/work/librsvg-2.42.2/rust/target cargo build --verbose --release

I don't know cargo... should we add the libssh2 dependency, or should we make cargo not use libssh2? Whichever we choose, the revision needs to be increased.

Change History (5)

comment:1 Changed 6 years ago by l2dy (Zero King)

https://doc.rust-lang.org/cargo/reference/build-scripts.html

As an example to follow, let’s take a look at one of Cargo’s own dependencies, libgit2. The C library has a number of constraints:

  • It has an optional dependency on OpenSSL on Unix to implement the https transport.
  • It has an optional dependency on libssh2 on all platforms to implement the ssh transport.
  • It is often not installed on all systems by default.
  • It can be built from source using cmake.

comment:2 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

I'm not sure I see what you're trying to point out with that...

comment:3 in reply to:  2 Changed 6 years ago by l2dy (Zero King)

Replying to ryandesign:

I'm not sure I see what you're trying to point out with that...

I'm providing an official reference to the opportunistic linking behavior.

I don't know much about cargo too, so I'd suggest adding libssh2 as dependency.

Last edited 6 years ago by l2dy (Zero King) (previous) (diff)

comment:4 Changed 6 years ago by l2dy (Zero King)

I was thinking of linking cargo to libgit2 (adding libgit2 as a dependency and set LIBGIT2_SYS_USE_PKG_CONFIG). But according to https://github.com/alexcrichton/git2-rs/issues/68, libgit2 frequently broke ABI compatibility.

Last edited 6 years ago by l2dy (Zero King) (previous) (diff)

comment:5 Changed 6 years ago by dbevans (David B. Evans)

Owner: set to dbevans
Resolution: fixed
Status: newclosed

In 42f30581fa112678029260a79a13c08076ed609b/macports-ports (master):

cargo: update dependencies, rebuild

Both cargo and cargo-stage1 link with libssh2. Previously
a dependency on libssh2 was only declared for cargo-stage1.
This allowed cargo to build properly (because of the build
dependency on cargo-stage1) but in situations where the
pre-built cargo archive was being activated by another
port (e.g. librsvg) a build error might occur if the cargo
binary was executed and libssh2 was not otherwise installed and active.

cargo build --verbose --release
dyld: Library not loaded: /opt/local/lib/libssh2.1.dylib
Referenced from: /opt/local/bin/cargo
Reason: image not found

Closes #57214

Note: See TracTickets for help on using tickets.