esp-rs / espflash

Serial flasher utility for Espressif SoCs and modules based on esptool.py
Apache License 2.0
455 stars 110 forks source link

cargo install cargo-espflash fails with error of build command for `openssl-sys v0.9.101` #597

Closed freew01f closed 4 months ago

freew01f commented 4 months ago

I run cargo install cargo-espflash got error my env is below

rustup show                 
Default host: aarch64-apple-darwin
rustup home:  /Users/freewolf/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin
esp

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
riscv32imac-unknown-none-elf
riscv32imafc-unknown-none-elf
riscv32imc-unknown-none-elf

active toolchain
----------------

nightly-aarch64-apple-darwin (overridden by '/Users/freewolf/Documents/Study/esp32/test-51/rust-toolchain.toml')
rustc 1.78.0-nightly (397937d81 2024-02-22)

 cargo install cargo-espflash
    Updating crates.io index
  Installing cargo-espflash v2.1.0
    Updating crates.io index
   Compiling libc v0.2.153
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling cfg-if v1.0.0
   Compiling pkg-config v0.3.30
   Compiling vcpkg v0.2.15
   Compiling serde v1.0.197
   Compiling memchr v2.7.1
   Compiling autocfg v1.1.0
   Compiling thiserror v1.0.57
   Compiling aho-corasick v1.1.2
   Compiling crc32fast v1.4.0
   Compiling regex-syntax v0.8.2
   Compiling smallvec v1.13.1
   Compiling once_cell v1.19.0
   Compiling lock_api v0.4.11
   Compiling parking_lot_core v0.9.9
   Compiling scopeguard v1.2.0
   Compiling adler v1.0.2
   Compiling miniz_oxide v0.7.2
   Compiling quote v1.0.35
   Compiling syn v2.0.50
   Compiling regex-automata v0.4.5
   Compiling cc v1.0.86
   Compiling version_check v0.9.4
   Compiling bitflags v2.4.2
   Compiling crossbeam-utils v0.8.19
   Compiling same-file v1.0.6
   Compiling libz-sys v1.1.15
   Compiling parking_lot v0.12.1
   Compiling walkdir v2.4.0
   Compiling flate2 v1.0.28
   Compiling num-traits v0.2.18
   Compiling itoa v1.0.10
   Compiling bstr v1.9.0
   Compiling crossbeam-channel v0.5.11
   Compiling prodash v25.0.2
   Compiling getrandom v0.2.12
   Compiling sha1_smol v1.0.0
   Compiling zeroize v1.7.0
   Compiling bytes v1.5.0
   Compiling typenum v1.17.0
   Compiling rustix v0.38.31
   Compiling errno v0.3.8
   Compiling subtle v2.5.0
   Compiling tinyvec_macros v0.1.1
   Compiling tinyvec v1.6.0
   Compiling btoi v0.4.3
   Compiling num-conv v0.1.0
   Compiling powerfmt v0.2.0
   Compiling time-core v0.1.2
   Compiling serde_derive v1.0.197
   Compiling thiserror-impl v1.0.57
   Compiling time-macros v0.2.17
   Compiling unicode-normalization v0.1.23
   Compiling deranged v0.3.11
   Compiling generic-array v0.14.7
   Compiling num_threads v0.1.7
   Compiling syn v1.0.109
   Compiling log v0.4.20
   Compiling time v0.3.34
   Compiling minimal-lexical v0.2.1
   Compiling nom v7.1.3
   Compiling memmap2 v0.5.10
   Compiling const-oid v0.9.6
   Compiling home v0.5.9
   Compiling gix-trace v0.1.7
   Compiling hashbrown v0.14.3
   Compiling gix-path v0.8.4
   Compiling gix-validate v0.7.7
   Compiling fastrand v2.0.1
   Compiling signal-hook v0.3.17
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling signal-hook-registry v1.4.1
   Compiling digest v0.10.7
   Compiling tempfile v3.10.0
   Compiling rand_core v0.6.4
   Compiling gix-date v0.5.1
   Compiling unicode-bidi v0.3.15
   Compiling gix-actor v0.21.0
   Compiling percent-encoding v2.3.1
   Compiling form_urlencoded v1.2.1
   Compiling idna v0.5.0
   Compiling libnghttp2-sys v0.1.9+1.58.0
   Compiling openssl-src v300.2.3+3.2.1
   Compiling static_assertions v1.1.0
   Compiling openssl-sys v0.9.101
   Compiling url v2.5.0
   Compiling hex v0.4.3
   Compiling gix-hash v0.11.4
   Compiling curl-sys v0.4.72+curl-8.6.0
   Compiling gix-features v0.30.0
   Compiling gix-hashtable v0.2.4
   Compiling ryu v1.0.17
   Compiling gix-object v0.30.0
   Compiling gix-fs v0.2.0
   Compiling base64ct v1.6.0
   Compiling heck v0.4.1
   Compiling pem-rfc7468 v0.7.0
   Compiling gix-tempfile v6.0.0
   Compiling byteorder v1.5.0
   Compiling serde_json v1.0.114
   Compiling der v0.7.8
   Compiling gix-chunk v0.4.7
   Compiling rustversion v1.0.14
   Compiling utf8parse v0.2.1
   Compiling hmac v0.12.1
   Compiling gix-utils v0.1.9
   Compiling spki v0.7.3
   Compiling ring v0.17.8
   Compiling libssh2-sys v0.3.0
   Compiling ahash v0.8.9
   Compiling unicode-width v0.1.11
   Compiling curl v0.4.46
   Compiling stable_deref_trait v1.2.0
   Compiling semver v1.0.22
   Compiling pkcs8 v0.10.2
   Compiling gix-lock v6.0.0
   Compiling derive_more v0.99.17
   Compiling twox-hash v1.6.3
   Compiling ff v0.13.0
   Compiling gix-config-value v0.12.5
   Compiling gix-quote v0.4.10
   Compiling gix-sec v0.8.4
