Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Feb 22, 2024 · 5 comments · Fixed by #127513
Closed

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

matthiaskrgr opened this issue Feb 22, 2024 · 5 comments · Fixed by #127513
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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!

@matthiaskrgr matthiaskrgr added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

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

@jieyouxu jieyouxu added requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

fwiw there is nothing about this that requires nightly

@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Feb 22, 2024

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

@matthiaskrgr matthiaskrgr removed the requires-nightly This issue requires a nightly compiler in some way. label Feb 22, 2024
@erikdesjardins
Copy link
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...

@erikdesjardins
Copy link
Contributor

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

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@nikic nikic self-assigned this Jul 24, 2024
@nikic nikic added the llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade label Jul 24, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 31, 2024
Update to LLVM 19

The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th.

The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time.

Compatibility note for wasm:

> WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns.

Related changes:
 * rust-lang#127605
 * rust-lang#127613
 * rust-lang#127654
 * rust-lang#128141
 * llvm/llvm-project#98933

Fixes rust-lang#121444.
Fixes rust-lang#128212.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 31, 2024
Update to LLVM 19

The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th.

The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time.

Compatibility note for wasm:

> WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns.

Related changes:
 * rust-lang#127605
 * rust-lang#127613
 * rust-lang#127654
 * rust-lang#128141
 * llvm/llvm-project#98933

Fixes rust-lang#121444.
Fixes rust-lang#128212.
@bors bors closed this as completed in 0b5eb7b Jul 31, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Aug 2, 2024
Update to LLVM 19

The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th.

The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang/rust#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time.

Compatibility note for wasm:

> WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns.

Related changes:
 * rust-lang/rust#127605
 * rust-lang/rust#127613
 * rust-lang/rust#127654
 * rust-lang/rust#128141
 * llvm/llvm-project#98933

Fixes rust-lang/rust#121444.
Fixes rust-lang/rust#128212.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Aug 13, 2024
Update to LLVM 19

The LLVM 19.1.0 final release is planned for Sep 3rd. The rustc 1.82 stable release will be on Oct 17th.

The unstable MC/DC coverage support is temporarily broken by this update. It will be restored by rust-lang/rust#126733. The implementation changed substantially in LLVM 19, and there are no plans to support both the LLVM 18 and LLVM 19 implementation at the same time.

Compatibility note for wasm:

> WebAssembly target support for the `multivalue` target feature has changed when upgrading to LLVM 19. Support for generating functions with multiple returns no longer works and `-Ctarget-feature=+multivalue` has a different meaning than it did in LLVM 18 and prior. The WebAssembly target features `multivalue` and `reference-types` are now both enabled by default, but generated code is not affected by default. These features being enabled are encoded in the `target_features` custom section and may affect downstream tooling such as `wasm-opt` consuming the module, but the actual generated WebAssembly will continue to not use either `multivalue` or `reference-types` by default. There is no longer any supported means to generate a module that has a function with multiple returns.

Related changes:
 * rust-lang/rust#127605
 * rust-lang/rust#127613
 * rust-lang/rust#127654
 * rust-lang/rust#128141
 * llvm/llvm-project#98933

Fixes rust-lang/rust#121444.
Fixes rust-lang/rust#128212.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants