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

Default relax_elf_relocations to true #106511

Merged
merged 1 commit into from
Aug 24, 2023
Merged

Conversation

MaskRay
Copy link
Contributor

@MaskRay MaskRay commented Jan 5, 2023

This option tells LLVM to emit relaxable relocation types R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX/R_386_GOT32X in applicable cases. True matches Clang's CMake default since 2020-08 1 and latest LLVM default2.

This also works around a GNU ld<2.41 issue2 when using general-dynamic/local-dynamic TLS models in -Z plt=no mode with latest LLVM.

@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2023

⚠️ Warning ⚠️

  • These commits modify submodules.

@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 Jan 5, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2023

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

@MaskRay MaskRay force-pushed the gotpcrelx branch 2 times, most recently from 10cba1c to 9a9ba97 Compare January 5, 2023 22:12
@rust-log-analyzer

This comment has been minimized.

@MaskRay
Copy link
Contributor Author

MaskRay commented Jan 5, 2023

failures:
    [mir-opt] src/test/mir-opt/generator_tiny.rs
    [mir-opt] src/test/mir-opt/simplify_cfg.rs
    [mir-opt] src/test/mir-opt/sroa.rs
...
TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against ... in section `.text' failed

are due to the current -Z plt=no default doesn't play well with GNU ld. I think this will be fixed when -Z plt=no default is reverted. See #106380

I try to https://sourceware.org/pipermail/binutils/2023-January/125507.html despite closed https://sourceware.org/bugzilla/show_bug.cgi?id=24784 .

@MaskRay MaskRay mentioned this pull request Jan 6, 2023
@nikic
Copy link
Contributor

nikic commented Jan 6, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 6, 2023
@bors
Copy link
Contributor

bors commented Jan 6, 2023

⌛ Trying commit 9a9ba97d5d67de51d8acc68d546d97f74bc04b92 with merge e0dceaae06dc2a3d7083c69129e9d7826eb21aae...

@bors
Copy link
Contributor

bors commented Jan 6, 2023

☀️ Try build successful - checks-actions
Build commit: e0dceaae06dc2a3d7083c69129e9d7826eb21aae (e0dceaae06dc2a3d7083c69129e9d7826eb21aae)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e0dceaae06dc2a3d7083c69129e9d7826eb21aae): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.8% [0.8%, 0.8%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.1%, -0.1%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 6, 2023
@nikic
Copy link
Contributor

nikic commented Jan 6, 2023

Minor code size improvements, no notable effects otherwise.

It sounds like we can't enable this for i386 right now, so possibly enable it only for x86_64 targets?

What kind of linker requirement does that impose (i.e. which is the earliest version of ld.bfd, ld.golf, ld.lld that reliably supports this and how old are they?)

@MaskRay
Copy link
Contributor Author

MaskRay commented Jan 6, 2023

Minor code size improvements, no notable effects otherwise.

It sounds like we can't enable this for i386 right now, so possibly enable it only for x86_64 targets?

What kind of linker requirement does that impose (i.e. which is the earliest version of ld.bfd, ld.golf, ld.lld that reliably supports this and how old are they?)

I want to avoid the configuration complexity mess. This should just be the default for both x86-32 and x86-64.
For GNU ld and gold, binutils 2.26 has the support (the commits are around 2015-10).
lld decent support for R_386_GOT32X is perhaps 2017-04 (llvm-project e7bf968). Note that rustc's default debug info cannot use lld<12 anyway (2020-11 https://reviews.llvm.org/D91291).

I believe the i386 issue will be resolved if we restore the -Z plt=yes sensible default (matching GCC and Clang).

@davidtwco
Copy link
Member

r? @nikic

@rustbot rustbot assigned nikic and unassigned davidtwco Jan 7, 2023
@nikic
Copy link
Contributor

nikic commented Jan 14, 2023

failures:
    [mir-opt] src/test/mir-opt/generator_tiny.rs
    [mir-opt] src/test/mir-opt/simplify_cfg.rs
    [mir-opt] src/test/mir-opt/sroa.rs
...
TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against ... in section `.text' failed

are due to the current -Z plt=no default doesn't play well with GNU ld. I think this will be fixed when -Z plt=no default is reverted. See #106380

Do you know whether there is a binutils bug for this? I found https://sourceware.org/bugzilla/show_bug.cgi?id=9938, but that's really old. From https://sourceware.org/pipermail/binutils/2023-January/125506.html it seems like maintainers are arguing that -fno-plt is only supported in conjunction with -mrelax-relocations=yes on x86_64 -- but it looks like at the same time -fno-plt only works with -mrelax-relocations=no on i686? Or am I misunderstanding something here?

@MaskRay
Copy link
Contributor Author

MaskRay commented Jan 14, 2023

failures:
    [mir-opt] src/test/mir-opt/generator_tiny.rs
    [mir-opt] src/test/mir-opt/simplify_cfg.rs
    [mir-opt] src/test/mir-opt/sroa.rs
...
TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against ... in section `.text' failed

are due to the current -Z plt=no default doesn't play well with GNU ld. I think this will be fixed when -Z plt=no default is reverted. See #106380

Do you know whether there is a binutils bug for this? I found https://sourceware.org/bugzilla/show_bug.cgi?id=9938, but that's really old. From https://sourceware.org/pipermail/binutils/2023-January/125506.html it seems like maintainers are arguing that -fno-plt is only supported in conjunction with -mrelax-relocations=yes on x86_64 -- but it looks like at the same time -fno-plt only works with -mrelax-relocations=no on i686? Or am I misunderstanding something here?

I don't know. https://sourceware.org/bugzilla/show_bug.cgi?id=24784 applies to x86-32 as well.

My stance is pretty clear: (a) default to -Z plt=yes, (b) enable relax_elf_relocations, (c) revert your revert of my llvm-project commit.
If Rust applies the patches in this order, there should be no issue.

@nikic
Copy link
Contributor

nikic commented Jan 14, 2023

failures:
    [mir-opt] src/test/mir-opt/generator_tiny.rs
    [mir-opt] src/test/mir-opt/simplify_cfg.rs
    [mir-opt] src/test/mir-opt/sroa.rs
...
TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against ... in section `.text' failed

are due to the current -Z plt=no default doesn't play well with GNU ld. I think this will be fixed when -Z plt=no default is reverted. See #106380

Do you know whether there is a binutils bug for this? I found https://sourceware.org/bugzilla/show_bug.cgi?id=9938, but that's really old. From https://sourceware.org/pipermail/binutils/2023-January/125506.html it seems like maintainers are arguing that -fno-plt is only supported in conjunction with -mrelax-relocations=yes on x86_64 -- but it looks like at the same time -fno-plt only works with -mrelax-relocations=no on i686? Or am I misunderstanding something here?

I don't know. https://sourceware.org/bugzilla/show_bug.cgi?id=24784 applies to x86-32 as well.

But that issue is about the -mrelax-relocations=no case, while we're testing -mrelax-relocations=yes here, so those shouldn't be related?

@apiraino
Copy link
Contributor

apiraino commented Feb 2, 2023

Switching to waiting on author as I think it was reviewed. Feel free to request a review with @rustbot ready, thanks!

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2023
@Dylan-DPC Dylan-DPC added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2023
MaskRay added a commit to MaskRay/rust that referenced this pull request Aug 22, 2023
The current old 2.25 seems to cause trouble to rust-lang#106511.

Install texinfo to dist-x86_64-freebsd/Dockerfile like other containers
to fix
```
  MAKEINFO doc/bfd.info
/binutils/binutils-2.40/missing: 81: /binutils/binutils-2.40/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 23, 2023
ci: Update FreeBSD and illumos binutils to 2.40

The current old 2.25 seems to cause trouble to rust-lang#106511.

Install texinfo to dist-x86_64-freebsd/Dockerfile like other containers
to fix
```
  MAKEINFO doc/bfd.info
/binutils/binutils-2.40/missing: 81: /binutils/binutils-2.40/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.
```

---

https://www.freshports.org/devel/binutils uses 2.40 for FreeBSD 12.x as well.

`@nikic`
@MaskRay
Copy link
Contributor Author

MaskRay commented Aug 23, 2023

Rebased after upgrading binutils for FreeBSD and Illumos

This option tells LLVM to emit relaxable relocation types
R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX/R_386_GOT32X in applicable cases. True
matches Clang's CMake default since 2020-08 [1] and latest LLVM default[2].

This also works around a GNU ld<2.41 issue[3] when using
general-dynamic/local-dynamic TLS models in `-Z plt=no` mode with latest LLVM.

[1]: llvm/llvm-project@c41a18c
[2]: llvm/llvm-project@2aedfdd
[3]: https://sourceware.org/bugzilla/show_bug.cgi?id=24784
@nikic
Copy link
Contributor

nikic commented Aug 23, 2023

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Aug 23, 2023

📌 Commit f3d8191 has been approved by nikic

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Aug 23, 2023
@bors
Copy link
Contributor

bors commented Aug 23, 2023

⌛ Testing commit f3d8191 with merge 4410868...

@bors
Copy link
Contributor

bors commented Aug 24, 2023

☀️ Test successful - checks-actions
Approved by: nikic
Pushing 4410868 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 24, 2023
@bors bors merged commit 4410868 into rust-lang:master Aug 24, 2023
12 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Aug 24, 2023
@bors bors mentioned this pull request Aug 24, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4410868): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.7% [0.5%, 0.9%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [0.5%, 0.9%] 2

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.6% [-5.5%, -0.1%] 3
Improvements ✅
(secondary)
-3.4% [-3.9%, -2.9%] 2
All ❌✅ (primary) -2.6% [-5.5%, -0.1%] 3

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.9%, -0.4%] 16
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.9%, -0.4%] 16

Bootstrap: 635.214s -> 635.876s (0.10%)
Artifact size: 347.18 MiB -> 347.03 MiB (-0.04%)

@Enselic
Copy link
Member

Enselic commented Aug 27, 2023

This commit has been confirmed to introduce a regression with the mold linker. See https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/SIGILL.20in.20build-script-build.20with.20nightly-2023-08-25/near/387506479.

nikic added a commit to nikic/rust that referenced this pull request Aug 27, 2023
This reverts commit 4410868, reversing
changes made to 249595b.

This causes linker failures with the binutils version used by
cross (rust-lang#115239), as well as miscompilations when using the mold
linker.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 27, 2023
…piler-errors

Revert relax_elf_relocations default change

This reverts commit 4410868 (rust-lang#106511).

The change caused linker failures with the binutils version used by cross (rust-lang#115239), as well as miscompilations when using the mold linker (https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/SIGILL.20in.20build-script-build.20with.20nightly-2023-08-25/near/387506479).
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 28, 2023
…ler-errors

Revert relax_elf_relocations default change

This reverts commit 4410868 (rust-lang#106511).

The change caused linker failures with the binutils version used by cross (rust-lang#115239), as well as miscompilations when using the mold linker (https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/SIGILL.20in.20build-script-build.20with.20nightly-2023-08-25/near/387506479).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

10 participants