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

Windows x64 no-std build broken with errors related to compiler-builtins #118559

Closed
byeongkeunahn opened this issue Dec 3, 2023 · 1 comment · Fixed by #118568
Closed

Windows x64 no-std build broken with errors related to compiler-builtins #118559

byeongkeunahn opened this issue Dec 3, 2023 · 1 comment · Fixed by #118568
Assignees
Labels
C-bug Category: This is a bug.

Comments

@byeongkeunahn
Copy link

byeongkeunahn commented Dec 3, 2023

Hello, the nightly update on 2023-12-02 seems to break the continuous integration (CI) on the basm-rs project on Windows x64 builds (nightly-x86_64-pc-windows-msvc). The Linux x86/x64 builds and the wasm32 builds continue to run fine. The recent commits on the repo is Linux-only and not related to Windows; thus the Windows build should not be affected. It seems like the recently merged pull request 113923 may be relevant.

I expected to see this happen: the basm-rs CI build should continue to pass.

Instead, this happened: the basm-rs CI build fails with a linker error related to compiler-builtins.

Meta

I tried to localize the error with cargo-bisect-rustc on Windows 11 x64 with the msvc toolchain as follows:

git clone https://github.com/byeongkeunahn/basm-rs.git
cargo-bisect-rustc -vv --start=2023-12-01 --end=2023-12-03

which results in the following analysis report:

searched nightlies: from nightly-2023-12-01 to nightly-2023-12-03
regressed nightly: nightly-2023-12-02
searched commit range: 87e1447...8c2b577
regressed commit: 8c2b577

bisected with cargo-bisect-rustc v0.6.7

Host triple: x86_64-pc-windows-msvc
Reproduce with:

cargo bisect-rustc --start=2023-12-01 --end=2023-12-03

The actual error message is about unresolved external symbols.

  = note: symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem4bcmp17hdd43ed361972df2aE
          symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem6memcmp17h4000bdfb54398fd7E
          symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem6memcpy17h76ab47a482abb17aE
          symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem6memset17hddee021ef3511addE
          symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem6strlen17h8221a76238dd80f9E
          symbols.o : error LNK2001: unresolved external symbol _ZN17compiler_builtins3mem7memmove17h9a354b96e96d4c1eE
          ..(omitted)\target-bisector-ci-8c2b57721728233e074db69d93517614de338055-x86_64-pc-windows-msvc\x86_64-pc-windows-msvc\debug\deps\basm.exe : fatal error LNK1120: 6 unresolved externals

Thanks in advance!

@byeongkeunahn byeongkeunahn added the C-bug Category: This is a bug. label Dec 3, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2023
@byeongkeunahn byeongkeunahn changed the title L Windows x64 no-std build broken with errors related to compiler-builtins Dec 3, 2023
@DianQK
Copy link
Member

DianQK commented Dec 3, 2023

@rustbot claim

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 5, 2023
Avoid adding builtin functions to `symbols.o`

We found performance regressions in rust-lang#113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not.

I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791.
The PR removes builtin functions.

Note that under LTO, ld still preserves these symbols. (lld will still remove them.)

The first commit also fixes rust-lang#118559. But I think the second commit also makes sense.
@bors bors closed this as completed in 503e129 Dec 7, 2023
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants