Repository: rust
Issue: Linker error when installing `wasm-bindgen-cli` in container `rust:1.72.0-alpine`
Labels: A-linkage,T-compiler,O-musl,C-bug

<!--
Thank you for filing a regression report! 🐛 A regression is something that changed between versions of Rust but was not supposed to.

Please provide a short summary of the regression, along with any information you feel is relevant to replicate it.
-->

### Code

I tried this code:

```shell
docker run --rm -it rust:1.72.0-alpine /bin/sh -c 'apk add pkgconfig musl-dev openssl-dev && cargo install wasm-bindgen-cli'
```

I expected to see this happen: Installation succeeds.

Instead, this happened: Installation fails with the output

```
   Compiling wasm-bindgen-cli v0.2.87
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/bin:/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/bin/self-contained:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crt1.o" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtbegin.o" "/tmp/rustcRXRjOo/symbols.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.00.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.01.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.02.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.03.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.04.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.05.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.06.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.07.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.08.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.09.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.10.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.11.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.12.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.13.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.14.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.wasm_bindgen_test_runner.1f95379ce0f90ab6-cgu.15.rcgu.o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26.19hh9c3u8vsswt4a.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/cargo-installRzq4g6/release/deps" "-L" "/tmp/cargo-installRzq4g6/release/build/curl-sys-7ceadbee8f5783d1/out/build" "-L" "/tmp/cargo-installRzq4g6/release/build/libz-sys-cffc81748277afdd/out/lib" "-L" "/tmp/cargo-installRzq4g6/release/build/libz-sys-cffc81748277afdd/out/lib" "-L" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/tmp/cargo-installRzq4g6/release/deps/libenv_logger-fea42c52e1f4f4fe.rlib" "/tmp/cargo-installRzq4g6/release/deps/libatty-317b42473a21e31a.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtermcolor-040fceae4cea271d.rlib" "/tmp/cargo-installRzq4g6/release/deps/libhumantime-626274989ed92745.rlib" "/tmp/cargo-installRzq4g6/release/deps/libregex-5b241dcccf21f933.rlib" "/tmp/cargo-installRzq4g6/release/deps/libregex_automata-9b96befcad88c4ab.rlib" "/tmp/cargo-installRzq4g6/release/deps/libaho_corasick-a16db84b88174926.rlib" "/tmp/cargo-installRzq4g6/release/deps/libregex_syntax-c3cf1ebb7a2b2e4d.rlib" "/tmp/cargo-installRzq4g6/release/deps/librouille-7230a0b8d19e678c.rlib" "/tmp/cargo-installRzq4g6/release/deps/liburl-9aebb6637b71bca7.rlib" "/tmp/cargo-installRzq4g6/release/deps/libidna-fb239a2c2019136b.rlib" "/tmp/cargo-installRzq4g6/release/deps/libunicode_normalization-54755a606192072d.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtinyvec-ee7642b89b653144.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtinyvec_macros-ff6759743fcc69d9.rlib" "/tmp/cargo-installRzq4g6/release/deps/libunicode_bidi-b489247189863188.rlib" "/tmp/cargo-installRzq4g6/release/deps/libform_urlencoded-d2c82d4a8de473ea.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtiny_http-7f8968ed1e1900d6.rlib" "/tmp/cargo-installRzq4g6/release/deps/libhttpdate-a24b706af28e4ef6.rlib" "/tmp/cargo-installRzq4g6/release/deps/libchunked_transfer-3a80b3bee19fa9e4.rlib" "/tmp/cargo-installRzq4g6/release/deps/libascii-8ab85db2098cf98e.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtime-a0293617723fa3a5.rlib" "/tmp/cargo-installRzq4g6/release/deps/libnum_threads-f25b70b3c45705e3.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtime_core-522cb0b5c81b88a6.rlib" "/tmp/cargo-installRzq4g6/release/deps/libderanged-9686717edf50d109.rlib" "/tmp/cargo-installRzq4g6/release/deps/libthreadpool-f94340fa0ccc9a33.rlib" "/tmp/cargo-installRzq4g6/release/deps/libsha1_smol-c6bcc18cced647a7.rlib" "/tmp/cargo-installRzq4g6/release/deps/libpercent_encoding-dc02a4f94527eacf.rlib" "/tmp/cargo-installRzq4g6/release/deps/libmultipart-4e7f890959935153.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtwoway-eacabc130a213c0a.rlib" "/tmp/cargo-installRzq4g6/release/deps/libhttparse-363b5b927f2c1587.rlib" "/tmp/cargo-installRzq4g6/release/deps/libbuf_redux-824514e68d98cc17.rlib" "/tmp/cargo-installRzq4g6/release/deps/libmemchr-19c5176ba959cb53.rlib" "/tmp/cargo-installRzq4g6/release/deps/libquick_error-553f59006e43ec1a.rlib" "/tmp/cargo-installRzq4g6/release/deps/libtempfile-aba4a00682dd1316.rlib" "/tmp/cargo-installRzq4g6/release/deps/libfastrand-fe632f4f74389971.rlib" "/tmp/cargo-installRzq4g6/release/deps/librustix-6d8cc2cc34aee0c8.rlib" "/tmp/cargo-installRzq4g6/release/deps/libbitflags-9e1b87856b5a39a6.rlib" "/tmp/cargo-installRzq4g6/release/deps/liblinux_raw_sys-4e4070322d7688b9.rlib" "/tmp/cargo-installRzq4g6/release/deps/librand-d2835ef6636aeab5.rlib" "/tmp/cargo-installRzq4g6/release/deps/librand_chacha-568bb813c2b47bea.rlib" "/tmp/cargo-installRzq4g6/release/deps/libppv_lite86-2e57afa0faee22ed.rlib" "/tmp/cargo-installRzq4g6/release/deps/librand_core-ed4dececf9a23aad.rlib" "/tmp/cargo-installRzq4g6/release/deps/libgetrandom-776d0166208e26f5.rlib" "/tmp/cargo-installRzq4g6/release/deps/libmime_guess-941a61daa992a772.rlib" "/tmp/cargo-installRzq4g6/release/deps/libunicase-28b314352ad426ab.rlib" "/tmp/cargo-installRzq4g6/release/deps/libmime-0ed1ffe2b41ac203.rlib" "/tmp/cargo-installRzq4g6/release/deps/libfiletime-6291ef5ef8718315.rlib" "/tmp/cargo-installRzq4g6/release/deps/libchrono-a9813c1d649a049d.rlib" "/tmp/cargo-installRzq4g6/release/deps/libnum_traits-ff6319496fc66d8e.rlib" "/tmp/cargo-installRzq4g6/release/deps/libiana_time_zone-06c52e180915fb89.rlib" "/tmp/cargo-installRzq4g6/release/deps/libbase64-04a3869521b53988.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcurl-8401af18d306a517.rlib" "/tmp/cargo-installRzq4g6/release/deps/libopenssl_probe-58309303a9f609bf.rlib" "/tmp/cargo-installRzq4g6/release/deps/libsocket2-0cda5863f22a9f1f.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcurl_sys-6e03aab9f31ac7f3.rlib" "/tmp/cargo-installRzq4g6/release/deps/libopenssl_sys-54ef50242963ee2e.rlib" "-lssl" "-lcrypto" "/tmp/cargo-installRzq4g6/release/deps/liblibz_sys-46141b191bc55227.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_cli_support-a8e091096f1105c3.rlib" "/tmp/cargo-installRzq4g6/release/deps/librustc_demangle-413429c0e73a1811.rlib" "/tmp/cargo-installRzq4g6/release/deps/libbase64-927b92a7980a3867.rlib" "/tmp/cargo-installRzq4g6/release/deps/libsafemem-9e20b9d7f5918daf.rlib" "/tmp/cargo-installRzq4g6/release/deps/libbyteorder-193ed6180b511e21.rlib" "/tmp/cargo-installRzq4g6/release/deps/libunicode_ident-facb9160c2b986fb.rlib" "/tmp/cargo-installRzq4g6/release/deps/libserde_json-c6d371e0ba0f1f0e.rlib" "/tmp/cargo-installRzq4g6/release/deps/libryu-fea49a689a77267f.rlib" "/tmp/cargo-installRzq4g6/release/deps/libitoa-5e1876a5b8dc25ab.rlib" "/tmp/cargo-installRzq4g6/release/deps/libserde-af4e742a39923287.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_threads_xform-45c90ceea9fd7b2c.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_shared-54ca8c389f3a7842.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_multi_value_xform-3cfca942b1dc6bce.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_externref_xform-459bf5b11f5bb873.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_wasm_interpreter-efdf35756ea4e01e.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasm_bindgen_wasm_conventions-8dbaf6474f2eff56.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwalrus-a2b97ede053e577c.rlib" "/tmp/cargo-installRzq4g6/release/deps/libleb128-6a6c460d8c649db9.rlib" "/tmp/cargo-installRzq4g6/release/deps/libwasmparser-640526087e5dde73.rlib" "/tmp/cargo-installRzq4g6/release/deps/libid_arena-a7382d3e69c3dfcd.rlib" "/tmp/cargo-installRzq4g6/release/deps/librayon-2f3462cb5183030a.rlib" "/tmp/cargo-installRzq4g6/release/deps/librayon_core-bf5017ead308b139.rlib" "/tmp/cargo-installRzq4g6/release/deps/libnum_cpus-6157bee815ca3e6a.rlib" "/tmp/cargo-installRzq4g6/release/deps/liblibc-ec23dbccd24ad4bf.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcrossbeam_deque-226b4a19293a209a.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcrossbeam_epoch-9c91de6b9109ccf8.rlib" "/tmp/cargo-installRzq4g6/release/deps/libmemoffset-106258de5846d349.rlib" "/tmp/cargo-installRzq4g6/release/deps/libscopeguard-5162a022afb43088.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcrossbeam_channel-0c851b46b7673bef.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcrossbeam_utils-2a12eb336abcd97a.rlib" "/tmp/cargo-installRzq4g6/release/deps/libcfg_if-2215ce30b5eeed66.rlib" "/tmp/cargo-installRzq4g6/release/deps/libeither-8725f330bf93e15e.rlib" "/tmp/cargo-installRzq4g6/release/deps/liblog-d17ae8ad17e5c7e1.rlib" "/tmp/cargo-installRzq4g6/release/deps/libanyhow-4c55c4ab3a31f229.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libstd-2ad8dcade37f4a90.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libpanic_unwind-979572faa2a17916.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libobject-93508898bcfc3702.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libmemchr-ab66446b81463d74.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libaddr2line-6083b516af549008.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libgimli-2389476f2626efb6.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_demangle-97faebafc321e964.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libstd_detect-e8ac812a6dab364e.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libhashbrown-dde0af57b0f2901e.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_std_workspace_alloc-8df52c7f042aeffd.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libminiz_oxide-8789ebd13f9e0a12.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libadler-cb238a2d7c01ef75.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libunwind-0ebf8faa9e79b9cc.rlib" "-lunwind" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcfg_if-73698e09b48b4cfd.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/liblibc-3f7bca623c41b752.rlib" "-lc" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/liballoc-11ab57860e7dd426.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/librustc_std_workspace_core-7ffd2525fa6ce213.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcore-e91e1df47a197349.rlib" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-5b084770a5817f4e.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib" "-L" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained" "-o" "/tmp/cargo-installRzq4g6/release/deps/wasm_bindgen_test_runner-4b3c9dfc3f5b6f26" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtend.o" "/usr/local/rustup/toolchains/1.72.0-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: /usr/lib/gcc/aarch64-alpine-linux-musl/12.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: cannot find -lssl: No such file or directory
          /usr/lib/gcc/aarch64-alpine-linux-musl/12.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: cannot find -lcrypto: No such file or directory
          collect2: error: ld returned 1 exit status
```

### Version it worked on

<!--
Provide the most recent version this worked on, for example:

It most recently worked on: Rust 1.47
-->

It most recently worked on: `rust:1.71.1-alpine`

### Version with regression

<!--
Provide the version you are using that has the regression.
-->

`rust:1.72.0-alpine`

<!--
If you know when this regression occurred, please add a line like below, replacing `{channel}` with one of stable, beta, or nightly.

@rustbot modify labels: +regression-from-stable-to-{channel} -regression-untriaged
-->

### Additional Context

Despite the linker output, one can check that the container does contain the `libssl` and `libcrypto` libraries which are installed by `apk` in the command provided. 

The problem does not arise with Debian-based Rust containers.

This bug is reproducable on both `amd64` and `arm64` architecture.