-
Notifications
You must be signed in to change notification settings - Fork 521
Stop passing an invalid target to llvm-mingw
's cross-compilation wrappers
#1495
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
Open
AlexTMjugador
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
AlexTMjugador:fix/llvm-mingw-target
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more robust way of testing?
I.e. checking version etc?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I agree that a more robust detection method could be nice.
After taking a closer look at the
llvm-mingw
repository, it appears that this cross-compilation toolchain has been setting a target since its very first tagged release,20181017
.For Unix host platforms, the wrapper script has consistently been symlinked from
x86_64-w64-mingw32-clang
and similar names, so the toolchain has been quite consistent in this regard. As a result, checking its version doesn't seem necessary.Interestingly, running
x86_64-w64-mingw32-clang -v
on any version of the toolchain reports the default target asx86_64-w64-windows-gnu
. This doesn't exactly match eitherx86_64-pc-windows-gnu
orx86_64-w64-mingw32
, but it still seems to work just fine. (Why are LLVM's target names so inconsistent? 😅 I don't think I'd want to rely on the reported target for any important decisions oncc-rs
...)That said, aside from the target string oddities, this is a fairly standard LLVM toolchain with varying standard LLVM versions that aren't particularly distinct from stock LLVM. I don't think it's worth running any command with potentially brittle output or implement any extra complexity to determine whether to skip passing a target parameter in this case.
Instead, I figured we could check whether the compiler path is a symlink to a
clang-target-wrapper.sh
script. If and only if it is, we returntrue
in this function. This approach should have a negligible chance of false positives, and in the unforeseen case that something goes wrong, users still have a fallback option other than fiddling with compiler flags: modifying the wrapper script directly.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about something else pretending to be it...or the script gets renamed in the future
cc @madsmtm @ChrisDenton do you think there's a more robust way?