rust-lang / git2-rs

libgit2 bindings for Rust
https://docs.rs/git2
Apache License 2.0
1.64k stars 380 forks source link

`libgit2-sys` fails to build with vendored openssl because of misconfigured `cc` parallelism #1026

Closed IGI-111 closed 4 months ago

IGI-111 commented 4 months ago

libgit2-sys enables the parallel feature of cc by default, however when building libgit2-sys with the vendored-openssl feature, this contaminates the cc run of openssl-sys with parallel flags and produces the following error:

 --- stderr
  make: *** read jobs pipe: Resource temporarily unavailable.  Stop.
  make: *** Waiting for unfinished jobs....
  thread 'main' panicked at /cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-300.2.3+3.2.1/src/lib.rs:611:9:

  Error building OpenSSL:
      Command: cd "/target/aarch64-unknown-linux-gnu/release/build/openssl-sys-6a5ed052a12e98be/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "make" "build_libs"
      Exit status: exit status: 2

This is a known issue with building openssl using parallelism: https://github.com/rust-lang/cargo/issues/13476 https://github.com/sfackler/rust-openssl/issues/2179 https://github.com/rust-lang/cc-rs/issues/964

In other words, cc/parallel is mutually exclusive with openssl-sys/vendored when building yet libgit2-sys potentially enables both.

IGI-111 commented 4 months ago

Enabled in https://github.com/rust-lang/git2-rs/commit/92491dbcc12cdcc73194859e6ea68f293a256bb2

NobodyXu commented 4 months ago

Could you try make 4.4.1 please? I've verified that it does fix compilation on my project.

IGI-111 commented 4 months ago

It does indeed work with that version.

I'll close this in favor of your cc PR since it seems to fix the underlying issue.

NobodyXu commented 4 months ago

cc 1.0.87 has released which should fix this