eclipse / paho.mqtt.rust

paho.mqtt.rust
Other
511 stars 102 forks source link

paho-mqtt-sys not finding vendored OpenSSL under cross --target mips-unknown-linux-musl #208

Closed homeassistant-hacs-m closed 10 months ago

homeassistant-hacs-m commented 11 months ago

Reproduction:

cargo new hello-mips
cd hello-mips
cargo add paho-mqtt-sys@0.8.1 --no-default-features --features vendored-ssl
cross build --target mips-unknown-linux-musl

Resulting Cargo.toml:

[package]
name = "hello-mips"
version = "0.1.0"
edition = "2021"

[dependencies]
paho-mqtt-sys = { version = "0.8.1", features = ["vendored-ssl"] }

Output:

   Compiling paho-mqtt-sys v0.8.1
error: failed to run custom build command for `paho-mqtt-sys v0.8.1`

Caused by:
  process didn't exit successfully: `/target/release/build/paho-mqtt-sys-28b3df184e955e40/build-script-build` (exit status: 101)
  --- stdout
  debug:Running the bundled build for Paho C
  cargo:rerun-if-changed=build.rs
  CMAKE_TOOLCHAIN_FILE_mips-unknown-linux-musl = None
  CMAKE_TOOLCHAIN_FILE_mips_unknown_linux_musl = Some("/opt/toolchain.cmake")
  CMAKE_GENERATOR_mips-unknown-linux-musl = None
  CMAKE_GENERATOR_mips_unknown_linux_musl = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_mips-unknown-linux-musl = None
  CMAKE_PREFIX_PATH_mips_unknown_linux_musl = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_mips-unknown-linux-musl = None
  CMAKE_mips_unknown_linux_musl = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/target/mips-unknown-linux-musl/release/build/paho-mqtt-sys-9a3e4493b7e1f9fb/out/build" && CMAKE_PREFIX_PATH="" "cmake" "~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/paho-mqtt-sys-0.8.1/paho.mqtt.c/" "-DPAHO_BUILD_SHARED=off" "-DPAHO_BUILD_STATIC=on" "-DPAHO_ENABLE_TESTING=off" "-DPAHO_HIGH_PERFORMANCE=on" "-DPAHO_WITH_SSL=on" "-DOPENSSL_ROOT_DIR=/target/mips-unknown-linux-musl/release/build/openssl-sys-9b6014567d7a215f/out/openssl-build/install" "-DCMAKE_TOOLCHAIN_FILE=/opt/toolchain.cmake" "-DCMAKE_INSTALL_PREFIX=/target/mips-unknown-linux-musl/release/build/paho-mqtt-sys-9a3e4493b7e1f9fb/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC" "-DCMAKE_BUILD_TYPE=MinSizeRel"
  -- The C compiler identification is GNU 9.2.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/local/bin/mips-linux-muslsf-gcc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- CMake version: 3.23.1
  -- CMake system name: Linux
  -- Timestamp is 2023-09-03T01:30:10Z
  -- Configuring incomplete, errors occurred!
  See also "/target/mips-unknown-linux-musl/release/build/paho-mqtt-sys-9a3e4493b7e1f9fb/out/build/CMakeFiles/CMakeOutput.log".

  --- stderr
  fatal: not a git repository (or any parent up to mount point ~)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  CMake Error at /usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
    system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
    OPENSSL_INCLUDE_DIR)
  Call Stack (most recent call first):
    /usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
    /usr/local/share/cmake-3.23/Modules/FindOpenSSL.cmake:578 (find_package_handle_standard_args)
    src/CMakeLists.txt:191 (find_package)

(I am aware I should be using build_bindgen on a weird target, but the error remains exactly the same, while the build to test the issue is faster)

fpagliughi commented 10 months ago

I just tried to reproduce it by following the steps you provided, and didn't get an error.

$ cargo new hello-mips
     Created binary (application) `hello-mips` package

$ cd hello-mips/

$ cargo add paho-mqtt-sys@0.8.1 --no-default-features --features vendored-ssl
    Updating crates.io index
      Adding paho-mqtt-sys v0.8.1 to dependencies.
             Features:
             + bundled
             + cmake
             + openssl-sys
             + ssl
             + vendored-ssl
             - bindgen
             - build_bindgen
    Updating crates.io index

$ cat Cargo.toml 
[package]
name = "hello-mips"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
paho-mqtt-sys = { version = "0.8.1", default-features = false, features = ["vendored-ssl"] }

$ cross build --target mips-unknown-linux-musl
info: downloading component 'rust-std' for 'mips-unknown-linux-musl'
info: installing component 'rust-std' for 'mips-unknown-linux-musl'
 23.6 MiB /  23.6 MiB (100 %)  17.6 MiB/s in  1s ETA:  0s
Unable to find image 'ghcr.io/cross-rs/mips-unknown-linux-musl:0.2.4' locally
0.2.4: Pulling from cross-rs/mips-unknown-linux-musl
09db6f815738: Already exists 
7121f569295b: Pull complete 
c2cb750d9e4f: Pull complete 
a609c3cd97fa: Pull complete 
3377c46af1ec: Pull complete 
a1cebf1b93a1: Pull complete 
f4e892ea09d3: Pull complete 
a68bd33d1030: Pull complete 
f978c3e997e9: Pull complete 
b61b360b09f3: Pull complete 
7778176840e6: Pull complete 
69e2e893d219: Pull complete 
0f1895026646: Pull complete 
ba3e0a92f4f2: Pull complete 
Digest: sha256:f607947973df26d947d66dc3a293164394faddbc752d59275e5c3de6a164f415
Status: Downloaded newer image for ghcr.io/cross-rs/mips-unknown-linux-musl:0.2.4
   Compiling libc v0.2.147
   Compiling vcpkg v0.2.15
   Compiling pkg-config v0.3.27
   Compiling cc v1.0.83
   Compiling openssl-src v300.1.3+3.1.2
   Compiling cmake v0.1.50
   Compiling openssl-sys v0.9.93
   Compiling paho-mqtt-sys v0.8.1
   Compiling hello-mips v0.1.0 (/project)
    Finished dev [unoptimized + debuginfo] target(s) in 17.55s

$ cross build --target mips-unknown-linux-musl --examples
warning: Target filter `examples` specified, but no targets matched. This is a no-op
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s

$ ls -lh target/mips-unknown-linux-musl/debug/
total 4.5M
drwxr-xr-x 5 fmp fmp 4.0K Sep  5 13:08 build
drwxr-xr-x 2 fmp fmp 4.0K Sep  5 13:08 deps
drwxr-xr-x 2 fmp fmp 4.0K Sep  5 13:08 examples
-rwxr-xr-x 2 fmp fmp 4.5M Sep  5 13:08 hello-mips
-rw-r--r-- 1 fmp fmp   71 Sep  5 13:08 hello-mips.d
drwxr-xr-x 3 fmp fmp 4.0K Sep  5 13:08 incremental

The only difference I can see is the dependency line in Cargo.toml::

[dependencies]
paho-mqtt-sys = { version = "0.8.1", default-features = false, features = ["vendored-ssl"] }

Mine has default-features = false and yours does not despite the fact that you requested no default features?

homeassistant-hacs-m commented 10 months ago

Whoops, my bad regarding default-features = false. I have tried both, but indeed it doesn't affect the result since the set of enabled features is the same in both cases.

The error continues on stable 1.71.0 (with missing rust-std component?!) but not on the current nightly, so I would consider this solved tbh.

fpagliughi commented 10 months ago

I wonder if it might be something with a bad setup with the cross environment for mips? Have you tried it with native build tools?

Just curious. I often test with cross for arm7 and aarch64 just to check that it compiles, but for my normal work, I use those tools natively - though these days, I don't see much of a performance enhancement.

DamienArke commented 9 months ago

Hi,

I'm experiencing the exact same issue with the latest 'main' image in version '0.2.5'. However, I was able to resolve this problem by downgrading to version '0.2.4', just as in the example you mentioned.

There seems to be a specific issue with version '0.2.5' that is affecting our case. I've checked the documentation and release notes, but I couldn't find an immediate solution. It's possible that it's a bug or an incompatibility with other components.

In the meantime, I'll continue using version '0.2.4' to ensure my application works correctly. If you have any updates on this issue or if you find a solution, I'd be happy to hear about it.

Thanks for sharing your experience here; it can help others who are encountering the same problem.

Best regards,