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

Tracking issue: -Zreg-struct-return support in rustc #116973

Open
1 of 7 tasks
ojeda opened this issue Oct 20, 2023 · 5 comments
Open
1 of 7 tasks

Tracking issue: -Zreg-struct-return support in rustc #116973

ojeda opened this issue Oct 20, 2023 · 5 comments
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-CLI Area: Command-line interface (CLI) to the compiler A-rust-for-linux Relevant for the Rust-for-Linux project C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ojeda
Copy link
Contributor

ojeda commented Oct 20, 2023

i.e. the equivalent of Clang's/GCC's -freg-struct-return. The kernel needs it to support the x86 32-bit architecture, together with -Zregparm=3.

It could potentially be a "global target feature", i.e. a target feature that is required to be set the same way for all compilation units.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps

Unresolved Questions & Answers

  • Q: Should it affect the Rust ABI? It cannot be documented as doing such, because the Rust ABI is unstable, but should it do so anyways as a quality-of-implementation matter?
  • Q: Should it affect any other ABIs than "C", "cdecl", and "stdcall"?
    • Currently: No.
    • Alternatives: It's not yet clear what ABIs this affects for gcc and clang.
  • Q: Should it be accepted on any other architecture than x86_32?
    • Currently: No.
  • Q: Does MSVC code use this?
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 20, 2023
@bjorn3
Copy link
Member

bjorn3 commented Oct 20, 2023

For the rust ABI we already do this. For C ABI compat we will need this. I'm not sure it should be a cli argument though as it affects the ABI and thus has to match for all crates. ABI changes are normally specified in the target spec.

@bjorn3 bjorn3 added the A-ABI Area: Concerning the application binary interface (ABI) label Oct 20, 2023
@bjorn3
Copy link
Member

bjorn3 commented Oct 20, 2023

Looks like there is already a target spec key for this used by eg FreeBSD: abi_return_struct_as_int

@Noratrieb Noratrieb added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 21, 2023
@ojeda
Copy link
Contributor Author

ojeda commented Oct 21, 2023

Yeah, it is the target spec vs. CLI discussion. If I recall correctly, at some point the topic was brought up we were told rustc wanted to move away from the JSON target spec file since it was too tied to LLVM. So that leaves built-in targets or CLI flags (or perhaps a new way). Built-in targets cannot be easily configured/experimented with (i.e. users need to revert to the JSON file), we may require different combinations of them depending on the kernel configuration, and diverges from what GCC/Clang offer. CLI flags are more flexible, but the overwhelming majority of users do not need some of these specialized ones.

@Darksonn
Copy link
Contributor

@rustbot label A-rust-for-linux

@rustbot rustbot added the A-rust-for-linux Relevant for the Rust-for-Linux project label Sep 28, 2024
@workingjubilee workingjubilee added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Oct 22, 2024
@workingjubilee workingjubilee changed the title -Zreg-struct-return support in rustc Tracking issue: -Zreg-struct-return support in rustc Oct 22, 2024
@workingjubilee workingjubilee added the A-CLI Area: Command-line interface (CLI) to the compiler label Oct 22, 2024
@azhogin
Copy link
Contributor

azhogin commented Oct 23, 2024

Currently: We already do this for the Rust ABI implicitly, without needing a compiler flag
For the rust ABI we already do this

It is not fully correct atm. For structs with 3 fields and more - yes, it works. But 2-field structs are represented by Abi::ScalarPair, not Abi::Aggregate, so { i32; i32 } is not optimized to i64 without the patch.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 6, 2024
… r=workingjubilee

rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-lang#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: rust-lang#116973
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 6, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#130777 (rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-lang#116973))
 - rust-lang#133211 (Extend Miri to correctly pass mutable pointers through FFI)
 - rust-lang#133294 (crashes: more tests)
 - rust-lang#133790 (Improve documentation for Vec::extend_from_within)
 - rust-lang#133930 (rustbook: update to use new mdbook-trpl package from The Book)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 6, 2024
… r=workingjubilee

rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-lang#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: rust-lang#116973
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 6, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#130777 (rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-lang#116973))
 - rust-lang#133211 (Extend Miri to correctly pass mutable pointers through FFI)
 - rust-lang#133790 (Improve documentation for Vec::extend_from_within)
 - rust-lang#133930 (rustbook: update to use new mdbook-trpl package from The Book)
 - rust-lang#133931 (Only allow PassMode::Direct for aggregates on wasm when using the C ABI)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 6, 2024
Rollup merge of rust-lang#130777 - azhogin:azhogin/reg-struct-return, r=workingjubilee

rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-lang#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: rust-lang#116973
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 7, 2024
…gjubilee

rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: rust-lang/rust#116973
antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this issue Dec 11, 2024
…gjubilee

rust_for_linux: -Zreg-struct-return commandline flag for X86 (#116973)

Command line flag `-Zreg-struct-return` for X86 (32-bit) for rust-for-linux.
This flag enables the same behavior as the `abi_return_struct_as_int` target spec key.

- Tracking issue: rust-lang/rust#116973
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-CLI Area: Command-line interface (CLI) to the compiler A-rust-for-linux Relevant for the Rust-for-Linux project C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants