These are chat archives for rust-lang/rust

27th
Feb 2018
Dylan DPC
@Dylan-DPC
Feb 27 2018 06:12
If you depend on a feature from a dependency of a dependency, then that dependency should be your primary dependency @omni-viral
John C F
@johncf
Feb 27 2018 06:22
Hi! I have used Rust a few years back, and it was a very pleasant experience. Today, I have been trying to compile a hello-world program. First I tried nightly, and it didn't complete in 5 minutes, so I gave up, and tried it in stable. It has been 6 minutes now, it still hasn't compiled yet. What is going on? I'm using rustup on ArchLinux updated everything today.
CPU usage has been 100% on one of the cores. I don't get it -- is it trying to compile std library or something?
Antonin Carette
@k0pernicus
Feb 27 2018 06:24
@johncf Are you using your IDE in parallel with cargo ?
John C F
@johncf
Feb 27 2018 06:24
Nope, just cargo run
Not even in release mode
Antonin Carette
@k0pernicus
Feb 27 2018 06:24
That’s weird...
Can you give me your version of rustc and cargo please?
John C F
@johncf
Feb 27 2018 06:25
11:48 % cargo --version
cargo 0.25.0 (8c93e0895 2018-02-01)
john: ~/dev/dictionary (-)(master)
11:57 % rustc --version
rustc 1.24.0 (4d90ac38c 2018-02-12)
Antonin Carette
@k0pernicus
Feb 27 2018 06:26
Also, what is the current output of cargo please when you are running cargo run?
John C F
@johncf
Feb 27 2018 06:26
Just Compiling ... v0.1.0 ... the usual
Antonin Carette
@k0pernicus
Feb 27 2018 06:27
Ok, so cargo is not waiting for something...
John C F
@johncf
Feb 27 2018 06:27
No, it downloaded the index and all fine...
Antonin Carette
@k0pernicus
Feb 27 2018 06:28
Ok, sometimes you can have this problem: « Blocking waiting for file lock on build directory », which is related to your dev environment...
John C F
@johncf
Feb 27 2018 06:28

Actually I first tried an empty crate with nom dependency, and it reached till here:

