Skip to content
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

Cross-crate flamegraph #37

Closed
sharksforarms opened this issue May 10, 2018 · 9 comments
Closed

Cross-crate flamegraph #37

sharksforarms opened this issue May 10, 2018 · 9 comments

Comments

@sharksforarms
Copy link

Hello, I'm trying to use this across multiple crates, is this possible?

@TyOverby
Copy link
Collaborator

Yes; if both crates have the same flame version, then everything should work out.

@sharksforarms
Copy link
Author

sharksforarms commented May 11, 2018

Ok so if I do nightly only without feature-guarding it it works, but with feature guards it doesn't

https://github.com/sharksforarms/testflame

cargo +nightly run --features flame_it

Doesn't seem to get the flame'd functions which aren't in the main crate i.e. myothercrate::hello_world_from_other

@sharksforarms
Copy link
Author

Maybe related?
rust-lang/cargo#4106

@TyOverby
Copy link
Collaborator

Your repo only has a readme file in it. Can you publish again?

@sharksforarms
Copy link
Author

Done

@TyOverby
Copy link
Collaborator

I think that the problem is that this line where you import your subcrate needs to enable it's own feature.

the features that are both named flame_it are not the same between crates.

@sharksforarms
Copy link
Author

sharksforarms commented May 12, 2018

Right, I changed it to this
myothercrate = { path = "./myothercrate", features = ["flame_it"] }

And it works. But now that means that the dependency myothercrate is always compiling with the flame_it feature

@sharksforarms
Copy link
Author

sharksforarms commented May 12, 2018

I think I got it!

Using the / syntax in features = [], funny enough I found out about this syntax in this ticket: rust-lang/cargo#5139

[package]
name = "testflame"
version = "0.1.0"
authors = ["sharks"]

[workspace]
members = [
    "myothercrate"
]

[dependencies]
myothercrate = {path = "./myothercrate", version = "0.1.0"}
flame = {version = "0.2.2", optional = true}
flamer = {version = "^0.2.1", optional = true}

[features]
default = []
flame_it = ["flame", "flamer", "myothercrate/flame_it"]

@TyOverby
Copy link
Collaborator

oh nice! Yeah, I gotta say I've never used features beyond the most trivial.

Looks like I can close this for now; if you run into anything else feel free to re-open or make a new issue!

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