Skip to content

Commit dbc62fe

Browse files
committed
cargo: explicitly configure musl to be statically linked
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)
1 parent 374d281 commit dbc62fe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.cargo/config.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,16 @@
66
rustflags = ["-C", "target-feature=+crt-static"]
77
[target.i686-pc-windows-msvc]
88
rustflags = ["-C", "target-feature=+crt-static"]
9+
10+
# Do the same for MUSL targets. At the time of writing (2023-10-23), this is
11+
# the default. But the plan is for the default to change to dynamic linking.
12+
# The whole point of MUSL with respect to ripgrep is to create a fully
13+
# statically linked executable.
14+
#
15+
# See: https://github.com/rust-lang/compiler-team/issues/422
16+
# See: https://github.com/rust-lang/compiler-team/issues/422#issuecomment-812135847
17+
[target.x86_64-unknown-linux-musl]
18+
rustflags = [
19+
"-C", "target-feature=+crt-static",
20+
"-C", "link-self-contained=yes",
21+
]

0 commit comments

Comments
 (0)