rust/compiler
Manish Goregaokar 7521a974d3
Rollup merge of #103353 - wesleywiser:fix_lld_thinlto_msvc, r=michaelwoerister
Fix Access Violation when using lld & ThinLTO on windows-msvc

Users report an AV at runtime of the compiled binary when using lld and ThinLTO on windows-msvc. The AV occurs when accessing a static value which is defined in one crate but used in another. Based on the disassembly of the cross-crate use, it appears that the use is not correctly linked with the definition and is instead assigned a garbage pointer value.

If we look at the symbol tables for each crates' obj file, we can see what is happening:

*lib.obj*:

```
COFF SYMBOL TABLE
...
00E 00000000 SECT2  notype       External     | _ZN10reproducer7memrchr2FN17h612b61ca0e168901E
...
```

*bin.obj*:

```
COFF SYMBOL TABLE
...
010 00000000 UNDEF  notype       External     | __imp__ZN10reproducer7memrchr2FN17h612b61ca0e168901E
...
```

The use of the symbol has the "import" style symbol name but the declaration doesn't generate any symbol with the same name. As a result, linking the files generates a warning from lld:

> rust-lld: warning: bin.obj: locally defined symbol imported: reproducer::memrchr::FN::h612b61ca0e168901 (defined in lib.obj) [LNK4217]

and the symbol reference remains undefined at runtime leading to the AV.

To fix this, we just need to detect that we are performing ThinLTO (and thus, static linking) and omit the `dllimport` attribute on the extern item in LLVM IR.

Fixes #81408
2022-11-08 21:03:52 -05:00
..
rustc rustc: Use unix_sigpipe instead of rustc_driver::set_sigpipe_handler 2022-10-02 17:49:36 +02:00
rustc_apfloat Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
rustc_arena Make use of [wrapping_]byte_{add,sub} 2022-08-23 19:32:37 +04:00
rustc_ast rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_ast_lowering rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_ast_passes Rollup merge of #95710 - fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett 2022-10-26 17:32:53 +05:30
rustc_ast_pretty Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
rustc_attr Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_borrowck Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, r=eholk 2022-11-08 11:23:51 +05:30
rustc_builtin_macros rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_codegen_cranelift Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_gcc Add type_array to BaseTypeMethods 2022-11-06 14:18:36 +05:30
rustc_codegen_llvm Rollup merge of #103353 - wesleywiser:fix_lld_thinlto_msvc, r=michaelwoerister 2022-11-08 21:03:52 -05:00
rustc_codegen_ssa Rollup merge of #104045 - Ayush1325:type_array, r=nikic 2022-11-07 09:46:26 +09:00
rustc_const_eval Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, r=eholk 2022-11-08 11:23:51 +05:30
rustc_data_structures Rollup merge of #103845 - camsteffen:data-structures-track-caller, r=compiler-errors 2022-11-04 12:18:01 +01:00
rustc_driver Add --print=split-debuginfo 2022-11-07 16:11:32 +01:00
rustc_error_codes Rollup merge of #103757 - ffmancera:ff/clarify_E0207, r=jackh726 2022-11-07 18:35:23 +05:30
rustc_error_messages Rollup merge of #103012 - chenyukang:fix-102806, r=davidtwco,compiler-errors 2022-11-06 08:35:26 +01:00
rustc_errors add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed' 2022-11-08 11:17:46 +08:00
rustc_expand Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_feature Auto merge of #102458 - JohnTitor:stabilize-instruction-set, r=oli-obk 2022-11-05 20:39:06 +00:00
rustc_fs_util Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
rustc_graphviz Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
rustc_hir Some tracing and comment cleanups 2022-11-04 17:10:07 +00:00
rustc_hir_analysis Rollup merge of #100508 - BoxyUwU:make_less_things_late_bound, r=nikomatsakis 2022-11-08 21:03:51 -05:00
rustc_hir_pretty pretty: fix to print some lifetimes on HIR pretty-print 2022-10-15 23:34:21 +09:00
rustc_hir_typeck Rollup merge of #104094 - lcnr:on_unimplemented-move, r=wesleywiser 2022-11-08 11:23:53 +05:30
rustc_incremental Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_index Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
rustc_infer Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, r=eholk 2022-11-08 11:23:51 +05:30
rustc_interface Simplify code 2022-11-05 17:54:06 +01:00
rustc_lexer Make underscore_literal_suffix a hard error. 2022-11-07 10:00:36 +11:00
rustc_lint fix: lint against lint functions 2022-11-07 19:23:29 -05:00
rustc_lint_defs Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error 2022-10-24 13:40:07 -05:00
rustc_llvm LLVM 16: Switch to using MemoryEffects 2022-11-04 17:58:16 +00:00
rustc_log Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
rustc_macros Modify comment syntax error 2022-11-07 14:33:33 +08:00
rustc_metadata Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_middle Auto merge of #104168 - GuillaumeGomez:rollup-tf4edqc, r=GuillaumeGomez 2022-11-08 22:50:12 +00:00
rustc_mir_build Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU 2022-11-05 00:02:06 +01:00
rustc_mir_dataflow Some tracing and comment cleanups 2022-11-04 17:10:07 +00:00
rustc_mir_transform Auto merge of #103975 - oli-obk:tracing, r=jackh726 2022-11-06 02:21:34 +00:00
rustc_monomorphize Fix ICE when negative impl is collected during eager mono 2022-11-04 03:08:28 +00:00
rustc_parse Fix outdated comment 2022-11-08 21:49:58 +04:00
rustc_parse_format Fix rustc_parse_format spans following escaped utf-8 multibyte chars 2022-10-27 18:20:56 +00:00
rustc_passes Auto merge of #103720 - crlf0710:most_translation_attr, r=compiler-errors 2022-11-06 11:23:24 +00:00
rustc_plugin_impl Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_privacy privacy: Check effective visibility invariants 2022-11-05 16:25:41 +04:00
rustc_query_impl Remove one lifetime from QueryKeyStringBuilder 2022-11-06 13:10:35 +01:00
rustc_query_system Rename Ctxt and CTX to Tcx and Qcx 2022-11-06 13:25:06 +01:00
rustc_resolve Auto merge of #103965 - petrochenkov:effvisperf3, r=oli-obk 2022-11-08 14:37:40 +00:00
rustc_save_analysis Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_serialize rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_session Add --print=split-debuginfo 2022-11-07 16:11:32 +01:00
rustc_smir Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
rustc_span Rollup merge of #97971 - Soveu:varargs, r=jackh726 2022-10-30 19:31:36 -07:00
rustc_symbol_mangling Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_target Rollup merge of #104067 - jeremyd2019:patch-1, r=davidtwco 2022-11-08 11:23:53 +05:30
rustc_trait_selection delay errors as bug 2022-11-08 14:48:07 +01:00
rustc_traits Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_transmute Auto merge of #103831 - chenyukang:yukang/fix-103751-ice, r=nagisa 2022-11-05 13:48:30 +00:00
rustc_ty_utils Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_type_ir deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly 2022-11-02 23:15:49 +08:00