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

fix: change the type to c_char so it can be compiled for aarch64 #337

Merged
merged 2 commits into from Oct 26, 2021

Conversation

cschin
Copy link
Contributor

@cschin cschin commented Oct 26, 2021

The PR changes the pointer type to i8 to a pointer type to c_char. When I tested to compile this on AWS graviton CPU, the c_char is actually u8 type. The hard-coded pointer type to i8 causes compiling errors. This should work on Intel and aarch64. (I did not test compiling the code on macOS though.)

@cschin cschin changed the title change the type to c_char so it can be compiled for aarch64 fix: change the type to c_char so it can be compiled for aarch64 Oct 26, 2021
@brainstorm
Copy link
Member

Thanks @cschin for these changes, there seem to be formatting issues, just cargo fmt and commit/push again? ;)

@brainstorm brainstorm self-requested a review October 26, 2021 02:29
@coveralls
Copy link

coveralls commented Oct 26, 2021

Pull Request Test Coverage Report for Build 1383999223

  • 37 of 37 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 94.8%

Totals Coverage Status
Change from base Build 1383851418: 0.004%
Covered Lines: 11523
Relevant Lines: 12155

💛 - Coveralls

@brainstorm
Copy link
Member

Can you rebase against master? CI does not seem to be happy with MacOS, it doesn't seem to be your fault though, I've pushed a couple of commits fixing rust.yml CI recipe for OSX now and it's green on HEAD.

@cschin
Copy link
Contributor Author

cschin commented Oct 26, 2021

Can you rebase against master? CI does not seem to be happy with MacOS, it doesn't seem to be your fault though, I've pushed a couple of commits fixing rust.yml CI recipe for OSX now and it's green on HEAD.

just did. sorry the commits are a bit messy.

@brainstorm
Copy link
Member

just did. sorry the commits are a bit messy.

Yeah, thanks, I noticed, would you mind cleaning (squashing) them up a bit?

@brainstorm
Copy link
Member

The PR changes the pointer type to i8 to a pointer type to c_char. When I tested to compile this on AWS graviton CPU, the c_char is actually u8 type. The hard-coded pointer type to i8 causes compiling errors. This should work on Intel and aarch64. (I did not test compiling the code on macOS though.)

Also, could you paste the compile errors you were seeing over here for future reference? I'll probably test your changes with my toy example: https://github.com/brainstorm/s3-rust-htslib-bam

@cschin
Copy link
Contributor Author

cschin commented Oct 26, 2021

This is the errors when I compile the master branch:

   Compiling rust-htslib v0.38.2 (/wd/rust-htslib)
error[E0308]: mismatched types
   --> src/bam/record.rs:152:16
    |
152 |             s: sam_copy.as_ptr() as *mut i8,
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*mut u8`
               found raw pointer `*mut i8`

error[E0308]: mismatched types
   --> src/bam/record.rs:583:17
    |
583 |                 c_str.as_ptr() as *mut i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*mut i8`

error[E0308]: mismatched types
   --> src/bam/record.rs:678:49
    |
678 |                 let c_str = ffi::CStr::from_ptr(aux.offset(TYPE_ID_LEN).cast::<i8>());
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`

error[E0308]: mismatched types
   --> src/bam/record.rs:798:21
    |
798 |                     ctag,
    |                     ^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*mut i8`

Copy link
Member

@tedil tedil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to go from i8 to c_char. Just a byte in a CStr ;)
Thanks for the PR, very much appreciated!

@brainstorm brainstorm merged commit a21aff2 into rust-bio:master Oct 26, 2021
@cschin
Copy link
Contributor Author

cschin commented Oct 26, 2021

@brainstorm @tedil Thanks. It will make my Cargo.toml a bit cleaner (no need to point to my own fork in the future).

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.

None yet

4 participants