Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile for 32-bit Tigo systems? #3

Open
zestysoft opened this issue Jul 1, 2024 · 5 comments
Open

Can't compile for 32-bit Tigo systems? #3

zestysoft opened this issue Jul 1, 2024 · 5 comments

Comments

@zestysoft
Copy link

Heya, trying to cross compile this to work with my 32-bit (armv5) Tigo CCS running v2.8.5 of the firmware, but it looks like the prometheus-client might be 64-bit only. Just wondering if there is any workaround for this?

$ cross build --target=armv5te-unknown-linux-gnueabi --release
   Compiling proc-macro2 v1.0.69
   Compiling libc v0.2.150
   Compiling parking_lot_core v0.9.9
   Compiling syn v1.0.109
   Compiling serde v1.0.192
   Compiling lock_api v0.4.11
   Compiling prometheus-client v0.22.0
   Compiling quote v1.0.33
   Compiling parking_lot v0.12.1
   Compiling syn v2.0.39
   Compiling csv v1.3.0
   Compiling prometheus-client-derive-encode v0.4.2
   Compiling gumdrop_derive v0.8.1
error[E0432]: unresolved import `std::sync::atomic::AtomicU64`
  --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/prometheus-client-0.22.0/src/metrics/counter.rs:10:5
   |
10 | use std::sync::atomic::AtomicU64;
   |     ^^^^^^^^^^^^^^^^^^^---------
   |     |                  |
   |     |                  help: a similar name exists in the module: `AtomicU32`
   |     no `AtomicU64` in `sync::atomic`

error[E0432]: unresolved import `std::sync::atomic::AtomicU64`
  --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/prometheus-client-0.22.0/src/metrics/exemplar.rs:17:5
   |
17 | use std::sync::atomic::AtomicU64;
   |     ^^^^^^^^^^^^^^^^^^^---------
   |     |                  |
   |     |                  help: a similar name exists in the module: `AtomicU32`
   |     no `AtomicU64` in `sync::atomic`

error[E0432]: unresolved imports `std::sync::atomic::AtomicI64`, `std::sync::atomic::AtomicU64`
  --> /cargo/registry/src/index.crates.io-6f17d22bba15001f/prometheus-client-0.22.0/src/metrics/gauge.rs:11:25
   |
11 | use std::sync::atomic::{AtomicI64, AtomicU64};
   |                         ^^^^^^^^^  ^^^^^^^^^ no `AtomicU64` in `sync::atomic`
   |                         |
   |                         no `AtomicI64` in `sync::atomic`
   |
help: a similar name exists in the module
   |
11 | use std::sync::atomic::{AtomicI32, AtomicU64};
   |                         ~~~~~~~~~
help: a similar name exists in the module
   |
11 | use std::sync::atomic::{AtomicI64, AtomicU32};
   |                                    ~~~~~~~~~

   Compiling gumdrop v0.8.1
For more information about this error, try `rustc --explain E0432`.
error: could not compile `prometheus-client` (lib) due to 3 previous errors
@rp-
Copy link
Owner

rp- commented Jul 1, 2024

Could you try to replace the Gauge<f64, AtomicU64>> to Gauge<f32, AtomicU32>>

prometheus-client 0.22.2 added support for that, maybe than the u64 are not compiled?

Otherwise I guess you would need to also patch that out of prometheus-client or make it feature enabled.

@zestysoft
Copy link
Author

Even after replacing 64 with 32 everywhere in the main.rs file, the same problem persists compiling the prometheus-client. This however looks hopeful! prometheus/client_rust#206

@rp-
Copy link
Owner

rp- commented Jul 2, 2024

yes this sounds promising

@navaati
Copy link

navaati commented Jul 2, 2024

Hi ! I’m writing this PR and have more coming for a more complete 32 bits support as I’m in the same embedded situation. Just prometheus/client_rust#206 by itself will not help you, you’ll also need at least prometheus/client_rust#203.

I’m maintaining my master branch with a merged version that includes all my in-flight PRs, hopefully it should give you what you need. In particular, it contains some commits for things not currently present in any PRs, like f32 support.

You can try temporarily adding this to your Cargo.toml:

[patch.crates-io]
prometheus-client = { git = "https://github.com/navaati/prometheus_client_rust.git", branch = "master" }

Then cargo update to pin the git hash in your lock file and go on github and check the exact diff between that git hash and upstream master, that way you don’t have to trust me. I’ll make sure to leave that commit available in the repo until everything is upstream.

You can track the current status of things in prometheus/client_rust#207 to know what works or not in upstream master.

Test feedbacks are welcome :).

@zestysoft
Copy link
Author

zestysoft commented Jul 16, 2024

That helped resolve a number of issues, however, I'm still not able to create that rust binary:

cross build --target=armv5te-unknown-linux-gnueabi --release
   Compiling proc-macro2 v1.0.86
   Compiling libc v0.2.155
   Compiling autocfg v1.3.0
   Compiling parking_lot_core v0.9.10
   Compiling serde v1.0.204
   Compiling smallvec v1.13.2
   Compiling memchr v2.7.4
   Compiling itoa v1.0.11
   Compiling prometheus-client v0.22.2 (https://github.com/navaati/prometheus_client_rust.git?branch=master#c74c2c3c)
   Compiling log v0.4.22
   Compiling ryu v1.0.18
   Compiling csv-core v0.1.11
   Compiling lock_api v0.4.12
   Compiling chunked_transfer v1.5.0
   Compiling tiny_http v0.12.0
   Compiling quote v1.0.36
   Compiling syn v2.0.71
   Compiling syn v1.0.109
   Compiling parking_lot v0.12.3
   Compiling csv v1.3.0
   Compiling gumdrop_derive v0.8.1
   Compiling prometheus-client-derive-encode v0.4.2 (https://github.com/navaati/prometheus_client_rust.git?branch=master#c74c2c3c)
   Compiling gumdrop v0.8.1
   Compiling tigo-exporter v0.3.0 (/project)
error[E0432]: unresolved import `std::sync::atomic::AtomicU64`
 --> src/main.rs:5:5
  |
5 | use std::sync::atomic::AtomicU64;
  |     ^^^^^^^^^^^^^^^^^^^---------
  |     |                  |
  |     |                  help: a similar name exists in the module: `AtomicU32`
  |     no `AtomicU64` in `sync::atomic`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `tigo-exporter` (bin "tigo-exporter") due to 1 previous error

Just for fun, I gave this rust source file to ChatGPT and asked it to convert it to Go. With one additional follow up question, it was able to produce the code in .go and gave instructions to successfully create a working binary: https://github.com/zestysoft/tigo-exporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants