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

target: default to the medium code model on LoongArch targets #130266

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

heiher
Copy link
Contributor

@heiher heiher commented Sep 12, 2024

The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As described in the "Code Model" section of LoongArch ELF psABI spec v20231219 1, one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium.

Because:

  • we do not want to ask users to recompile std if they are to build such software,
  • objects compiled with larger code models can be linked with those with smaller code models without problems, and
  • the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB,

it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak.

Relands 2: #120661

The Rust LoongArch targets have been using the default LLVM code model
so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak.
As described in the "Code Model" section of LoongArch ELF psABI spec
v20231219 [1], one can only make function calls as far as ±128MiB with
the "normal" code model; this is insufficient for very large software
containing Rust components that needs to be linked into the big text
section, such as Chromium.

Because:

* we do not want to ask users to recompile std if they are to build
  such software,
* objects compiled with larger code models can be linked with those
  with smaller code models without problems, and
* the "medium" code model is comparable to the "small"/"normal" one
  performance-wise (same data access pattern; each function call
  becomes 2-insn long and indirect, but this may be relaxed back into
  the direct 1-insn form in a future LLVM version), but is able to
  perform function calls within ±128GiB,

it is better to just switch the targets to the "medium" code model,
which is also "medium" in LLVM-speak.

[1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models

Co-authored-by: WANG Rui <wangrui@loongson.cn>
@rustbot
Copy link
Collaborator

rustbot commented Sep 12, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 12, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 12, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

@heiher
Copy link
Contributor Author

heiher commented Sep 12, 2024

cc @xen0n @xry111

@xen0n
Copy link
Contributor

xen0n commented Sep 12, 2024

It's better to mention in the PR description the comment suggesting the reland for some more context. It really helps Git archaeology several years later according to my experience...

@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 13, 2024

📌 Commit 82777a9 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2024
@compiler-errors compiler-errors self-assigned this Sep 13, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 13, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 13, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#129320 (Fix crash when labeling arguments for call_once and friends)
 - rust-lang#130266 (target: default to the medium code model on LoongArch targets)
 - rust-lang#130297 (Dataflow cleanups)
 - rust-lang#130299 (Add set_dcx to ParseSess)
 - rust-lang#130301 (some fixes for clashing_extern_declarations lint)
 - rust-lang#130305 (Clippy: consider msrv for const context for const_float_bits_conv)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 13, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#129320 (Fix crash when labeling arguments for call_once and friends)
 - rust-lang#130266 (target: default to the medium code model on LoongArch targets)
 - rust-lang#130297 (Dataflow cleanups)
 - rust-lang#130299 (Add set_dcx to ParseSess)
 - rust-lang#130301 (some fixes for clashing_extern_declarations lint)
 - rust-lang#130305 (Clippy: consider msrv for const context for const_float_bits_conv)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 778f6fb into rust-lang:master Sep 13, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 13, 2024
Rollup merge of rust-lang#130266 - heiher:loong-medium-cmodel, r=compiler-errors

target: default to the medium code model on LoongArch targets

The Rust LoongArch targets have been using the default LLVM code model so far, which is "small" in LLVM-speak and "normal" in LoongArch-speak. As described in the "Code Model" section of LoongArch ELF psABI spec v20231219 [1], one can only make function calls as far as ±128MiB with the "normal" code model; this is insufficient for very large software containing Rust components that needs to be linked into the big text section, such as Chromium.

Because:

* we do not want to ask users to recompile std if they are to build such software,
* objects compiled with larger code models can be linked with those with smaller code models without problems, and
* the "medium" code model is comparable to the "small"/"normal" one performance-wise (same data access pattern; each function call becomes 2-insn long and indirect, but this may be relaxed back into the direct 1-insn form in a future LLVM version), but is able to perform function calls within ±128GiB,

it is better to just switch the targets to the "medium" code model, which is also "medium" in LLVM-speak.

Relands [2]:  rust-lang#120661

[1]: https://github.com/loongson/la-abi-specs/blob/v2.30/laelf.adoc#code-models
[2]: rust-lang#121289 (comment)
@heiher heiher deleted the loong-medium-cmodel branch September 14, 2024 02:01
heiher added a commit to heiher/rust that referenced this pull request Oct 18, 2024
The context for this is rust-lang#130266: setting the medium code model for the
'loongarch64-linux-ohos' target.
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 18, 2024
Default to the medium code model on OpenHarmony LoongArch target

The context for this is rust-lang#130266: setting the medium code model for the `loongarch64-linux-ohos` target.

r? `@jieyouxu`
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 18, 2024
Default to the medium code model on OpenHarmony LoongArch target

The context for this is rust-lang#130266: setting the medium code model for the `loongarch64-linux-ohos` target.

r? ``@jieyouxu``
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Oct 18, 2024
Default to the medium code model on OpenHarmony LoongArch target

The context for this is rust-lang#130266: setting the medium code model for the `loongarch64-linux-ohos` target.

r? ```@jieyouxu```
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2024
Rollup merge of rust-lang#131874 - heiher:loong-ohos-medium, r=jieyouxu

Default to the medium code model on OpenHarmony LoongArch target

The context for this is rust-lang#130266: setting the medium code model for the `loongarch64-linux-ohos` target.

r? ```@jieyouxu```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants