-
Notifications
You must be signed in to change notification settings - Fork 84
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
Static compilation possible? #80
Comments
Static building is fine. I do that all the time. However, HTSlib needs glibc >= 2.3.4. You are trying to build on musl instead. I don't know if that is supported. I suggest asking the htslib guys. |
Closing for now, feel free to reopen if you disagree or new issues arise. |
Thanks, I would be happy to use glibc. However, after a frustrating amount of internet searching I'm finding it difficult to work out how, exactly. Would you mind sharing your secret? I'm looking to build an executable. Apologies if this is a naive question, I just figure you might have a solution easily at hand. |
glibc should be the default on most linux distributions. So, if you e.g. run on Ubuntu or Fedora, it will use a new enough glibc automatically. Unfortunately, if your system uses musl, you might need to do the build inside a container or a virtual machine, or try to figure out how to switch to glibc on your system. |
Right, glibc is the default on my (Ubuntu/GNU Guix) system. I installed the musl toolchain with rustup specifically for the purpose of static compilation, following this advice:
https://doc.rust-lang.org/1.12.1/book/advanced-linking.html#static-linking Compiling with the musl toolchain gives a static binary by default, where the glibc toolchain does not (I tried using Thanks, ben |
Ok, so you want the libc to be statically linked as well. This is indeed not possible if you depend on htslib, since that requires glibc as far as I know. However, please note that statically linking glibc into a binary is usually not necessary. It is present on virtually every system. All you need is to build your binary on an old enough linux, because glibc is forward compatible. By e.g. building on centos 6, it should work on all newer linuxes. The problem you have is that your ubuntu has a too new glibc for many other linuxes I guess. Instead of trying to build a compatible binary on your own (I guess for distribution), please consider providing your package via Bioconda, which solves such problems for you. |
OK, thanks for the suggestions. I'll figure something out. |
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
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
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
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
* feat: add musl target support 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 #80 * chore: not force install cargo-travis to save time * fix: try to fix default target error * fix(CI): fix cargo-travis(kcov) error 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
Hi,
I'm trying to create a static binary for a project of mine https://github.com/wwood/CoverM but i'm running into an issue:
Is it possible to get a static compile of a project using rust-htslib? Am I doing something incorrectly?
ta, ben
The text was updated successfully, but these errors were encountered: