Skip to content

Commit

Permalink
Don't build shared libraries for musl targets
Browse files Browse the repository at this point in the history
  • Loading branch information
bofh69 authored and lu-zero committed Oct 21, 2020
1 parent e569550 commit 04a92bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,16 @@ pub fn cbuild(
args: &ArgMatches<'_>,
) -> anyhow::Result<(BuildTargets, InstallPaths, CApiConfig)> {
let rustc_target = target::Target::new(args.target())?;
let libkinds = args
.values_of("library-type")
.map_or_else(|| vec!["staticlib", "cdylib"], |v| v.collect::<Vec<_>>());
let libkinds = args.values_of("library-type").map_or_else(
|| {
if rustc_target.env == "musl" {
vec!["staticlib"]
} else {
vec!["staticlib", "cdylib"]
}
},
|v| v.collect::<Vec<_>>(),
);
let only_staticlib = !libkinds.contains(&"cdylib");

patch_lib_kind_in_target(ws, &libkinds)?;
Expand Down
4 changes: 3 additions & 1 deletion src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ impl Target {

if os == "android" {
lines.push(format!("-Wl,-soname,lib{}.so", lib_name));
} else if os == "linux" || os == "freebsd" || os == "dragonfly" || os == "netbsd" {
} else if env != "musl"
&& (os == "linux" || os == "freebsd" || os == "dragonfly" || os == "netbsd")
{
lines.push(format!("-Wl,-soname,lib{}.so.{}", lib_name, major));
} else if os == "macos" || os == "ios" {
let line = format!("-Wl,-install_name,{1}/lib{0}.{2}.{3}.{4}.dylib,-current_version,{2}.{3}.{4},-compatibility_version,{2}",
Expand Down

0 comments on commit 04a92bc

Please sign in to comment.