rust-lang/rust

LLVM ERROR `Attribute 'align' exceed the max size 2^14`

matthiaskrgr opened this issue · 5 comments

auto-reduced (treereduce-rust):

// #45662

#[repr(align(536870912))]
pub struct A(i64);

pub extern "C" fn foo(x: A) {}

fn main() {
    foo(A(0));
}

original:

//@ run-pass

#![allow(stable_features)]
#![allow(unused_variables)]

// #45662

#![feature(repr_align)]

#[repr(align(536870912))]
pub struct A(#[allow(dead_code)] i64);

#[allow(improper_ctypes_definitions)]
pub extern "C" fn foo(x: A) {}

fn main() {
    foo(A(0));
}

Version information

rustc 1.78.0-nightly (f8131a48a 2024-02-21)
binary: rustc
commit-hash: f8131a48a46ac3bc8a3d0fe0477055b132cffdc3
commit-date: 2024-02-21
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2

Program output

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.YLDguKS9zOCA/rustc_testrunner_tmpdir_reporting.HqYrVsxsA6S8/mvce.rs:6:23
  |
6 | pub extern "C" fn foo(x: A) {}
  |                       ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: field `0` is never read
 --> /tmp/icemaker_global_tempdir.YLDguKS9zOCA/rustc_testrunner_tmpdir_reporting.HqYrVsxsA6S8/mvce.rs:4:14
  |
4 | pub struct A(i64);
  |            - ^^^
  |            |
  |            field in this struct
  |
  = note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
  |
4 | pub struct A(());
  |              ~~

warning: `extern` fn uses type `A`, which is not FFI-safe
 --> /tmp/icemaker_global_tempdir.YLDguKS9zOCA/rustc_testrunner_tmpdir_reporting.HqYrVsxsA6S8/mvce.rs:6:26
  |
6 | pub extern "C" fn foo(x: A) {}
  |                          ^ not FFI-safe
  |
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout
note: the type is defined here
 --> /tmp/icemaker_global_tempdir.YLDguKS9zOCA/rustc_testrunner_tmpdir_reporting.HqYrVsxsA6S8/mvce.rs:4:1
  |
4 | pub struct A(i64);
  | ^^^^^^^^^^^^
  = note: `#[warn(improper_ctypes_definitions)]` on by default

Attribute 'align' exceed the max size 2^14
ptr @_ZN4mvce3foo17h02ccc75a6bd1c329E
in function _ZN4mvce3foo17h02ccc75a6bd1c329E
LLVM ERROR: Broken function found, compilation aborted!

Regression in nightly-2023-07-16

commit[0] 2023-07-14: Auto merge of #113471 - compiler-errors:new-solver-norm-escaping, r=lcnr
commit[1] 2023-07-15: Auto merge of #113514 - jyn514:more-gha-groups, r=oli-obk
commit[2] 2023-07-15: Auto merge of #112157 - erikdesjardins:align, r=nikic
commit[3] 2023-07-15: Auto merge of #113732 - matthiaskrgr:rollup-nm5qy4i, r=matthiaskrgr
commit[4] 2023-07-15: Auto merge of #113697 - GuillaumeGomez:rm-unneeded-externallocation-handling, r=lqd
ERROR: no CI builds available between ad96323 and 4c8bb79 within last 167 days

I suspect #112157 cc @erikdesjardins , @nikic

fwiw there is nothing about this that requires nightly

This is a 1.72 -> 1.73 regression (as in, build pass -> llvm error)