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

Cargo build seems to hang on Arch #380

Closed
dcellucci opened this issue Oct 13, 2022 · 6 comments
Closed

Cargo build seems to hang on Arch #380

dcellucci opened this issue Oct 13, 2022 · 6 comments

Comments

@dcellucci
Copy link

I am building opencv on an Arch VM, and I am having trouble getting the build to complete.
I don't get an error, but the build seems to hang at this point:

[opencv 0.70.0] === Waiting until the binding-generator binary is built...
[opencv 0.70.0]    Compiling libc v0.2.134
[opencv 0.70.0]    Compiling glob v0.3.0
[opencv 0.70.0]    Compiling memchr v2.5.0
[opencv 0.70.0]    Compiling clang-sys v1.4.0
[opencv 0.70.0]    Compiling cfg-if v1.0.0
[opencv 0.70.0]    Compiling libloading v0.7.3
[opencv 0.70.0]    Compiling aho-corasick v0.7.19
[opencv 0.70.0]    Compiling regex-syntax v0.6.27
[opencv 0.70.0]    Compiling regex v1.6.0
[opencv 0.70.0]    Compiling clang v2.0.0
[opencv 0.70.0]    Compiling percent-encoding v2.2.0
[opencv 0.70.0]    Compiling dunce v1.0.2
[opencv 0.70.0]    Compiling once_cell v1.15.0
[opencv 0.70.0]    Compiling maplit v1.0.2
[opencv 0.70.0]    Compiling opencv-binding-generator v0.48.0
[opencv 0.70.0]     Finished release [optimized] target(s) in 1m 18s
Building [=======================>   ] 34/37: opencv(build)

I installed the base packages using

pacman -S clang qt5-base opencv

and I built using

RUST_BACKTRACE=full cargo build -vv 

The full output is located here:
https://gist.github.com/dcellucci/fecbdbdaabc8c68981eef6d3c5b2d436

@twistedfall
Copy link
Owner

That's quite weird, can you please try doing a cargo clean beforehand and if that doesn't help try using the version 0.69.0 of the crate?

@dcellucci
Copy link
Author

I have been running cargo clean each time, no help. Also downgrading to 0.69.0 didn't work.

@dcellucci
Copy link
Author

dcellucci commented Oct 13, 2022

ok after taking a closer look at the build process it seems like it's hanging on this line

let token = job_server.acquire().expect("Can't acquire token from job server");        

the thread is locked until it can acquire a token from the job server, so it appears to freeze. I will look into a solution.

UPDATE:
After reviewing jobserver generation code, I had to manually create a job server instead of relying on from_env(). A manually created jobserver successfully produces tokens and the rest of the build process seems to proceed without issues.

@twistedfall
Copy link
Owner

Thank you for the investigation, that's really helpful! Can you please tell me how exactly you created the jobserver manually?

@dcellucci
Copy link
Author

dcellucci commented Oct 14, 2022

Yes - sorry for not specifying that!

In build.rs, lines 228-238

opencv-rust/build.rs

Lines 228 to 238 in 007de72

fn build_job_server() -> Option<jobserver::Client> {
unsafe { jobserver::Client::from_env() }
.or_else(|| {
let num_jobs = env::var("NUM_JOBS").ok()
.and_then(|jobs| jobs.parse().ok())
.unwrap_or(2)
.max(1);
eprintln!("=== Creating a new job server with num_jobs: {}", num_jobs);
jobserver::Client::new(num_jobs).ok()
})
}

Calling ::from_env() returns a client, but that client always has 0 jobs. Instead creating a new client from scratch seems to work fine. I did this by modifying the function to explicitly call the or_else code block. Not sure if this is a jobserver problem or what.

@twistedfall
Copy link
Owner

This should be fixed in 0.74.1

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