Closed zeeev closed 4 months ago
Hey there. I believe Rust statically links everything by default except for glibc, which is where the error is occurring. I don't think you can get around that, but you could compile on an older glibc system (like the manylinux container the Python library uses) to assure backwards compatibility. It lets me release a python module that is precompiled yet works on many different systems. You can see the manylinux compilation here: https://github.com/jguhlin/minimap2-rs/blob/main/.github/workflows/build-test-rust-minimappers2.yaml
If you truly want to statically link, you need to drop glibc and use musl (minimap2-rs has a test to compile with musl as well, so compatibility is assured). I haven't done any benchmarking though.
rustup target add x86_64-unknown-linux-musl
set -x RUSTFLAGS '-C target-feature=+crt-static'
cargo test --release --target x86_64-unknown-linux-musl
Let me know if none of those work.
Hi @jguhlin,
Thanks for quick reply with good suggestions. Unfortunately, we are tied to using a system wide install of rust (i.e. rustup cannot be used) and therefore I cannot switch to musl. Looking into other options.
sorry to bug, but we were wondering if there is any update on a release version?
@jrharting Oops, missed this. There's a release coming out soon, but it may not fix the above problem
no worries! thanks for the update. We will see what we can do re the glibc issue and if we find anything will let you know.
@jguhlin we've been able to build tools for static release that have htslib as a dependancy. Wondering what deps are making this challenging?
@jrharting @zeeev New update is out, see if that fixes it? Or if you can get a new error report posted here?
Otherwise I think it's zlib, we can change it by using zlib-ng, but that could have problems on other platforms. I'll work on making it into a feature.
Update: there's a static flag for libz-sys (with your mention of htslib I went digging in there code and found it). I think that might work too, so if the newest version doesn't work try out the github repo?
Hi @jguhlin, sorry for the delay. I've uploaded the error message for 0.1.14
Trying the GitHub version now. Thanks again!
Here is the GitHub version error.
Thanks, this is great. I'll enable a static flag for zlib and a zlibng flag as well. It may be later today or next week, unfortunately as I'm at a conference this week. But I do think it is that.
On Wed, 19 Jul 2023, 1:28 am Zev Kronenberg, @.***> wrote:
Here is the GitHub version error.
err-gh.txt https://github.com/jguhlin/minimap2-rs/files/12082948/err-gh.txt
— Reply to this email directly, view it on GitHub https://github.com/jguhlin/minimap2-rs/issues/38#issuecomment-1640448332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOA2CBAIE4TUKH2ZYCNLBTXQ2TQFANCNFSM6AAAAAAYG622AQ . You are receiving this because you were mentioned.Message ID: @.***>
@zeeev Looks like the errors have changed, so it could be a libcurl problem. Do you have any deps needing curl-sys (cargo tree should give this). There are static features for curl-sys. But in case it is still this crate, I've created a test branch:
Please try this in the Cargo.toml and give it a go
minimap2 = { git = "https://github.com/jguhlin/minimap2-rs", branch = "static" }
Let me know what your command to build the static binary is as well, I'd like to get it into the CI system here too. :)
Hi @jguhlin,
Here's the command that works for other tools on our build server.
module load cmake gcc zlib rust/1.68.2 htslib
export RUSTFLAGS="-C target-feature=+crt-static -C relocation-model=static"
cargo build --release --target x86_64-unknown-linux-gnu
I tried the new branch and attached the error build.err.txt
Thanks for checking it out.
@zeeev Thanks, that helps a ton. It compiles and runs tests with: "target-feature=+crt-static" but the relocation model is causing some errors with -fPIE, so different from the errors you are getting. I suspect you have other crates causing problems now. But can't be certain without checking the code. But this is compiling and testing with +crt-static, and giving another error entirely at the linking step for the relocation model. Going to dig into this, and will let you know when I've got something!
@zeeev Do you need the relocation model to be static? It does compile and run all tests without it, and ldd on fakeminimap2 in the static branch shows it as static, and I can bring it over to another machine and it runs?
(base) joseph@josephguhlin:~/development/minimap2-rs/fakeminimap2$ ldd target/release/fakeminimap2
statically linked
Also change the dep line to:
minimap2 = { git = "https://github.com/jguhlin/minimap2-rs", branch = "static", features = ["static"]}
(although zlib-ng should work as a feature too)
Hi @jguhlin,
Thanks for building this wrapper to minimap2 it's been extremely useful. We (@jrharting) are trying to get a static build working for our project, but hitting linking errors in linux. We traced the problem back to minimap2-rs. Do you have any suggestions?
I reproduced the error just in the minimap2-rs repo by doing the following: