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

feat: add musl target support #111

Merged
merged 4 commits into from
Sep 12, 2018
Merged

Conversation

zitsen
Copy link
Contributor

@zitsen zitsen commented Sep 4, 2018

Changes:

  • explicitly declare deps for bzip2 and lzma feature.
  • add musl target support using cc crate.

Though I choose to link native deps via the bzip2-sys and lzma-sys crates,
note that the deps could be done with cargo's target selector.
Let me know if you do not want to link it by default.

/cc #80

@zitsen zitsen force-pushed the master branch 2 times, most recently from 03ff8cf to c999356 Compare September 5, 2018 01:02
Changes:
- explicitly declare deps for `bzip2` and `lzma` feature.
- add musl target support using `cc` crate.

Though I choose to link native deps with the `bzip2-sys` and `lzma-sys` crates,
note that the deps could be done with cargo's `target` selector.
Let me know if you do not want to link it by default.

/cc rust-bio#80
@zitsen zitsen force-pushed the master branch 2 times, most recently from 9dae7ab to 640e70e Compare September 5, 2018 06:17
Error description(see https://travis-ci.org/rust-bio/rust-htslib/builds/424648253):

```
kcov: warning: kcov: WARNING: kcov has been built without libbfd-dev (or
kcov: binutils-dev), so the --verify option will not do anything.
Can't set personality: Operation not permitted
kcov: error: Can't start/attach to /home/travis/build/rust-bio/rust-htslib/target/debug/deps/rust_htslib-b4e39d181972c8d6
Child hasn't stopped: ff00
kcov: error: Can't start/attach to /home/travis/build/rust-bio/rust-htslib/target/debug/deps/rust_htslib-b4e39d181972c8d6
error: test failed
```

Reference: roblabla/cargo-travis#38
@@ -13,6 +13,9 @@ documentation = "https://docs.rs/rust-htslib"

[dependencies]
libc = "0.2"
libz-sys = "1.0"
bzip2-sys = { version = "0.1.6", git = "https://github.com/alexcrichton/bzip2-rs.git", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand this. I thought these sys crates are just the bindings, but we don't need bindings here do we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do they also ship the libs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

libz-sys is here

@@ -39,17 +48,28 @@ fn main() {
if !use_bzip2 {
let bzip2_patterns = vec!["s/ -lbz2//", "/#define HAVE_LIBBZ2/d"];
sed_htslib_makefile(&out, &bzip2_patterns, "bzip2");
} else if let Ok(inc) = env::var("DEP_BZIP2_ROOT")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these additional env vars needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do they come from the bzip2-sys crate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's so sad I mistakenly deleted the commonts 😢 , maybe you could see them in email?

@johanneskoester
Copy link
Contributor

Looks really nice! just a few questions of somebody not so experienced with C compilation.

@zitsen
Copy link
Contributor Author

zitsen commented Sep 5, 2018

Explained here(:cry: seems that I'm not familiar with the github review behaviors...):

The -sys crate doest not only ship the libs, but also do lot of checks and settings, see the libz-sys build.rs, the cargo build script reference. At least these things to know:

  1. detecting system library settings.
  2. providing bidings of C API
  3. set link options to rustc without forcely linked (I mean -lz ...) , support static link option- though only serveral could
  4. providing include files and library files if system not match, eg. not exist or not static. That's the DEP_* environments come from.
  5. cc is a cross platform compiler wraper, better to use it instead of use gcc command, it does more than a complie command line, more targets will be benifit from this.

Copy link
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

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

Amazing! Really nice and very good to know.

@johanneskoester
Copy link
Contributor

johanneskoester commented Sep 5, 2018

Last question, does it make sense to follow a similar pattern for zlib as well (libz-sys)? If so, would you mind adding that here as well? If I understand correctly, this could make the build entirely self-contained.

@zitsen
Copy link
Contributor Author

zitsen commented Sep 5, 2018

There's something to do following libz-sys style:

1. Windows support should be dealt with, test should be passed (via appveyor - it's upon to you).
2. More targets should be tested(this is optional)
3. Trust will help.
4. filling build.rs

I'm glad to help after your done with appveyor(it's free).

@johanneskoester
Copy link
Contributor

Why would we need windows testing? As far as I know, htslib does not support windows, see here. Also, windows is not really relevant as a platform for the kind of bioinformatics analyses that can be done with htslib and rust-htslib.

@zitsen
Copy link
Contributor Author

zitsen commented Sep 10, 2018

ignore it and make your decision then.

@johanneskoester
Copy link
Contributor

Yes, I think libz-sys support would be nice. Do you want to add it in this PR?

@zitsen
Copy link
Contributor Author

zitsen commented Sep 11, 2018

did you mean add libz-sys dep? it has already been included.

or libz-sys like build scripts for htslib???

maybe my english is urgly....

@johanneskoester
Copy link
Contributor

I just meant adding at a dependency and using it. I was confused by the fact that there is no feature for it, and apparently it is not used in the build.rs. Is that intentional?

@zitsen
Copy link
Contributor Author

zitsen commented Sep 12, 2018

see libz-sys added as a dependency here. in common, there's no need to declare it in build.rs, but do declare it in lib.rs, cargo link it automatically. bzip2 and lzma is declared as optional because of feature deps, but libz is always required.

any else?

@johanneskoester johanneskoester merged commit 1f9736e into rust-bio:master Sep 12, 2018
@johanneskoester
Copy link
Contributor

Thank you!

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