The following warnings were emitted during compilation:

warning: openssl-sys@0.9.101: xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
warning: openssl-sys@0.9.101: xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

error: failed to run custom build command for `openssl-sys v0.9.101`

Caused by:
  process didn't exit successfully: `/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-f6d773da745922e0/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_NO_VENDOR
  AARCH64_APPLE_DARWIN_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
  CC_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
  CC_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  running: "cc" "--version"
  exit status: 0
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
  cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
  cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
  exit status: 1
  cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
  CFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=AR_aarch64-apple-darwin
  AR_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=AR_aarch64_apple_darwin
  AR_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_AR
  HOST_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  cargo:rerun-if-env-changed=ARFLAGS_aarch64-apple-darwin
  ARFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=ARFLAGS_aarch64_apple_darwin
  ARFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_ARFLAGS
  HOST_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=RANLIB_aarch64-apple-darwin
  RANLIB_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=RANLIB_aarch64_apple_darwin
  RANLIB_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_RANLIB
  HOST_RANLIB = None
  cargo:rerun-if-env-changed=RANLIB
  RANLIB = None
  cargo:rerun-if-env-changed=RANLIBFLAGS_aarch64-apple-darwin
  RANLIBFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=RANLIBFLAGS_aarch64_apple_darwin
  RANLIBFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_RANLIBFLAGS
  HOST_RANLIBFLAGS = None
  cargo:rerun-if-env-changed=RANLIBFLAGS
  RANLIBFLAGS = None
  running cd "/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-3fdfd723e5951a19/out/openssl-build/build/src" && env -u CROSS_COMPILE AR="ar" CC="cc" RANLIB="ranlib" "perl" "./Configure" "--prefix=/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-3fdfd723e5951a19/out/openssl-build/install" "--openssldir=/usr/local/ssl" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "darwin64-arm64-cc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=11.0"
  Configuring OpenSSL version 3.2.1 for target darwin64-arm64-cc
  Using os-specific seed configuration
  Created configdata.pm
  Running configdata.pm
  Created Makefile.in
  Created Makefile
  Created include/openssl/configuration.h

  **********************************************************************
  ***                                                                ***
  ***   OpenSSL has been successfully configured                     ***
  ***                                                                ***
  ***   If you encounter a problem while building, please open an    ***
  ***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
  ***   and include the output from the following command:           ***
  ***                                                                ***
  ***       perl configdata.pm --dump                                ***
  ***                                                                ***
  ***   (If you are new to OpenSSL, you might want to consult the    ***
  ***   'Troubleshooting' section in the INSTALL.md file first)      ***
  ***                                                                ***
  **********************************************************************
  running cd "/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-3fdfd723e5951a19/out/openssl-build/build/src" && "make" "depend"
  running cd "/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-3fdfd723e5951a19/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=12,13 --jobserver-auth=12,13" "make" "build_libs"
  perl "-I." "-Iutil/perl" "-Mconfigdata" "-MOpenSSL::paramnames" "util/dofile.pl" "-oMakefile" crypto/params_idx.c.in > crypto/params_idx.c

  --- stderr
  make: *** read jobs pipe: Resource temporarily unavailable.  Stop.
  make: *** Waiting for unfinished jobs....
  thread 'main' panicked at /Users/freewolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-300.2.3+3.2.1/src/lib.rs:611:9:

  Error building OpenSSL:
      Command: cd "/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY/release/build/openssl-sys-3fdfd723e5951a19/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=12,13 --jobserver-auth=12,13" "make" "build_libs"
      Exit status: exit status: 2

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-espflash v2.1.0`, intermediate artifacts can be found at `/var/folders/gl/tjcxhg593tlg7qndbxgr1d8h0000gn/T/cargo-installtAXYUY`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

how ca i fix it ? thanks

SergioGasquez commented 4 months ago

Other colleagues have encountered this issue too, its a current third party limitation, see the issues:

I would recommend using the binaries from the release: https://github.com/esp-rs/espflash/releases:


curl -L "https://github.com/esp-rs/espflash/releases/latest/download/cargo-espflash-aarch64-apple-darwin.zip" -o "${HOME}/.cargo/bin/cargo-espflash.zip"
unzip "${HOME}/.cargo/bin/cargo-espflash.zip" -d "${HOME}/.cargo/bin/" 
rm "${HOME}/.cargo/bin/cargo-espflash.zip"
chmod u+x "${HOME}/.cargo/bin/cargo-espflash"
NobodyXu commented 4 months ago

I tried on my own project that updating to make 4.4.1 fixed this error. Could you give it a shot please?

playfulFence commented 4 months ago

@NobodyXu yes, your solution definitely fixes the error! Thank you for your response though! ❤️

A quick guide (at least worked for me. Requires updating the PATH which may be not ideal, but at least fixes the issue):

brew install make
PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"

Second command depends on your particular file location on the system, usually brew will give the path where it installed the new make.

NobodyXu commented 4 months ago

That's good to hear!

I also submit a PR in cc to fix the issue for older make (<4.3)

NobodyXu commented 4 months ago

cc 1.0.87 has released which should fix this

freew01f commented 4 months ago

@NobodyXu yes, your solution definitely fixes the error! Thank you for your response though! ❤️

A quick guide (at least worked for me. Requires updating the PATH which may be not ideal, but at least fixes the issue):

brew install make
PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"

Second command depends on your particular file location on the system, usually brew will give the path where it installed the new make.

It works thanks very much

NobodyXu commented 4 months ago

cc 1.0.88 has released, which should fix this even if you are using make < 4.3

SergioGasquez commented 4 months ago

Seems like the issue still persist with make < 4.3. I made #602 which updates the cc version to 1.0.88, but the issue still persists when doing cargo install cargo-espflash --git https://github.com/SergioGasquez/espflash --branch fix/mac-install --force

freew01f commented 4 months ago

Seems like the issue still persist with make < 4.3. I made #602 which updates the cc version to 1.0.88, but the issue still persists when doing cargo install cargo-espflash --git https://github.com/SergioGasquez/espflash --branch fix/mac-install --force

cc1.088 have the other problem

NobodyXu commented 4 months ago

cc1.088 have the other problem

Can you please elaborate?

freew01f commented 4 months ago

cc1.088 have the other problem

Can you please elaborate?

https://github.com/esp-rs/esp-idf-sys/issues/287

see here

1.0.84 -87 can not build

NobodyXu commented 4 months ago

@freew01f That's a different error. It's due to --target flag we now passed to clang, probably same as rust-lang/cc-rs#903