rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
826 stars 128 forks source link

0.8.2 fails to compile with rustc 1.48.0 due to unknown codegen option #190

Closed matthiasbeyer closed 3 years ago

matthiasbeyer commented 3 years ago
   Compiling env_logger v0.8.2                                                                                                                                                                                     
error: unknown codegen option: `embed-bitcode`                                                                                                                                                                     
error: could not compile `env_logger`

$ rustc --version
rustc 1.48.0 (7eac88abb 2020-11-16)

$ cargo --version
cargo 1.48.0 (65cbdd2dc 2020-10-14)
matthiasbeyer commented 3 years ago

Maybe some more information: I do not crosscompile anything. I compile a crate I developed on another system on a centos7 machine. I did a cargo clean run before retrying cargo build but it did not help, same error.

matthiasbeyer commented 3 years ago

Also, I just cloned this repository and it builds fine. But not if I have env_logger as a dependency. Not sure what is happening here...

jplatte commented 3 years ago

env_logger doesn't have a build script or anything else that I can see that could cause this. The string bitcode doesn't appear anywhere inside this repository. I would recommend you ask for help about this on users.rust-lang.org, Discord, reddit or some other place for general help and advice about Rust.

matthiasbeyer commented 3 years ago

Thanks for the fast reply. Apparently the compiler fails to understand an argument it gets ... don't know why tho. Anyways, I'll report to users.rust-lang.org! Thank!

BafDyce commented 3 years ago

Hey @matthiasbeyer

Where you able to solve this issue? I am also hitting this error message, whenever I try to compile anything that has env_logger in its dependencies..

matthiasbeyer commented 3 years ago

Actually I'm not sure what solved that issue for me, sorry. Make sure to use an up-to-date version of the compiler and also make sure you don't mess up different versions in one installation. Happened to me before and is most certainly not the way to go! :laughing:

sunshowers commented 3 years ago

I'm hitting the same issue in a Docker build but with some more interesting output (we have a somewhat custom setup which bypasses the rustup wrapper to cargo but not rustc):

   Compiling env_logger v0.8.2
info: syncing channel updates for '1.41.0-x86_64-unknown-linux-gnu'
info: latest update on 2020-01-30, rust version 1.41.0 (5e1a79984 2020-01-27)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
error: unknown codegen option: `embed-bitcode`

error: could not compile `env_logger`

1.41.0 matches the rust-toolchain checked into env_logger, I suspect excluding this file from the crates.io release will fix it.

sunshowers commented 3 years ago

Yes, assuming you have a stable version of the Rust toolchain installed, this command reproduces the issue:

eval $(rustup which --toolchain stable cargo) build

Honestly this is almost certainly an upstream bug in Cargo -- but excluding rust-toolchain from the release on crates.io should work around it.

jplatte commented 3 years ago

Removing the rust-toolchain from the crates.io release should be easy enough and I don't see a reason not to do that 👍🏼

jplatte commented 3 years ago

Done in eed165155261fcb31f6648485462b9ee3c0ab670. I'll try to do a release in the coming days, feel free to ping me if I still haven't gotten to it next week.

sunshowers commented 3 years ago

@jplatte been a week so gentle ping, thanks! :)

jplatte commented 3 years ago

Release it out.

Vagelis-Prokopiou commented 3 years ago

Latest master (commit 16d982ed979bb9361048fc25a5589ac5e06daf17) also fails to build for me.

Command: cargo build Error: error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the '1.41.0-x86_64-unknown-linux-gnu' toolchain

Command: eval $(rustup which --toolchain stable cargo) build Error: error: unknown codegen option: embed-bitcode

My setup: Cargo: 1.51.0 (43b129a20 2021-03-16) Rustc: 1.51.0 (2fd73fabe 2021-03-23) OS: Debian (Linux debian 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux)

jplatte commented 3 years ago

@Vagelis-Prokopiou that sounds like the cargo but also triggers on git dependencies which aren't affected by the previous fix to this issue. I don't really know what to do about that short of removing rust-toolchain.

jplatte commented 3 years ago

Oh, actually you're building directly, right? That's bad if that fails in this way..

Do you have a .cargo/config anywhere that sets embed-bitcode, are you using a lld, a non-linux platform or anything else you think may be relevant? I'd like to find out what triggers this before deleting rust-toolchain as a fix.

And one more thing: Does removing that file even fix the issue?

Vagelis-Prokopiou commented 3 years ago

My platform is Debian Linux (Linux debian 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux); Cargo: 1.51.0 (43b129a20 2021-03-16) Rustc: 1.51.0 (2fd73fabe 2021-03-23)

Commands that lead to failure:

git clone https://github.com/env-logger-rs/env_logger.git;
cd env_logger;
cargo build;

:heavy_check_mark: Deleting the rust-toolchain file, results in successful build.

I have no ~/.cargo/config at all.

I don't know what lld is :-)

mainrs commented 3 years ago

I ran this inside of WSL but couldn't reproduce:

Can you run cargo build -vv &> output.txt and upload the logs to Gist or some other service? The paths in that file will contain your username/home directory path, just a heads up :) This will only be useful if compilation actually starts.

Make sure to delete your target folder before that. Would be nice if you could also share the contents of the target/.rustc_info.json file. Maybe some toolchain versions are just messed up, this will help investigate that case.

Vagelis-Prokopiou commented 3 years ago

The output.txt contains nothing more that the error that I am getting in the terminal.

cat output.txt
error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the '1.41.0-x86_64-unknown-linux-gnu' toolchain

When the errors happens, no target folder is created at all.

The following is the contents of target/.rustc_info.json after the successful build (when deleting the rust-toolchain file):

{
   "rustc_fingerprint":15281189911875476545,
   "outputs":{
      "4476964694761187371":{
         "success":true,
         "status":"",
         "code":0,
         "stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/va/.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",
         "stderr":""
      },
      "1164083562126845933":{
         "success":true,
         "status":"",
         "code":0,
         "stdout":"rustc 1.51.0 (2fd73fabe 2021-03-23)\nbinary: rustc\ncommit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0\ncommit-date: 2021-03-23\nhost: x86_64-unknown-linux-gnu\nrelease: 1.51.0\nLLVM version: 11.0.1\n",
         "stderr":""
      },
      "551384519178316037":{
         "success":false,
         "status":"exit code: 1",
         "code":1,
         "stdout":"",
         "stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"
      }
   },
   "successes":{

   }
}

I am also attaching the output.txt of the successful build.

output.txt

My Debian installation is a stock Debian stable (with all the latest updates). Nothing special.

mainrs commented 3 years ago

Can you also post the target/.rustc_info.json file if you do not delete rust-toolchain? On a side note, I just span up a VM with Debian 10, installed rustup as mentioned on their website and build the project without any problems. My guess would be that some paths are just not correctly setup on your system. Might be worth to uninstall and re-install rustup and all toolchains:

$ rustup self uninstall; curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Vagelis-Prokopiou commented 3 years ago

Hmmm.... :heavy_check_mark: Indeed, uninstalling and re-installing rust fixed the error. The library is build with no errors whatsoever. The only thing I can suppose is that something "broke" during the various rust updates (through rustup update), because apart from the the updates I have not done anything to modify my installation. The initial installation was done through the instructions from the official page (the same as the one you provided).

Thanx for debugging this with me :-)

mainrs commented 3 years ago

No problem, great that it worked out!

sunshowers commented 3 years ago

Out of curiosity do you happen to use vscode and/or the jetbrains Rust plugin?

Vagelis-Prokopiou commented 3 years ago

Out of curiosity do you happen to use vscode and/or the jetbrains Rust plugin?

I use the JetBrains Rust plugin.