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

128-bit integers marked as having an unknown stable ABI #78473

Open
haraldh opened this issue Oct 28, 2020 · 5 comments
Open

128-bit integers marked as having an unknown stable ABI #78473

haraldh opened this issue Oct 28, 2020 · 5 comments
Labels
A-abi Area: Concerning the application binary interface (ABI). A-ffi Area: Foreign Function Interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@haraldh
Copy link
Contributor

haraldh commented Oct 28, 2020

Introduced by 549dd10 128-bit integers used in e.g. extern "sysv64" produce the warning:

warning: `extern` fn uses type `u128`, which is not FFI-safe
   --> src/xxx.rs:126:6
    |
126 | ) -> u128 {
    |      ^^^^ not FFI-safe
    |
    = note: `#[warn(improper_ctypes_definitions)]` on by default
    = note: 128-bit integers don't currently have a known stable ABI

warning: 1 warning emitted

I dispute this statement by pointing to the now de facto source of the x86-64 System V ABI:

@est31
Copy link
Member

est31 commented Oct 28, 2020

Good point actually. Allowing it for extern "C" for sysv64 using targets would probably be a bad idea due to the current lack of a portability lint (#41619), but allowing it for extern "sysv64" should be doable I think.

cc @nagisa

@jonas-schievink jonas-schievink added A-ffi Area: Foreign Function Interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. labels Oct 28, 2020
est31 added a commit to est31/rust that referenced this issue Oct 28, 2020
For the sysv64 ABI, 128 bit integers are well defined.

Fixes rust-lang#78473.
@est31
Copy link
Member

est31 commented Oct 28, 2020

Made a PR to allow it on sysv64: #78481

@workingjubilee workingjubilee added the A-abi Area: Concerning the application binary interface (ABI). label Jul 1, 2022
@workingjubilee
Copy link
Contributor

workingjubilee commented Feb 21, 2023

Making some notes here for the next swing at a generic integers RFC:

  • _BitInt(N) is upcoming in C23
  • Current spec for SysV x86-64 _BitInt(N) where N > 64 is as-if eightbyte-aligned structs
  • Thus, __int128 and _BitInt(128) are ABI-incompatible
  • If we RFC something like int<const N> we may want to decide:
    • type i128 = int<128>;
    • int<N> is repr(C)-compatible as _BitInt(N)
  • That would make this pair incorrect:
extern "C" fn by_value_int128s(a: i128, b: i128, c: i128, d: i64, e: i128) -> i128
__int128 by_value_int128s(__int128 a, __int128 b, __int128 c, int64_t d, __int128 e);
  • Deciding int<128> =! _BitInt(128) means we can't call this C23 function:
_BitInt(128) by_value_big_bitints(_BitInt(128) a, _BitInt(128) b, _BitInt(128) c, int64_t d, _BitInt(128) e);

I have opened an issue regarding this at the x86-64-ABI gitlab. However they may have good reasons for their current spec, so it is not guaranteed they will consider this a spec bug.

@tgross35
Copy link
Contributor

I think the links in the original issue are dead, unless this was actually the intended highlight range

image

(GL changes the URL if you hit the "permalink" button top right, not like GH where you can copy a permalink directly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-abi Area: Concerning the application binary interface (ABI). A-ffi Area: Foreign Function Interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants