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

Fix linking for symbols starting with ? on i686-pc-windows-msvc #130808

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

checkraisefold
Copy link

When using the export_name attribute to specifically export a symbol beginning with a question mark on the i686-pc-windows-msvc target, that symbol will fail to link and throw a linker error 100% of the time.
Issue writeup.

Closes #44282

I'm not sure if this is a proper solution, but LLVM does the same check which causes this issue, and is applied to all 32- and 64-bit Windows COFF objects (maybe the same patch should be applied for 64 bit windows as well then?). I am more unsure of whether this is the proper place for such a solution (and if the exact conditions of is_like_windows are proper for this usecase), or if the underscore should be stripped elsewhere, but it seems like the most correct place.

I'm also unsure if there are any backwards compatibility ramifications here. There shouldn't be, because binaries with exported symbols starting with ? for this target failed to link because of this issue anyway, but still.

@rustbot
Copy link
Collaborator

rustbot commented Sep 25, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 25, 2024
@checkraisefold
Copy link
Author

Just tested this patch with rust-lld; the original issue exists with lld being used as well, not just MSVC's linker, and is fixed by this patch.

@jieyouxu jieyouxu added O-windows-msvc Toolchain: MSVC, Operating system: Windows A-linkage Area: linking into static, shared libraries and binaries labels Sep 25, 2024
@jieyouxu
Copy link
Member

cc @bjorn3, @petrochenkov and @ChrisDenton, in case anyone has any clues about this 😅

@jieyouxu
Copy link
Member

Rerolling a reviewer. r? compiler

@rustbot rustbot assigned nnethercote and unassigned TaKO8Ki Nov 16, 2024
@nnethercote nnethercote added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2024
@alex-semenyuk
Copy link
Member

@checkraisefold
From wg-triage. Could you please take a look question above

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Dec 30, 2024
@rustbot

This comment has been minimized.

@checkraisefold checkraisefold force-pushed the fix-questionmark-linking branch from a79b6c2 to 2ec1dce Compare December 30, 2024 05:44
@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Dec 30, 2024
@checkraisefold checkraisefold force-pushed the fix-questionmark-linking branch from 2ec1dce to 6994ee3 Compare December 30, 2024 05:47
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Dec 31, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 31, 2024

This PR modifies tests/run-make/. If this PR is trying to port a Makefile
run-make test to use rmake.rs, please update the
run-make port tracking issue
so we can track our progress. You can either modify the tracking issue
directly, or you can comment on the tracking issue and link this PR.

cc @jieyouxu

@checkraisefold
Copy link
Author

checkraisefold commented Dec 31, 2024

Apologies for the time it took to get to this - aside from being busy, for a relative Rust newbie (and contributing to the compiler, lol) especially the testing harness is very intimidating and it takes a while to iterate on my beautiful Ryzen 5 3600.

I was hoping to be able to fit this into a codegen or assembly test with some FileCheck annotations, but the technical difficulties of that are very annoying compared to a general run-make test - the compilation fails without this fix, which I tested, and it's a whole lot easier to implement.

@rust-log-analyzer

This comment has been minimized.

@checkraisefold checkraisefold force-pushed the fix-questionmark-linking branch from c84f1b7 to a4c628c Compare December 31, 2024 08:33
@checkraisefold
Copy link
Author

checkraisefold commented Dec 31, 2024

Seeing as the test no longer sucks-
@rustbot review

Additionally, run-make label can be removed

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 31, 2024
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2024
@jieyouxu jieyouxu removed the A-run-make Area: port run-make Makefiles to rmake.rs label Dec 31, 2024
@jieyouxu
Copy link
Member

r? compiler (assigned reviewer is on holiday)

@rustbot rustbot assigned cjgillot and unassigned nnethercote Dec 31, 2024
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 O-windows-msvc Toolchain: MSVC, Operating system: Windows 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

export_name works for msvc x86_64 toolchain, but not i686
8 participants