Closed
Description
Problem
With #9523 the following use-case does not compile anymore with nightly. It works with current stable.
- A -sys crate links against an external library using
cargo:rustc-link-lib
/cargo:rustc-link-lib-framework
in itsbuild.rs
. The crate is to be consumed by acdylib
crate. To make consumption easy,build.rs
of the -sys crate also prints outcargo:rustc-cdylib-link-arg=-Wl,-rpath,/some/path
. - The
cdylib
crate depends on the -sys crate and thecdylib
is linked in a way that the external library becomes a dependency for the dynamic linker and the rpath is set due to the propagation ofrustc-cdylib-link-arg
from the -sys crate to the finalcdylib
crate.
With stable rust this works as described, with nightly this now produces a build error when compiling the -sys crate due to the use of rustc-cdylib-link-arg
in the non-cdylib -sys crate.
Concrete example:
Building the qttypes crate from https://github.com/woboq/qmetaobject-rs/tree/master/qttypes produces the error that #9523 introduced:
$ cargo +nightly build
Compiling qttypes v0.2.1 (/Users/simon/src/qmetaobject-rs/qttypes)
error: invalid instruction `cargo:rustc-cdylib-link-arg` from build script of `qttypes v0.2.1 (/Users/simon/src/qmetaobject-rs/qttypes)`
The package qttypes v0.2.1 (/Users/simon/src/qmetaobject-rs/qttypes) does not have a cdylib target.
Possible Solution(s)
Allow rustc-cdylib-link-arg
again in non-cdylib crates to avoid breaking their build with the next stable release.
Notes
Output of cargo version
:
cargo 1.54.0-nightly (0cecbd6 2021-06-01)
cargo 1.52.0 (6976741 2021-04-21)