Weird `-Zshare-generics` flag on project

The project is here in which stable Rust emits a nightly compilation flag -Zshare-generics from nowhere.
This happens on Ubuntu, but not on Windows (though the stable Rust on Windows is a bit older, it's v1.78.0). sccache is used on both tested platforms.

$ rustup default stable
  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.78.0 (9b00956e5 2024-04-29)

$ cargo c
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/root/.cargo/bin/sccache 
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -
 --crate-name ___ --print=file-names -Clink-arg=-fuse-ld=lld
 -Zshare-generics=y --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: 1)
  --- stderr
  error: the option `Z` is only accepted on the nightly compiler

  help: consider switching to a nightly toolchain: `rustup default nightly`

  note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>

  note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>

  error: 1 nightly option were parsed

Doesn't happen for me on a fresh checkout.

Caused by:
  process didn't exit successfully: `/root/.cargo/bin/sccache 

It looks like you're using sccache.
What's your config? Have you tried without sccache? Or cleaned out the sccache cache before a build?

Thanks for trying it out. I found the problem. There was an unexpected .cargo/config.toml in project.

$ bat .cargo/config.toml
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: .cargo/config.toml
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [build]
   2   │ rustc-wrapper = '/root/.cargo/bin/sccache'
   3   │ [target.x86_64-unknown-linux-gnu]
   4   │ rustflags = [
   5   │     '-Clink-arg=-fuse-ld=lld',
   6   │     '-Zshare-generics=y',
   7   │ ]
   8   │ linker = '/usr/bin/clang'
   9   │
  10   │ [target.x86_64-pc-windows-msvc]
  11   │ rustflags = ['-Zshare-generics=y']
  12   │ linker = 'rust-lld.exe'
  13   │
  14   │ [target.x86_64-apple-darwin]
  15   │ rustflags = [
  16   │     '-C',
  17   │     'link-arg=-fuse-ld=/usr/local/bin/zld',
  18   │     '-Zshare-generics=y',
  19   │     '-Csplit-debuginfo=unpacked',
  20   │ ]
  21   │ [profile.dev]
  22   │ opt-level = 0
  23   │ debug = 2
  24   │ incremental = true
  25   │ codegen-units = 512
  26   │
  27   │ [profile.release]
  28   │ opt-level = 3
  29   │ debug = 0
  30   │ incremental = false
  31   │ codegen-units = 256
  32   │ split-debuginfo = '...'
───────┴────────────────────────

I think it was created by some tool, not by myself, two years ago. I never knew Zshare-generics=y until now.

And .cargo dir is in .gitignore, so a repo clone on Windows doesn't contain it.

I removed the config, and it works now.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.