Skip to content

Commit

Permalink
cargo: explicitly configure musl to be statically linked
Browse files Browse the repository at this point in the history
It looks like the musl target will, at some point, default to be
dynamically linked. This config knob should make it so that it's always
statically linked.

Ref rust-lang/compiler-team#422
Ref rust-lang/compiler-team#422 (comment)
  • Loading branch information
BurntSushi committed Oct 23, 2023
1 parent 374d281 commit dbc62fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@
rustflags = ["-C", "target-feature=+crt-static"]
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

# Do the same for MUSL targets. At the time of writing (2023-10-23), this is
# the default. But the plan is for the default to change to dynamic linking.
# The whole point of MUSL with respect to ripgrep is to create a fully
# statically linked executable.
#
# See: https://github.com/rust-lang/compiler-team/issues/422
# See: https://github.com/rust-lang/compiler-team/issues/422#issuecomment-812135847
[target.x86_64-unknown-linux-musl]
rustflags = [
"-C", "target-feature=+crt-static",
"-C", "link-self-contained=yes",
]

0 comments on commit dbc62fe

Please sign in to comment.