rust/compiler/rustc_codegen_gcc/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 simplify a self-profiling activity call in the cg_gcc backend 2022-04-07 15:47:20 +02:00
intrinsic Merge apply_attrs_callsite into call and invoke 2022-10-01 17:01:31 +00:00
abi.rs Merge apply_attrs_callsite into call and invoke 2022-10-01 17:01:31 +00:00
allocator.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
archive.rs Rewrite LLVM's archive writer in Rust 2022-11-26 19:35:32 +00:00
asm.rs Merge apply_attrs_callsite into call and invoke 2022-10-01 17:01:31 +00:00
base.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
builder.rs Use &mut Bx more. 2022-11-16 15:46:39 +11:00
callee.rs Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
common.rs Remove dead broken code from const zst handling in backends 2022-09-06 14:09:49 +00:00
consts.rs Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
context.rs Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
coverageinfo.rs Merge commit 'e228f0c16ea8c34794a6285bf57aab627c26b147' into libgccjit-codegen 2021-08-15 08:29:07 -04:00
debuginfo.rs Introduce composite debuginfo. 2022-11-15 17:53:50 +00:00
declare.rs Use custom entry name in gcc 2022-11-15 22:15:55 +05:30
errors.rs Move linkage type check to HIR analysis and fix semantics issues. 2022-12-05 15:05:43 -08:00
int.rs Merge commit 'e8dca3e87d164d2806098c462c6ce41301341f68' into sync_from_cg_gcc 2022-06-06 22:04:37 -04:00
lib.rs Allow actual AVX512-related feature names in the case of some misleading aliases 2022-11-12 18:46:21 -05:00
mono_item.rs Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
type_.rs add is_sized method on Abi and Layout, and use it 2022-11-13 12:23:53 +01:00
type_of.rs Update TypeVisitor paths 2022-07-06 06:41:53 +01:00