11:43 % cargo run                                                                           !
   Compiling libc v0.2.36
   Compiling memchr v2.0.1
   Compiling nom v4.0.0-beta1
   Compiling dictionary v0.1.0 (file:///home/john/dev/dictionary)

That's where it got stuck

"dictionary" is the name of my project btw... So that means it has completed compiling all its dependency
And my project is --bin
If it was waiting on a file lock, the CPU usage would have been low
Antonin Carette
@k0pernicus
Feb 27 2018 06:30
Can you try this: cargo new —bin helloworld && cd helloworld && cargo run please ?
John C F
@johncf
Feb 27 2018 06:30
But for me it's max on a core
That's basically, what I tried after it... But I'll try it anyway
Antonin Carette
@k0pernicus
Feb 27 2018 06:32
It took me approximately 4 seconds to build and run this crate...
John C F
@johncf
Feb 27 2018 06:33
Ok, it has been over a minute now... Still compiling
12:03 % cargo new --bin helloworld && cd helloworld && cargo run
     Created binary (application) `helloworld` project
   Compiling helloworld v0.1.0 (file:///home/john/dev/helloworld)
Antonin Carette
@k0pernicus
Feb 27 2018 06:33
Ok - you can abort
John C F
@johncf
Feb 27 2018 06:34
Now, I tried with --lib, and it's the same too...
and cargo test
Antonin Carette
@k0pernicus
Feb 27 2018 06:35
I don’t know if it’s a cargo or rustc problem...
Zakarum
@omni-viral
Feb 27 2018 06:35
@Dylan-DPC wat?
Antonin Carette
@k0pernicus
Feb 27 2018 06:35
Have you tried rustc src/main.rs ?
(just to know if the issue is coming from cargo or the compiler itself)
Actually, I’ve never heard about that issue before… :-/
John C F
@johncf
Feb 27 2018 06:37

@k0pernicus

Have you tried rustc src/main.rs ?

Yes, just tried.. The same

Ok, I'm gonna do a full-system upgrade now.. Let's see if it's due to one of its dependencies..
Antonin Carette
@k0pernicus
Feb 27 2018 06:37
Ok, so I think the issue is not coming from cargo
@johncf You installed rust via rustup ?
Ok - ping me please if you try again
Dylan DPC
@Dylan-DPC
Feb 27 2018 06:47
@omni-viral I might have misread your question. But you want to depend on a dependency of a dependency right?
John C F
@johncf
Feb 27 2018 06:51

@k0pernicus

@johncf You installed rust via rustup ?

Yes, I'll try my distro's rust package next, if system upgrade didn't work out either...

Thanks for the suggestions too...
Antonin Carette
@k0pernicus
Feb 27 2018 06:52
@johncf No problem - I am using rustup on my ArchLinux too, no trouble so far...
John C F
@johncf
Feb 27 2018 07:20
@k0pernicus I tried system upgrade and also distro's package to no avail. I'm able to do cargo build on a lib crate, but not cargo test... Is it some LLVM issue?
John C F
@johncf
Feb 27 2018 07:35
Anyone knows how I can diagnose this?
What was the command to see the build-steps of compiling and time it takes for each?
Denis Lisov
@tanriol
Feb 27 2018 07:39
cargo +nightly rustc -- -Ztime-passes
John C F
@johncf
Feb 27 2018 07:43
Thanks
This is the output of that command. Gets stuck after it... Any idea which step is next? https://gist.github.com/johncf/b8cf63b815de01344e4d76129690ce66
(the preview above is incomplete)
John C F
@johncf
Feb 27 2018 07:49
last line reads time: 0.000; rss: 115MB serialize work products
Denis Lisov
@tanriol
Feb 27 2018 08:07
That's almost all, only linking goes next...
...do you have any leftovers like linker overrides from the old experiments?
Also, does it hang the same way with CARGO_INCREMENTAL=0?
John C F
@johncf
Feb 27 2018 08:34

@tanriol

Also, does it hang the same way with CARGO_INCREMENTAL=0?

It does hang the same way...

...do you have any leftovers like linker overrides from the old experiments?

I don't think so, since I don't think I've ever done something like that...

John C F
@johncf
Feb 27 2018 09:03
Alright this is not a Rust problem. I just tried a hello world program in C, compiled it using gcc hello.c and it hangs too...
I'm not sure where to ask for help, and what info to provide...
John C F
@johncf
Feb 27 2018 09:47
Alright, I figured it out... It was because of some obsolete package called hardening-wrapper that somehow never got removed, and that was overriding default compiler tools...
Antonin Carette
@k0pernicus
Feb 27 2018 10:15
Wow, that’s weird...
Zakarum
@omni-viral
Feb 27 2018 14:28
@Dylan-DPC I have two dependencies A and B. B is optional. A also optionally depends on B.
When A compiled with B enabled - types from A implements traits from B.
I want to enable B in A if B is enabled in my crate. So that I could use implementations of traits from B for types in A
Zakarum
@omni-viral
Feb 27 2018 14:33
To be less abstract. I want to write #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] on the type with field of type smallvec::SmallVec.
smallvec::SmallVec implements Serialize and Deserialize if serde feature is enabled the same way my types will.
François Dubois
@francoisduboisx_twitter
Feb 27 2018 16:09
Dum question, on the rust forum, how paste code and see it as code (not as text) ?
it seems to try to analyse it and see if it is code or not, but doesn't work well
Michal 'vorner' Vaner
@vorner
Feb 27 2018 16:14
@francoisduboisx_twitter If I'm not mistaken, you can place it in between two lines, each with tripple backticks. The leading one can be followed (on the same line) with rust, to hint it at the language.
(this thing will eat it as well if I try to use it here)
François Dubois
@francoisduboisx_twitter
Feb 27 2018 16:27
Thanks
Ingvar Stepanyan
@RReverser
Feb 27 2018 16:58
@vorner ```rust :P
Won't eat if you escape it
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:44
@omni-viral You need to define a feature that would control all serde-related deps (you can't use just "serde" because it will conflict with dependency name), and then define all serde deps as optional = true in Cargo.toml, and then include them with your feature
that sounds a bit vague I guess :D
[dependencies]
serde = { version = "1.0.27", optional = true }
serde_derive = { version = "1.0.27", optional = true }
...

[features]
serialize = [
    "serde",
    "serde_derive",
    ...
]
Zakarum
@omni-viral
Feb 27 2018 17:45
@RReverser looks inconvenient as most crates use implicit feature "serde" to control it
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:45
basically your Cargo.toml will look like this
Zakarum
@omni-viral
Feb 27 2018 17:46
Do it with dedicated feature is easy. But I don't want it :smile:
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:46
You can use feature "serde" if you are just using "serde", but if you also want to use serde_derive you can't use it AFAIK
By default one optional dep == one feature unless you specify own dedicated feature
Zakarum
@omni-viral
Feb 27 2018 17:47
You can use serde_derive thorugh serde like this serde = { version = "1.0", optional = true, features = ["serde_derive"] }
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:48
Oh, they reexport it
Then yeah, you can just use serde feature name directly
Zakarum
@omni-viral
Feb 27 2018 17:49
But how would I enable serde feature for my dependencies?
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:49
Except features = ["derive"] I guess? (that's how it's called in their Cargo.toml)
You mean if you want to pass serde on to crates you're depending on, if it's enabled?
Zakarum
@omni-viral
Feb 27 2018 17:51
Yes
Ingvar Stepanyan
@RReverser
Feb 27 2018 17:52

Well, once again, with custom feature you could use

[features]
serialize = ["crate_name/serde"]

but I'm not sure if you can do it just with optional dependency...

Zakarum
@omni-viral
Feb 27 2018 17:54

As I mentioned before

Do it with dedicated feature is easy. But I don't want it

Ingvar Stepanyan
@RReverser
Feb 27 2018 17:56
I guess the answer is "you can't" then. It seems at this point it's purely about aesthetical choice of feature name, not technical limitation.