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

compilation failure on Android in termux shell #200

Closed
BurntSushi opened this issue Jan 12, 2025 · 3 comments · Fixed by #201
Closed

compilation failure on Android in termux shell #200

BurntSushi opened this issue Jan 12, 2025 · 3 comments · Fixed by #201
Labels
bug Something isn't working

Comments

@BurntSushi
Copy link
Owner

          Looks like this does not compile on-device from a Termux shell. There are 5 instances of this error:
error[E0308]: mismatched types
   --> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io
-6f17d22bba15001f/jiff-0.1.22/src/tz/system/android.rs:117:38
    |
117 | ...= unsafe { dlopen(cstr("libc.so\0").as_ptr(), 0) };
    |               ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`,
 found `*const u8`
    |               |
    |               arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io
-6f17d22bba15001f/jiff-0.1.22/src/tz/system/android.rs:293:8
    |
293 |     fn dlopen(filename: *const i8, flag: i32) -> *mut c_void;
    |        ^^^^^^

Originally posted by @dead10ck in #140 (comment)

BurntSushi added a commit that referenced this issue Jan 12, 2025
I guess some platforms use `*const u8` for C strings while most
seemingly use `*const i8`. So insert a bunch of `.cast()` calls where
appropriate.

Ref #140

Fixes #200
@BurntSushi
Copy link
Owner Author

@dead10ck Can you check if #201 fixes the issue for you?

I would still love to know your target triple so that I can add it to CI. I do have x86_64-linux-android being build in CI, but that apparently didn't catch this issue.

@dead10ck
Copy link

Thanks for the quick fix! My target triple is: aarch64-linux-android. The repro is simply cargo build

BurntSushi added a commit that referenced this issue Jan 13, 2025
I guess some platforms use `*const u8` for C strings while most
seemingly use `*const i8`. And indeed, `CStr::as_ptr` returns a
`*const u8` or a `*const i8` depending on the platform. So do the right
thing here and use std's `c_char` alias.

Ref #140

Fixes #200
@BurntSushi BurntSushi added the bug Something isn't working label Jan 13, 2025
@BurntSushi
Copy link
Owner Author

This should be fixed in jiff 0.1.23 on crates.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants