Skip to content

Conversation

@cosmikwolf
Copy link

I changed an ffi datatype to fix compilation errors during the docker build on an Apple sillicon computer:

16.15    Compiling clap v4.5.32
16.84    Compiling trace-recorder-parser v0.19.0
41.70    Compiling trace-recorder-to-ctf v0.3.1 (/trace-recorder-to-ctf)
41.81 error[E0308]: mismatched types
41.81     --> src/events.rs:118:10
41.81      |
41.81 118  | #[derive(CtfEventClass)]
41.81      |          ^^^^^^^^^^^^^
41.81      |          |
41.81      |          expected `*const u8`, found `*const i8`
41.81      |          arguments to this function are incorrect
41.81      |
41.81      = note: expected raw pointer `*const u8`
41.81                 found raw pointer `*const i8`
41.81 note: function defined here
41.81     --> /root/.cargo/git/checkouts/babeltrace2-sys-997fb7d2c925722c/795546a/src/bindings.rs:3852:12
41.81      |
41.81 3852 |     pub fn bt_field_class_enumeration_signed_add_mapping(
41.81      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41.81      = note: this error originates in the derive macro `CtfEventClass` (in Nightly builds, run with -Z macro-backtrace for more info)
41.81 
41.92 For more information about this error, try `rustc --explain E0308`.
41.92 error: could not compile `trace-recorder-to-ctf` (bin "trace-recorder-to-ctf") due to 1 previous error
41.93 error: failed to compile `trace-recorder-to-ctf v0.3.1 (/trace-recorder-to-ctf)`, intermediate artifacts can be found at `/trace-recorder-to-ctf/target`.
41.93 To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
------
Dockerfile:28
--------------------
  26 |     COPY src/ /trace-recorder-to-ctf/src/
  27 |     
  28 | >>> RUN cd /trace-recorder-to-ctf && ls -l && cargo install --path .
  29 |     
  30 |     ENTRYPOINT ["/root/.cargo/bin/trace-recorder-to-ctf"]
--------------------
ERROR: failed to solve: process "/bin/sh -c cd /trace-recorder-to-ctf && ls -l && cargo install --path ." did not complete successfully: exit code: 101
Error: Failed to build Docker image
Cleaning up build directory...
Trace processing complete
CTF output available at: target/trace/trace_20250325_152822.ctf

@jonlamb-gh
Copy link
Owner

Hi @cosmikwolf
I think this is a pretty typical portability issue. Probably would be best to cfg(target... gate this, and maybe wrap it in some opaque newtype that transparently handles the variants.
This whole layer was hacked together pretty quickly just to get a proof of concept out and I didn't have any portability concerns in mind.

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

Successfully merging this pull request may close these issues.

2 participants