File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -384,8 +384,14 @@ impl<'ll> CodegenCx<'ll, '_> {
384384 let g = if val_llty == llty {
385385 g
386386 } else {
387- // If we created the global with the wrong type,
388- // correct the type.
387+ // codegen_static_initializer creates the global value just from the
388+ // `Allocation` data by generating one big struct value that is just
389+ // all the bytes and pointers after each other. This will almost never
390+ // match the type that the static was declared with. Unfortunately
391+ // we can't just LLVMConstBitCast our way out of it because that has very
392+ // specific rules on what can be cast. So instead of adding a new way to
393+ // generate static initializers that match the static's type, we picked
394+ // the easier option and retroactively change the type of the static item itself.
389395 let name = llvm:: get_value_name ( g) . to_vec ( ) ;
390396 llvm:: set_value_name ( g, b"" ) ;
391397
You can’t perform that action at this time.
0 commit comments