mozilla / sccache

Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
Apache License 2.0
5.85k stars 552 forks source link

Error when trying to build a Rust project on OpenBSD #2198

Closed lcheylus closed 5 months ago

lcheylus commented 5 months ago

I'm trying to use sccache to build a Rust project on OpenBSD version 7.5 (release April 2024) on amd64.

Error when trying to build a Rust project with cargo and sccache (local storage):

$ export RUSTC_WRAPPER=sccache
$ cargo build
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `sccache rustc - --crate-name ___ --print=file-names --cfg tokio_unstable --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 2)
  --- stderr
  sccache: error: no current exe available (short)

I was not able to find a similar issue or this error message in code (no current exe available (short)).

Have you some clue to debug this error?

lcheylus commented 5 months ago

Same error on OpenBSD current (amd64) with Rust 1.78.0 and sccache 0.8.0

$ rustc -vV
rustc 1.78.0 (15adfb9cd 2024-04-28) (built from a source tarball)
binary: rustc
commit-hash: 15adfb9cd5b029268e1470a41391d91859b0a1f8
commit-date: 2024-04-28
host: x86_64-unknown-openbsd
release: 1.78.0
LLVM version: 16.0.6

$ sccache -V
sccache 0.8.0

$ cd <my Rust project>
$ export RUSTC_WRAPPER=sccache
$ cargo build -v
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `sccache rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 2)
  --- stderr
  sccache: error: no current exe available (short)
sylvestre commented 5 months ago

Salut Laurent!

This error ringed a bell! I improved the error message when calling current_exe on Linux for this 7 years ago :| https://github.com/rust-lang/rust/commit/1b6a182cf1e400b63ae8692e3183beabe541ea6c

On Linux, it means that chroot isn't correctly set up. (/proc not mounted)

On openbsd, it seems that the libc call is failing: https://github.com/rust-lang/rust/blob/2a2c29aafa50bf6fe53d66b32070eba59f860ac3/library/std/src/sys/pal/unix/os.rs#L385

so, afaik, it isn't a sccache error.

lcheylus commented 5 months ago

Salut Sylvestre :)

Thanks for your infos. Strange error when calling rustc from sccache, I have no issue when I call it directly.

$ rustc -V
rustc 1.78.0 (15adfb9cd 2024-04-28) (built from a source tarball)

$ sccache rustc -V
sccache: error: no current exe available (short)