Closed lexi-the-cute closed 8 months ago
Dependency checking can be limited by the depth, but is fundamentally a recursive operation. In practice, recursion depth is typically very low (e.g., ripgrep seems to currently have a dependency depth of at most 7: ripgrep -> ignore -> crossbeam-deque -> crossbeam-epoch -> crossbeam-utils -> cfg-if, a tool that uses rocket will go to at least 8: that tool -> rocket -> rocket-codegen -> rocket_http -> hyper -> tokio -> mio -> libc), so I doubt projects that hit a recursion depth of say 100 actually exist as real examples. Now, we call more than one function per level of dependency recursion, but we should not even come anywhere close to causing issues.
In summary, I am unsure what you are asking/expecting of this crate here? For further investigation, please share at least a minimal reproducible example.
will definitely have to look into creating a minimal reproducible example. in the meantime, i'm currently trying to track why it takes an hour to build my program in release mode and 2 minutes for debug mode. https://github.com/lexi-the-cute/catgirl-engine/blob/main/build.rs
Assuming that the this repository causes issues for you, I cloned it and had a look at it. Since it seems you are restricting build-info to prevent issues, I applied the following patch:
diff --git a/build.rs b/build.rs
index 95c4c40..730621c 100644
--- a/build.rs
+++ b/build.rs
@@ -23,13 +23,7 @@ fn matches_environment_var(key: &str, value: &str) -> bool {
}
fn generate_build_info() {
- let mut depth: DependencyDepth = DependencyDepth::Depth(8);
-
- // Custom environment variable to speed up writing code
- let rust_analyzer: bool = matches_environment_var("RUST_ANALYZER", "true");
- if rust_analyzer {
- depth = DependencyDepth::None;
- }
+ let mut depth: DependencyDepth = DependencyDepth::Full;
build_info_build::build_script().collect_dependencies(depth);
}
and opened the project in VSCode with the rust-analyzer plugin enabled (linux, rustc 1.76.0, rust-analyzer v0.3.1850).
I have no issues.
huh. i guess i may have accidentally solved it during my attempt to speed up the build process after implementing the workaround. lemme see if i can find the commit that was broken. it works fine now for me too
the commit was e288ee843325e960ed08d4114afd39989abd66ed. i first built the project in the terminal and then commented out a log statement line to trigger the rust-analyzer
I can reproduce your issue like that. To see how much of the issue is from rust-analyzer being unreasonable, and how much from build-info having high requirements, I performed a little experiment on the command line.
My default stack size is 8096 kb, which triggers the issue in rust-analyzer while building fine via cargo. I reduced the available stack size to 512 kb at which it still builds fine, so whatever rust-analyzer does, it causes at least a 15x blowup. (At 256 kb, the build fails due to cc
crashing before it ever gets to build-info, so the limit seems to have been applied successfully.)
So, I doubt our level of recursion is the real cause here.
7df0c9ac2fa9559a88eb35b4d4b6989897d11e50 seems to also fix this issue, can you confirm that this works for you as well?
7df0c9a seems to also fix this issue, can you confirm that this works for you as well?
That appears to have solved the issue. Rust Analyzer worked immediately without issue and the build took 2 minutes and 46 seconds. I used the same commit, but modified both build-info-build and build-info to use the commit, 7df0c9ac2fa9559a88eb35b4d4b6989897d11e50
Build: Finished
releaseprofile [optimized] target(s) in 2m 46s
When rust-analyzer runs, it runs some cargo commands. I implemented a custom environment variable to detect when rust-analyzer is running.
When it runs the dependency check, it causes rust-analyzer's workers to overflow the stack and grinds the computer to a halt. My computer is a decent computer, so that was a shock.
I'm trying to collect dependencies to comply with attribution licenses, so i just selectively disable it depending on if it's a build or just the analyzer running stuff like
cargo check
.This issue mainly is to ask to implement the dependency fetching in a non-recursive way to prevent overflowing the stack. I'll have to see if I can get a default check implemented for rust-analyzer so the check will work regardless of environment setup