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

[Triple] Ignore the vendor field for MinGW, wrt LTO/IR compatibility #122801

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

mstorsjo
Copy link
Member

For MinGW environments, the regular C/C++ toolchains usually use "w64" for the vendor field in triples, while Rust toolchains usually use "pc" in the vendor field.

The differences in the vendor field have no bearing on whether the IR is compatible on this platform. (This probably goes for most other OSes as well, but limiting the scope of the change to the specific case.)

Add a unit test for the isCompatibleWith, including some existing test cases found in existing tests.

For MinGW environments, the regular C/C++ toolchains usually use
"w64" for the vendor field in triples, while Rust toolchains usually
use "pc" in the vendor field.

The differences in the vendor field have no bearing on whether the
IR is compatible on this platform. (This probably goes for most other
OSes as well, but limiting the scope of the change to the specific case.)

Add a unit test for the isCompatibleWith, including some existing
test cases found in existing tests.
@mstorsjo mstorsjo requested review from MaskRay, fhahn and cjacek January 13, 2025 21:47
@mstorsjo
Copy link
Member Author

This fixes an issue brought up in mstorsjo/llvm-mingw#469 (comment); CC @Andarwinux @mati865.

Copy link
Contributor

@mati865 mati865 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with question addressed

Comment on lines +2027 to +2028
// On MinGW, C code is usually built with a "w64" vendor, while Rust
// often uses a "pc" vendor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is uwp-windows-gnu compatible the other two mentioned variants? I think so but wanted to double-check.
Not sure if it's even a real triple in LLVM. Rust has it, but the GNU env is unmaintained: https://doc.rust-lang.org/rustc/platform-support.html

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for pointing it out!

On an LTO/IR level, there's nothing there that would be incompatible. Of course, on functional level, code that doesn't target UWP may or may not work correct if code is linked in that isn't written with a UWP target in mind (but this issue is the same even if not involving LTO).

Also, thanks for pointing out the Rust use of uwp for the vendor field here; going that way would help using Clang config files for the UWP targets in llvm-mingw. (Currently we use the environment name mingw32uwp, but that gets normalized into the same windows-gnu as non-UWP.)

Not sure if it's even a real triple in LLVM.

The vendor field is pretty much freeform and not really used by anything as far as I'm aware. Sure, there are a couple of known ones and an enum for them, but neither w64 nor uwp map to any of the known enum values: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/llvm/lib/TargetParser/Triple.cpp#L627-L644

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't sure if there are any differences other than headers and libraries. We're good then.

@mstorsjo mstorsjo merged commit a829eba into llvm:main Jan 14, 2025
9 checks passed
@mstorsjo mstorsjo deleted the mingw-rust-lto branch January 14, 2025 22:18
paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 16, 2025
…lvm#122801)

For MinGW environments, the regular C/C++ toolchains usually use "w64"
for the vendor field in triples, while Rust toolchains usually use "pc"
in the vendor field.

The differences in the vendor field have no bearing on whether the IR is
compatible on this platform. (This probably goes for most other OSes as
well, but limiting the scope of the change to the specific case.)

Add a unit test for the isCompatibleWith, including some existing test
cases found in existing tests.
DKLoehr pushed a commit to DKLoehr/llvm-project that referenced this pull request Jan 17, 2025
…lvm#122801)

For MinGW environments, the regular C/C++ toolchains usually use "w64"
for the vendor field in triples, while Rust toolchains usually use "pc"
in the vendor field.

The differences in the vendor field have no bearing on whether the IR is
compatible on this platform. (This probably goes for most other OSes as
well, but limiting the scope of the change to the specific case.)

Add a unit test for the isCompatibleWith, including some existing test
cases found in existing tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants