librespot-org / librespot

Open Source Spotify client library
MIT License
4.76k stars 589 forks source link

Error on cargo build --release #1346

Open fivebanger opened 6 hours ago

fivebanger commented 6 hours ago

I'm getting a build error on cargo build --release, running Linux Mint 20.3 (based on Ubuntu 20.04 LTS, still supported). What I did so far:

sudo apt-get update
sudo apt-get upgrade

$ rustup update stable
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.81.0 (eeb90cda1 2024-09-04)

info: checking for self-update

$ rustc --version
rustc 1.81.0 (eeb90cda1 2024-09-04)
$ cargo --version
cargo 1.81.0 (2dbb1af80 2024-08-20)

$ git clone https://github.com/librespot-org/librespot

Building result in following error:

cargo build --release

...

error: failed to run custom build command for `aws-lc-sys v0.21.1`

Caused by:
  process didn't exit successfully: `/home/martin/librespot/librespot-dev/librespot/target/release/build/aws-lc-sys-7936ae7f1dab2471/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_PREFIX
  cargo:rerun-if-env-changed=AWS_LC_SYS_INTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_EXTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_ASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_CFLAGS
  cargo:rerun-if-env-changed=AWS_LC_SYS_PREBUILT_NASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_C_STD
  cargo:rustc-cfg=x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=AWS_LC_SYS_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  default_for Target: 'x86_64-unknown-linux-gnu'
  cargo:rerun-if-env-changed=CARGO_FEATURE_SSL
  default_for Target: 'x86_64-unknown-linux-gnu'
  cargo:rerun-if-env-changed=CARGO_FEATURE_SSL
  cargo:root=/home/martin/librespot/librespot-dev/librespot/target/release/build/aws-lc-sys-a9f24552134098bb/out
  default_for Target: 'x86_64-unknown-linux-gnu'
  HOST = Some(x86_64-unknown-linux-gnu)
  TARGET = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  OUT_DIR = Some(/home/martin/librespot/librespot-dev/librespot/target/release/build/aws-lc-sys-a9f24552134098bb/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OPT_LEVEL = Some(3)
  TARGET = Some(x86_64-unknown-linux-gnu)
  OUT_DIR = Some(/home/martin/librespot/librespot-dev/librespot/target/release/build/aws-lc-sys-a9f24552134098bb/out)
  HOST = Some(x86_64-unknown-linux-gnu)
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None

  --- stderr
  thread 'main' panicked at /home/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/cc_builder.rs:277:13:
  ### COMPILER BUG DETECTED ###
  Your compiler (cc) is not supported due to a memcmp related bug reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189. We strongly recommend against using this compiler. 
  EXECUTED: true
  ERROR: 
  OUTPUT: 

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I'm not facing any build issues for a version older than 3rd of Sept. Next update for me was 7th of Sept. Since 7th of Sept. I cannot build HEAD of dev anymore. Some commit between 3rd and 7th seems to cause this issue.

Any help welcome.

fivebanger commented 6 hours ago

It seems that my used gcc version is to old.

gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0

I found some advice to use a newer version of gcc, so I did:

sudo apt remove gcc
sudo apt install gcc-10

Running cargo build leads now to error: linkerccnot found. The suggested solution to this issue was to run

sudo apt install build-essential

like also mentioned in the COMPILING.md here.

Now I end up with the original error (see first post). I can see that build-essentials has installed gcc-9 again.

I tried to just remove gcc-9, also does not work. The error on cargo build is now:

  --- stderr
  thread 'main' panicked at /home/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/builder/cc_builder.rs:258:9:
  COMPILER: "cc"ARGS: ["-O3", "-ffunction-sections", "-fdata-sections", "-fPIC", "-m64", "-Wall", "-Wextra", "/home/martin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.21.1/aws-lc/tests/compiler_features_tests/memcmp_invalid_stripped_check.c", "-Wno-unused-parameter", "-o", "/home/martin/librespot/librespot-dev/librespot/target/release/build/aws-lc-sys-a9f24552134098bb/out/memcmp_invalid_stripped_check"]EXECUTED: falseERROR: OUTPUT: Failed to compile memcmp_invalid_stripped_check
fivebanger commented 5 hours ago

What has fixed the issue for me:

sudo apt remove gcc-9
sudo apt install gcc-10

I missed cargo clean before starting a new build which seems to be important. Otherwise build fails with error.

Maybe it's worth to mention a min. version for gcc in the COMPILING.md?

kingosticks commented 3 hours ago

Maybe it's worth to mention a min. version for gcc in the COMPILING.md?

I don't think this is realistic. This new gcc requirement comes from a dependency. Downstream projects can't be expected to track this kind of thing. I think if you're building the latest code, you're likely going to need a reasonably recent version of common dev tools like gcc. Ubuntu 20.04 might still be "supported" by Canoncial, but it's two LTS releases behind now and contains software from 4.5 years ago. I think it's fair to say that building latest software isn't what old Ubuntu LTS releases are for.