Azure / azure-sdk-for-rust

This repository is for active development of the *unofficial* Azure SDK for Rust. This repository is *not* supported by the Azure SDK team.
MIT License
676 stars 231 forks source link

iot_hub examples require aws-lc-rs prerequisites (NASM, etc.), breaking rust-analyzer for other packages #1677

Open analogrelay opened 3 weeks ago

analogrelay commented 3 weeks ago

The iot_hub examples use hyper_rustls (though honestly I don't see exactly where).

The update from hyper-rustls 0.26 to 0.27 in https://github.com/Azure/azure-sdk-for-rust/pull/1628 includes rustls changes to switch the underlying crypto library from ring to aws-lc-rs. Unfortunately, the aws-lc-rs library requires several dependencies in order to build. As a result, running rust-analyzer in the repository fails. For example, see this screenshot from RustRover:

image

Or, building examples (cargo build --examples) at the repo root:

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

Caused by:
  process didn't exit successfully: `W:\Azure\azure-sdk-for-rust\target\debug\build\aws-lc-sys-1e301be2af945e09\build-script-main` (exit code: 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_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:warning=Generating bindings - internal bindgen. Platform: x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=AWS_LC_SYS_INCLUDES

  --- stderr
  AWS_LC_SYS_NO_ASM=1
  thread 'main' panicked at C:\Users\ashleyst\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.69.4\lib.rs:622:31:
  Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Specifically, you need NASM (or to set AWS_LC_SYS_NO_ASM) and Clang installed.

This is a confusing experience for a new engineer, and it seems undesirable to require these prerequisites be configured if you're not even working on the IoT Hub library.

There are a few solutions to take here, and I'm happy to open a PR for one of them, but I don't really work in the iot_hub area (I'll be working primarily on Cosmos DB) so I wanted to consult:

  1. Document how to install the pre-reqs in the repo README.md - I'd prefer not to expect all users of the repo to install NASM and a C Compiler, but it's fairly straightforward.
  2. Remove hyper-rustls from the iot_hub examples altogether. I don't see it actually being used and was able to run at least part of one of the iot_hub examples without it (I ran the configuration example and it successfully created the connection, then failed with some other deserialization errors, indicating it was successfully making requests to Azure).
  3. Switch hyper-rustls from the default aws-lc-rs feature to ring, which doesn't require build prerequisites.
  4. Exclude the iot_hub package from the workspace, or encourage users to do so transiently, so that rust-analyzer can correctly start. Not a fan of this one, but it's what I'm doing locally for now ;).

I think option 2 is probably the easiest, if it works. I just don't have the context to know if there's a deeper reason hyper-rustls is installed as a dev dependency in that package.