Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Recently, ripgrep was on the frontpage. It says "Linux binaries are static executables" [0]. If I run ldd on cargo, it spits out the usually glibc dependencies, but Rust libraries are statically linked. It seems to be the default behavior of cargo? I would describe that as "promote static linking".

Personally, I don't judge this as good or bad. There is no simple answer. Static linking has clear disadvantage wrt security patches. On the other hand, it makes little sense to dynamically link tiny libraries, e.g. a queue data structure.

[0] https://github.com/BurntSushi/ripgrep



> It says "Linux binaries are static executables" [0].

They are. Running `ldd` on cargo doesn't confirm or deny this. You need to run `ldd` on the binary distributed:

    $ curl -sLO 'https://github.com/BurntSushi/ripgrep/releases/download/0.2.1/ripgrep-0.2.1-x86_64-unknown-linux-musl.tar.gz'
    $ tar xf ripgrep-0.2.1-x86_64-unknown-linux-musl.tar.gz 
    $ ldd ./ripgrep-0.2.1-x86_64-unknown-linux-musl/rg
            not a dynamic executable
This is not the default output on Linux. You need to compile with musl instead of glibc: https://news.ycombinator.com/item?id=12565268


To elaborate on what burntsushi said:

By default, Rust statically links all Rust code. However, glibc isn't usually statically linked, so Rust doesn't either. You can use musl instead of glibc to get 100% statically linked binaries.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: