This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add support for a MinGW AArch64 target
ClosedPublic

Authored by mstorsjo on Aug 5 2017, 1:01 PM.

Details

Summary

The machine name arm64pe passed to the linker is completely made up; gnu binutils doesn't (afaik) support this, so it only has to match what the corresponding (not yet merged) lld linker supports - similarly to the existing thumb2pe machine name.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 5 2017, 1:01 PM
compnerd added inline comments.Aug 5 2017, 9:37 PM
lib/Driver/ToolChains/MinGW.cpp
122–131 ↗(On Diff #109890)

Can you use a switch here instead?

mstorsjo added inline comments.Aug 6 2017, 4:09 AM
lib/Driver/ToolChains/MinGW.cpp
122–131 ↗(On Diff #109890)

Sure, I can change that.

What do you think about the llvm_unreachable part btw? There's nothing stopping a user from trigger that with e.g. -target mips-windows-gnu, and in release builds, such a default: llvm_unreachable() case usually ends up as just running one of the existing cases. Should it be changed into a real runtime error that isn't optimized out from release builds?

martell added inline comments.Aug 6 2017, 5:56 AM
lib/Driver/ToolChains/MinGW.cpp
129 ↗(On Diff #109890)

I believe the reason I used thumb2pe for the arm triple is because MS gave us a watered down thumb environment.
If I remember correctly there was also an armce environment in binutils called thumbpe because it was thumb 1 mode.
Anyway, I assume aarch64 on windows is a fully fledged arm64 environment that doesn't use thumb mode over arm64?
I know we don't have any real sdk for this but are you able to tell from link.exe martin?
On arm the branch for a dll call would always set the bit for thumb mode in the instruction.
Although when I think about it arm64pe is probably the most suitable name anyway because we already use thumb2pe

mstorsjo updated this revision to Diff 109916.Aug 6 2017, 6:11 AM

Updated to use a switch, added a mapping of a missed case of thumb while reformatting the if to a switch.

mstorsjo added inline comments.Aug 6 2017, 6:15 AM
lib/Driver/ToolChains/MinGW.cpp
129 ↗(On Diff #109890)

There's no thumb mode at all in 64 bit mode (yet at least), so naming it thumb* wouldn't make sense. Modelling the previous name after the old thumbpe makes sense though.

martell added inline comments.Aug 6 2017, 6:31 AM
lib/Driver/ToolChains/MinGW.cpp
129 ↗(On Diff #109890)

Great, thanks. Just wanted to clarify because we never had a discussion about the naming.
LGTM

martell added inline comments.Aug 6 2017, 7:35 AM
lib/Driver/ToolChains/MinGW.cpp
130 ↗(On Diff #109916)

I believe this was left incase someone wanted to do windows ce in future.
Can you add a todo like in CrossWindows.cpp in this case
// FIXME: this is incorrect for WinCE
or if we don't care about WinCE anymore just remove the TODO from CrossWindows?

mstorsjo added inline comments.Aug 6 2017, 8:09 AM
lib/Driver/ToolChains/MinGW.cpp
130 ↗(On Diff #109916)

Sure, I can add a todo. I wanted to add it, since technically, the modern windows on arm stuff is thumb, we should handle it if the user uses the triple thumbv7-windows-gnu (iirc, some of the tests do).

mstorsjo updated this revision to Diff 109935.Aug 6 2017, 12:49 PM

Added a fixme comment about this being incorrect for WinCE.

martell accepted this revision.Aug 9 2017, 4:36 AM

LGTM

This revision is now accepted and ready to land.Aug 9 2017, 4:36 AM

@compnerd - are you ok with this one as well?

compnerd accepted this revision.Aug 13 2017, 11:13 AM

Yeah, I think that this is okay.

This revision was automatically updated to reflect the committed changes.