Repository: rust
Issue: Unexpected compiler panic "undefined symbol: __getrandom_custom"
Labels: I-ICE,T-compiler,C-bug,E-needs-mcve

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

I am running into this issue while running `cargo tarpaulin --verbose --workspace --out Xml` on a cargo workspace which has sqlx as a dependency for several of the local packages. Not sure if the issue is in one of these packages, but I am reporting per `rustc` output message.

 --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs:67:1

```Rust
pub extern crate sqlx_macros;
```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2
```

### Error output

```
   Compiling sqlx v0.6.3
     Running `rustc --crate-name sqlx --edition=2021 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="_rt-tokio"' --cfg 'feature="chrono"' --cfg 'feature="macros"' --cfg 'feature="migrate"' --cfg 'feature="offline"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio-rustls"' --cfg 'feature="sqlx-macros"' --cfg 'feature="uuid"' -C metadata=8609a6f082f3cbea -C extra-filename=-8609a6f082f3cbea --out-dir /home/runner/work/core/core/target/debug/deps -L dependency=/home/runner/work/core/core/target/debug/deps --extern sqlx_core=/home/runner/work/core/core/target/debug/deps/libsqlx_core-b0972e0b2071df0c.rmeta --extern sqlx_macros=/home/runner/work/core/core/target/debug/deps/libsqlx_macros-9dea50aba1cf204c.so --cap-lints allow -Cdebuginfo=2 --cfg=tarpaulin -Clink-dead-code -L native=/home/runner/work/core/core/target/debug/build/ring-611b3f0a6161274c/out`
Jul 03 15:46:45.257 DEBUG cargo_tarpaulin::cargo: Linker paths: ["/home/runner/work/core/core/target/debug/build/ring-611b3f0a6161274c/out"]
error: Broken pipe (os error 32)
warning: build failed, waiting for other jobs to finish...
thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_resolve/src/lib.rs:1872:67
stack backtrace:
   0:     0x7f8a255b0cca - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8a255b0cca - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8a255b0cca - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f8a255b0cca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8a256150cf - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f8a255a3805 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x7f8a255b0a95 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f8a255b0a95 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f8a255b373e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x7f8a255b34e5 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x7f8a2886f995 - <rustc_driver_impl[fe6df70259db788d]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[da82827a87f140f9]::ops::function::FnOnce<(&core[da82827a87f140f9]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f8a255b3f34 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb9b860f5a1175bda
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  12:     0x7f8a255b3f34 - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
  13:     0x7f8a255b3c62 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:580:13
  14:     0x7f8a255b1136 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f8a255b3a02 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  16:     0x7f8a25611443 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  17:     0x7f8a256114dd - core::panicking::panic::h0ead933cb8f56d66
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
  18:     0x7f8a278868f5 - <rustc_resolve[23c071e843dc4060]::Resolver>::resolve_rustdoc_path
  19:     0x7f8a27886067 - <rustc_resolve[23c071e843dc4060]::late::LateResolutionVisitor>::resolve_and_cache_rustdoc_path
  20:     0x7f8a2788145e - <rustc_resolve[23c071e843dc4060]::late::LateResolutionVisitor>::resolve_doc_links
  21:     0x7f8a2786ff4c - <rustc_resolve[23c071e843dc4060]::late::LateResolutionVisitor>::resolve_item
  22:     0x7f8a2786fdb1 - <rustc_resolve[23c071e843dc4060]::late::LateResolutionVisitor as rustc_ast[1277eecfcff379e0]::visit::Visitor>::visit_item
  23:     0x7f8a2786fc1d - <rustc_resolve[23c071e843dc4060]::Resolver>::late_resolve_crate
  24:     0x7f8a2786eed7 - <rustc_session[99ba0ed9c533f203]::session::Session>::time::<(), <rustc_resolve[23c071e843dc4060]::Resolver>::resolve_crate::{closure#0}>
  25:     0x7f8a2786c5e4 - rustc_interface[7aa24cde61830128]::passes::resolver_for_lowering
  26:     0x7f8a2804b17e - rustc_query_system[5e34f8384464b8a5]::query::plumbing::try_execute_query::<rustc_query_impl[3e42b93bfeb445bd]::queries::resolver_for_lowering, rustc_query_impl[3e42b93bfeb445bd]::plumbing::QueryCtxt>
  27:     0x7f8a2804ae6d - <rustc_query_impl[3e42b93bfeb445bd]::Queries as rustc_middle[a487dff4633a86d0]::ty::query::QueryEngine>::resolver_for_lowering
  28:     0x7f8a27eef898 - <std[b70fedfd8b77e9]::thread::local::LocalKey<core[da82827a87f140f9]::cell::Cell<*const ()>>>::with::<rustc_middle[a487dff4633a86d0]::ty::context::tls::enter_context<<rustc_middle[a487dff4633a86d0]::ty::context::GlobalCtxt>::enter<rustc_driver_impl[fe6df70259db788d]::run_compiler::{closure#1}::{closure#2}::{closure#2}, &rustc_data_structures[fea82b52c2e47d17]::steal::Steal<(rustc_middle[a487dff4633a86d0]::ty::ResolverAstLowering, alloc[c91da12302dbbf86]::rc::Rc<rustc_ast[1277eecfcff379e0]::ast::Crate>)>>::{closure#0}, &rustc_data_structures[fea82b52c2e47d17]::steal::Steal<(rustc_middle[a487dff4633a86d0]::ty::ResolverAstLowering, alloc[c91da12302dbbf86]::rc::Rc<rustc_ast[1277eecfcff379e0]::ast::Crate>)>>::{closure#0}, &rustc_data_structures[fea82b52c2e47d17]::steal::Steal<(rustc_middle[a487dff4633a86d0]::ty::ResolverAstLowering, alloc[c91da12302dbbf86]::rc::Rc<rustc_ast[1277eecfcff379e0]::ast::Crate>)>>
  29:     0x7f8a27b59f02 - <rustc_interface[7aa24cde61830128]::interface::Compiler>::enter::<rustc_driver_impl[fe6df70259db788d]::run_compiler::{closure#1}::{closure#2}, core[da82827a87f140f9]::result::Result<core[da82827a87f140f9]::option::Option<rustc_interface[7aa24cde61830128]::queries::Linker>, rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  30:     0x7f8a27b55281 - rustc_span[2f805118d893a80f]::set_source_map::<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustc_driver_impl[fe6df70259db788d]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  31:     0x7f8a27b5482f - std[b70fedfd8b77e9]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7aa24cde61830128]::util::run_in_thread_pool_with_globals<rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustc_driver_impl[fe6df70259db788d]::run_compiler::{closure#1}>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>
  32:     0x7f8a28138661 - <<std[b70fedfd8b77e9]::thread::Builder>::spawn_unchecked_<rustc_interface[7aa24cde61830128]::util::run_in_thread_pool_with_globals<rustc_interface[7aa24cde61830128]::interface::run_compiler<core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>, rustc_driver_impl[fe6df70259db788d]::run_compiler::{closure#1}>::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[da82827a87f140f9]::result::Result<(), rustc_span[2f805118d893a80f]::ErrorGuaranteed>>::{closure#1} as core[da82827a87f140f9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f8a255be3b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1f2224656a778fb
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  34:     0x7f8a255be3b5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haa29ed9703f354b7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  35:     0x7f8a255be3b5 - std::sys::unix::thread::Thread::new::thread_start::h33b6dae3e3692197
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f8a25309b43 - <unknown>
  37:     0x7f8a2539ba00 - <unknown>
  38:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.70.0 (90c541806 2023-05-31) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C debuginfo=2 -C link-dead-code

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack
error: could not compile `sqlx` (lib) due to 3 previous errors

Caused by:
  process didn't exit successfully: `rustc --crate-name sqlx --edition=2021 /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="_rt-tokio"' --cfg 'feature="chrono"' --cfg 'feature="macros"' --cfg 'feature="migrate"' --cfg 'feature="offline"' --cfg 'feature="postgres"' --cfg 'feature="runtime-tokio-rustls"' --cfg 'feature="sqlx-macros"' --cfg 'feature="uuid"' -C metadata=8609a6f082f3cbea -C extra-filename=-8609a6f082f3cbea --out-dir /home/runner/work/core/core/target/debug/deps -L dependency=/home/runner/work/core/core/target/debug/deps --extern sqlx_core=/home/runner/work/core/core/target/debug/deps/libsqlx_core-b0972e0b2071df0c.rmeta --extern sqlx_macros=/home/runner/work/core/core/target/debug/deps/libsqlx_macros-9dea50aba1cf204c.so --cap-lints allow -Cdebuginfo=2 --cfg=tarpaulin -Clink-dead-code -L native=/home/runner/work/core/core/target/debug/build/ring-611b3f0a6161274c/out` (exit status: 101)
Jul 03 15:46:52.438 ERROR cargo_tarpaulin: Failed to compile tests!
error: /home/runner/work/core/core/target/debug/deps/libsqlx_macros-9dea50aba1cf204c.so: undefined symbol: __getrandom_custom
  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs:67:1
   |
67 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Error: "Failed to compile tests!\nerror: /home/runner/work/core/core/target/debug/deps/libsqlx_macros-9dea50aba1cf204c.so: undefined symbol: __getrandom_custom\n  --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-0.6.3/src/lib.rs:67:1\n   |\n67 | pub extern crate sqlx_macros;\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"

```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```

stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: <rustc_resolve::Resolver>::resolve_rustdoc_path
   4: <rustc_resolve::late::LateResolutionVisitor>::resolve_and_cache_rustdoc_path
   5: <rustc_resolve::late::LateResolutionVisitor>::resolve_doc_links
   6: <rustc_resolve::late::LateResolutionVisitor>::resolve_item
   7: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_item
   8: <rustc_resolve::Resolver>::late_resolve_crate
   9: <rustc_session::session::Session>::time::<(), <rustc_resolve::Resolver>::resolve_crate::{closure#0}>
  10: rustc_interface::passes::resolver_for_lowering
  11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::resolver_for_lowering, rustc_query_impl::plumbing::QueryCtxt>
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolver_for_lowering
  13: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#2}, &rustc_data_structures::steal::Steal<(rustc_middle::ty::ResolverAstLowering, alloc::rc::Rc<rustc_ast::ast::Crate>)>>::{closure#0}, &rustc_data_structures::steal::Steal<(rustc_middle::ty::ResolverAstLowering, alloc::rc::Rc<rustc_ast::ast::Crate>)>>::{closure#0}, &rustc_data_structures::steal::Steal<(rustc_middle::ty::ResolverAstLowering, alloc::rc::Rc<rustc_ast::ast::Crate>)>>
  14: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  15: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>

```

</p>
</details>