Skip to content

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

Closed

Description

@matthiaskrgr

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!

Activity

  1. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Feb 22, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 22, 2024
  3. matthiaskrgr commented on Feb 22, 2024

    @matthiaskrgr
    MemberAuthor

    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

  4. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 22, 2024
  5. matthiaskrgr commented on Feb 22, 2024

    @matthiaskrgr
    MemberAuthor

    fwiw there is nothing about this that requires nightly

  6. matthiaskrgr commented on Feb 22, 2024

    @matthiaskrgr
    MemberAuthor

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

  7. removed
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Feb 22, 2024
  8. erikdesjardins commented on Feb 23, 2024

    @erikdesjardins
    Contributor

    Yeah, this is almost certainly because of #112157.

    The build passed in 1.72 because we ignored alignment for byval arguments. That caused us to miscompile such code, which was the motivation for #112157.

    I don't think we can drop or clamp the alignment attribute when it's too high for LLVM, since that would reintroduce the miscompile. (So I don't really see any option besides providing a nicer error diagnostic.)

    Although...Clang just ignores the requested alignment entirely if it's absurdly high, which also affects struct layout (https://godbolt.org/z/fjzfcsWda), which means we already differ from its ABI...

  9. erikdesjardins commented on Feb 23, 2024

    @erikdesjardins
    Contributor

    (When that PR was merged I thought the nightmare was over, but it turns out the ride never ends...)

  10. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Apr 15, 2024
  11. self-assigned this
    on Jul 24, 2024
  12. added
    llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
    on Jul 24, 2024
  13. added 3 commits that reference this issue on Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions