Skip to content

Nightly regression: downstream artifacts suddenly depend on proc-macro crate's dylib #37893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexbool opened this issue Nov 20, 2016 · 3 comments
Assignees

Comments

@alexbool
Copy link
Contributor

Consider a project:

.
├── Cargo.lock
├── Cargo.toml
├── library
│   ├── Cargo.toml
│   └── src
│       └── lib.rs
└── user
    ├── Cargo.toml
    └── src
        └── lib.rs

./Cargo.toml:

[workspace]
members = ["user", "library"]

library/Cargo.toml:

[package]
name = "library"
version = "0.1.0"
authors = ["Alexander Bulaev <[email protected]>"]

[dependencies]
serde_derive = "*"

library/src/lib.rs:

extern crate serde_derive;

user/Cargo.toml:

[package]
name = "user"
version = "0.1.0"
authors = ["Alexander Bulaev <[email protected]>"]

[lib]
crate-type = ["rlib", "dylib"]

[dependencies]
library = { path = "../library" }
serde_derive = "*"

user/src/lib.rs:

extern crate library;
extern crate serde_derive;

Then:

alexbool@alexbool-osx ~/D/I/r/user> cargo build
   Compiling quote v0.3.5
   Compiling unicode-xid v0.0.3
   Compiling syn v0.10.3
   Compiling serde_codegen_internals v0.11.1
   Compiling serde_codegen v0.8.18
   Compiling serde_derive v0.8.18
   Compiling library v0.1.0 (file:///Users/alexbool/Documents/IdeaProjects/rust-fail/library)
warning: custom derive crates and `#[no_link]` crates have no effect without `#[macro_use]`
 --> /Users/alexbool/Documents/IdeaProjects/rust-fail/library/src/lib.rs:1:1
  |
1 | extern crate serde_derive;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

   Compiling user v0.1.0 (file:///Users/alexbool/Documents/IdeaProjects/rust-fail/user)
    Finished debug [unoptimized + debuginfo] target(s) in 13.74 secs


alexbool@alexbool-osx ~/D/I/r/user> otool -L ../target/debug/libuser.dylib 
../target/debug/libuser.dylib:
	/Users/alexbool/Documents/IdeaProjects/rust-fail/target/debug/deps/libuser.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libstd-1357b93f.dylib (compatibility version 0.0.0, current version 0.0.0)
	/Users/alexbool/Documents/IdeaProjects/rust-fail/target/debug/deps/libserde_derive-7dacf7ca26e124d8.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

Whoa! This artifact depends on libserde_derive-7dacf7ca26e124d8.dylib and libstd-1357b93f.dylib.

If you try staticlib, you get an error:

   Compiling user v0.1.0 (file:///Users/alexbool/Documents/IdeaProjects/rust-fail/user)
error: dependency `serde_derive` not found in rlib format

error: aborting due to previous error

error: Could not compile `user`.

If you try a binary, it compiles but obviously cannot be run:

alexbool@alexbool-osx ~/D/I/r/user> ../target/debug/user 
dyld: Library not loaded: @rpath/libstd-1357b93f.dylib
  Referenced from: /Users/alexbool/Documents/IdeaProjects/rust-fail/user/../target/debug/user
  Reason: image not found
fish: '../target/debug/user' terminated by signal SIGABRT (Abort)

Meta:
macOS Sierra

alexbool@alexbool-osx ~> rustc -vV
rustc 1.15.0-nightly (ac635aa95 2016-11-18)
binary: rustc
commit-hash: ac635aa95ba851898e125b047ad7b8d6a8fecf8e
commit-date: 2016-11-18
host: x86_64-apple-darwin
release: 1.15.0-nightly
LLVM version: 3.9
alexbool@alexbool-osx ~> cargo --version
cargo 0.16.0-nightly (d1bfc01 2016-11-18)

Also reproduces on Windows i686 msvc.

@alexbool alexbool changed the title Nightly regression: symbols from proc-macro crates suddenly leak into downstream artifacts Nightly regression: downstream artifacts suddenly depend on proc-macro crate's dylib Nov 20, 2016
@alexbool
Copy link
Contributor Author

cc @jseyfried

@jseyfried
Copy link
Contributor

jseyfried commented Nov 20, 2016

@alexbool Thanks for the report, fixed in #37895.

As we wait for that to land, you can work around this issue by reordering the extern crates in user/src/lib.rs so that proc-macro crates precede other crates.

@alexbool
Copy link
Contributor Author

@jseyfried thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants