rust/compiler/rustc_codegen_llvm/src
Peter Collingbourne 5873ebeef3 Move linkage type check to HIR analysis and fix semantics issues.
This ensures that the error is printed even for unused variables,
as well as unifying the handling between the LLVM and GCC backends.

This also fixes unusual behavior around exported Rust-defined variables
with linkage attributes. With the previous behavior, it appears to be
impossible to define such a variable such that it can actually be imported
and used by another crate. This is because on the importing side, the
variable is required to be a pointer, but on the exporting side, the
type checker rejects static variables of pointer type because they do
not implement `Sync`. Even if it were possible to import such a type, it
appears that code generation on the importing side would add an unexpected
additional level of pointer indirection, which would break type safety.

This highlighted that the semantics of linkage on Rust-defined variables
is different to linkage on foreign items. As such, we now model the
difference with two different codegen attributes: linkage for Rust-defined
variables, and import_linkage for foreign items.

This change gives semantics to the test
src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was
previously expected to fail to compile. Therefore, convert it into a
test that is expected to successfully compile.

The update to the GCC backend is speculative and untested.
2022-12-05 15:05:43 -08:00
..
back Use LLVM for getting symbols from COFF bigobj files 2022-11-26 19:35:32 +00:00
coverageinfo Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
debuginfo Unreserve braced enum variants in value namespace 2022-11-21 22:40:06 +03:00
llvm Auto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiser 2022-12-03 15:07:39 +00:00
abi.rs Improve generating Custom entry function 2022-11-11 01:04:39 +05:30
allocator.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
asm.rs Rollup merge of #103977 - TimNN:memory-effects, r=nikic 2022-11-05 00:02:05 +01:00
attributes.rs Mark naked functions as never inline in codegen_fn_attrs 2022-12-03 01:04:42 +01:00
base.rs Remove several unused methods from MiscMethods 2022-10-01 16:45:07 +00:00
builder.rs Use &mut Bx more. 2022-11-16 15:46:39 +11:00
callee.rs Workaround for private global symbol issue 2022-11-18 11:38:31 -08:00
common.rs Introduce a fallible variant of LLVMConstIntGetZExtValue 2022-09-09 15:54:14 +02:00
consts.rs Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
context.rs Rollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3 2022-11-19 11:54:43 +05:30
declare.rs Improve generating Custom entry function 2022-11-11 01:04:39 +05:30
errors.rs Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
intrinsic.rs Add Mutability::{is_mut,is_not} 2022-11-23 20:26:31 +00:00
lib.rs Port diagnostics created by Handler 2022-11-09 14:56:21 +01:00
llvm_util.rs Rollup merge of #105026 - oToToT:aarch64-v8a, r=davidtwco 2022-12-02 21:22:47 +01:00
mono_item.rs Fix diag() and formatting 2022-11-09 14:56:20 +01:00
type_.rs Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
type_of.rs add is_sized method on Abi and Layout, and use it 2022-11-13 12:23:53 +01:00
va_arg.rs Introduce Bx::switch_to_block 2022-02-24 12:18:21 +01:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00