Error: unknown codegen option: `embed-bitcode`

I am currently trying to compile a crate on a centos7 machine and I get the following error:

error: unknown codegen option: `embed-bitcode`

error: could not compile `env_logger`

(My first report: here, but it has nothing to do with the env_logger crate)

Apparently, the rust compiler gets an argument --embed-bitcode=no which it does not understand. This happens with rustc 1.48.0 and 1.47.0. I am not cross-compiling anything.

Can someone help me with this issue?

1 Like

Is it possible that you have multiple versions of Rust installed? or Cargo newer than rustc? This option requires Rust 1.45 or later.

which -a reports three rust binaries, but they all have the exact same --version output.

$ rustc --version && cargo --version
rustc 1.48.0 (7eac88abb 2020-11-16)
cargo 1.48.0 (65cbdd2dc 2020-10-14)

What is the output of cat target/.rustc_info.json? This should show the exact rustc version that cargo is using alongside other things.

$ \cat target/.rustc_info.json | json_pp
{
   "outputs" : {
      "1164083562126845933" : [
         "rustc 1.48.0 (7eac88abb 2020-11-16)\nbinary: rustc\ncommit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4\ncommit-date: 2020-11-16\nhost: x86_64-unknown-linux-gnu\nrelease: 1.48.0\nLLVM version: 11.0\n",
         ""
      ],
      "4476964694761187371" : [
         "___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/beyer/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n", 
         ""
      ]
   },
   "successes" : {},
   "rustc_fingerprint" : 9251463643064323083
}

That doesn't look like a version mix-up. Strange.

Strangely enough, the issue vanished and I was not able to reproduce it.
Either way, thank you!

I'm getting the xact same error while trying to cross compile FIrefox on Ubuntu for Solaris SPARC. The error pops up while executing mach build but I can reproduce it by executing that one command directly from the command line:
michele@michele-VirtualBox:/usr/sparcv9-solaris/solaris/cross/bin$ /home/michele/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -C opt-level=2 -C debuginfo=2 --cap-lints warn -C -Cembed-bitcode=yes -C codegen-units=1 --target sparcv9-sun-solaris --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg
error: unknown codegen option: -Cembed-bitcode
michele@michele-VirtualBox:~/mozilla-unified$ rustc --version && cargo --version
rustc 1.49.0 (e1884a8e3 2020-12-29)
cargo 1.49.0 (d00d64df9 2020-12-05)
I note that if I remove the "-C" immediately before "-Cembed-bitcode" the command works. What does this -C do? Any ideas?