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

Solve the pinned memchr problem #127890

Open
ehuss opened this issue Jul 18, 2024 · 0 comments
Open

Solve the pinned memchr problem #127890

ehuss opened this issue Jul 18, 2024 · 0 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jul 18, 2024

Ever since #120454, the memchr crate has been pinned at 2.5.0. This is causing problems when trying to update things which depend on a newer version (like regex). This issue is to track trying to get that problem resolved.

The dependency is pinned because the x86_64-pc-windows-gnu target fails some tests with the 2.6.0 release. These tests fail when linking with "undefined reference" symbol errors in memchr (which ends up in the standard library via the object dependency for backtraces).

The errors look like:

...ld.exe: ...-cgu.0.rcgu.o.rcgu.o:std.33d504e26fbb75:(.text+0x66963): undefined reference to `__imp__ZN6memchr4arch6x86_646memchr10memchr_raw2FN17h0aa7d2dff3bebec3E'

The underlying problem isn't with memchr. It's just that version 2.6 is just triggering a bug that has been around for a long while due to some refactoring of the code.

Reproduction

  1. Edit rustc_ast/Cargo.toml and remove the = on memchr.

  2. cargo update -p memchr

  3. ./x test tests/ui --build=x86_64-pc-windows-msvc --host=x86_64-pc-windows-gnu

This currently fails these tests:

    [ui] tests\ui\extern\issue-64655-extern-rust-must-allow-unwind.rs#thin0
    [ui] tests\ui\extern\issue-64655-extern-rust-must-allow-unwind.rs#thin1
    [ui] tests\ui\extern\issue-64655-allow-unwind-when-calling-panic-directly.rs#thin
    [ui] tests\ui\extern\issue-64655-extern-rust-must-allow-unwind.rs#thin2
    [ui] tests\ui\extern\issue-64655-extern-rust-must-allow-unwind.rs#thin3
    [ui] tests\ui\lto\all-crates.rs
    [ui] tests\ui\lto\lto-thin-rustc-loads-linker-plugin.rs
    [ui] tests\ui\lto\thin-lto-inlines2.rs

Theories

This is likely some interaction with Thin LTO and inline.

A theory is that this is a bug in ld.bfd (just based on the evidence that it works with lld). However, it may also be possible that rustc is generating things in an incorrect way, and lld is just more tolerant of it.

Note that memchr is doing some fancy things with function pointers (https://github.com/BurntSushi/memchr/blob/2.7.4/src/arch/x86_64/memchr.rs#L58-L160) with inline(always) functions.

Notes

Possible solutions

  • Demote *-pc-windows-gnu and replace with *-pc-windows-gnullvm. To the best of our understanding, lld does not have this problem.
  • Report this to the binutils maintainers to see if it is possible to fix it in ld.bfd.
  • Is it possible to switch to gold or lld?
  • Disable the tests on *-pc-windows-gnu until someone can fix the problem. This means any user using thin-lto will likely run into the same problem. Perhaps this will motivate one of them to try to fix it? 😉

Non-solutions

  • We could change the inline attribute in memchr for windows-gnu, but nobody wants to do that. It's not memchr's fault, and we don't want to paper over the real problem.
@ehuss ehuss added the O-windows-gnu Toolchain: GNU, Operating system: Windows label Jul 18, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 18, 2024
@Noratrieb Noratrieb added A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 18, 2024
tgross35 added a commit to tgross35/rust that referenced this issue Aug 26, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 1, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 1, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 3, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 11, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 24, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 24, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 24, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 24, 2024
Pin memchr to 2.5.0 in the library rather than rustc_ast

The latest versions of `memchr` experience LTO-related issues when compiling for windows-gnu [1], so needs to be pinned. The issue is present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`, pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]

try-job: x86_64-mingw
try-job: x86_64-msvc
tgross35 added a commit to tgross35/rust that referenced this issue Sep 24, 2024
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]
tgross35 added a commit to tgross35/rust that referenced this issue Sep 24, 2024
…eb,Mark-Simulacrum

Pin memchr to 2.5.0 in the library rather than rustc_ast

The latest versions of `memchr` experience LTO-related issues when compiling for windows-gnu [1], so needs to be pinned. The issue is present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`, pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]

try-job: x86_64-mingw
try-job: x86_64-msvc
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 25, 2024
Rollup merge of rust-lang#130788 - tgross35:memchr-pinning, r=Noratrieb,Mark-Simulacrum

Pin memchr to 2.5.0 in the library rather than rustc_ast

The latest versions of `memchr` experience LTO-related issues when compiling for windows-gnu [1], so needs to be pinned. The issue is present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`, pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow non-library crates to upgrade to the latest version.

Link: rust-lang#127890 [1]

try-job: x86_64-mingw
try-job: x86_64-msvc
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 25, 2024
…imulacrum

Pin memchr to 2.5.0 in the library rather than rustc_ast

The latest versions of `memchr` experience LTO-related issues when compiling for windows-gnu [1], so needs to be pinned. The issue is present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`, pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow non-library crates to upgrade to the latest version.

Link: rust-lang/rust#127890 [1]

try-job: x86_64-mingw
try-job: x86_64-msvc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows 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

3 participants