rust/compiler
Wesley Wiser 296489c892 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.
2022-11-03 11:17:42 -04: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 remove unused parser fn 2022-10-26 19:19:44 +00:00
rustc_ast_lowering Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04: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 #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04:00
rustc_builtin_macros Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_cranelift Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_gcc Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_llvm Fix Access Violation when using lld & ThinLTO on windows-msvc 2022-11-03 11:17:42 -04:00
rustc_codegen_ssa Rollup merge of #103638 - ia0:multivalue, r=nagisa 2022-11-01 20:00:39 -04:00
rustc_const_eval Format dyn Trait better in type_name intrinsic 2022-11-01 20:41:47 +00:00
rustc_data_structures Introduce UnordMap, UnordSet, and UnordBag (see MCP 533) 2022-10-27 13:23:26 +00:00
rustc_driver Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_error_codes Update E0382.md 2022-10-31 00:41:12 -04:00
rustc_error_messages Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3 2022-11-01 14:12:25 +05:30
rustc_errors Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_expand Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_feature Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +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 Reorder walk_ functions in intravisit.rs 2022-11-01 19:02:45 -04:00
rustc_hir_analysis Rollup merge of #103875 - oli-obk:ast_conv_simplification, r=spastorino 2022-11-02 22:06:28 +01: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 Simplify astconv item def id handling 2022-11-02 12:03:59 +00:00
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 #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04:00
rustc_interface Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_lexer rustc_lexer::TokenKind improve docs 2022-10-26 23:32:14 +02:00
rustc_lint Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04: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: Don't initialize removed legacy passes 2022-10-25 15:03:21 -07:00
rustc_log Add diagnostic translation lints to crates that don't emit them 2022-08-18 19:29:02 +01:00
rustc_macros Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04:00
rustc_metadata Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_middle Format dyn Trait better in type_name intrinsic 2022-11-01 20:41:47 +00:00
rustc_mir_build Rollup merge of #103584 - ouz-a:issue-102303, r=oli-obk 2022-11-01 14:12:25 +05:30
rustc_mir_dataflow Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_mir_transform Remove bounds check with enum cast 2022-10-31 14:10:37 +03:00
rustc_monomorphize Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_parse Rollup merge of #103703 - Nilstrieb:flag-recovery-1, r=compiler-errors 2022-11-02 22:32:03 +05:30
rustc_parse_format Detect and reject out-of-range integers in format string literals 2022-10-01 01:05:01 +02:00
rustc_passes Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04:00
rustc_plugin_impl Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_privacy Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_query_impl Introduce UnordMap, UnordSet, and UnordBag (see MCP 533) 2022-10-27 13:23:26 +00:00
rustc_query_system Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_resolve Rollup merge of #103760 - petrochenkov:macimp, r=cjgillot 2022-11-01 22:01:36 +05:30
rustc_save_analysis Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_serialize remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
rustc_session Rollup merge of #103610 - wesleywiser:thinlto_cgu1, r=michaelwoerister 2022-11-02 22:06:26 +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 Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_target Auto merge of #103455 - BlackHoleFox:apple-sim-abi-consistency, r=davidtwco 2022-11-03 03:07:31 +00:00
rustc_trait_selection Rollup merge of #103862 - compiler-errors:ocx-in-fully-normalize, r=spastorino 2022-11-02 22:32:05 +05:30
rustc_traits remove _types from ocx method names 2022-10-27 15:43:37 +00:00
rustc_transmute fix #103783, fix ICE checking transmutability of NaughtyLenArray 2022-10-30 06:21:27 +08:00
rustc_ty_utils Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors 2022-10-29 14:18:03 +02:00
rustc_type_ir Deny const variables as well 2022-10-19 17:11:40 +00:00