This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Enabled emulated TLS on WOA.
ClosedPublic

Authored by martell on Apr 30 2017, 7:00 AM.

Details

Summary

Thanks to recent work from @marsupial here rL301350
We can now bootstrap mingw x86 and x64 with clang without importing winpthreads headers. .i.e pthread.h

I never enabled emutls on WOA because of this extra step previously.
@mstorsjo would enabling this cause any issues with your work?

I also changed Windows.h to windows.h to support mingw from file case sensitive systems.
MSVC doesn't care much about this because it is run from windows.

I added Saleem also because he cares about cross compiling to windows and can give another perspective on the case sensitivity.

Diff Detail

Repository
rL LLVM

Event Timeline

martell created this revision.Apr 30 2017, 7:00 AM
martell updated this revision to Diff 97230.Apr 30 2017, 7:01 AM

Added diff context for readability

Doing this on just the MinGW build seems reasonable. Most of the library shouldn't be needed for Windows.

lib/builtins/emutls.c
101 ↗(On Diff #97230)

The file is Windows.h in the SDK, so why are you changing it to the lower case?

martell added a comment.EditedMay 1 2017, 6:51 AM

The file is Windows.h in the SDK, so why are you changing it to the lower case?

Mingw headers do not follow the uppercase naming conventions of the windows sdk.
Projects that are typically build from not windows platforms follow the mingw convention when supporting both msvc and mingw.
Example https://github.com/videolan/vlc/blob/master/modules/video_output/win32/common.c#L38

The reason for me changing to lowercase is that MSVC is case insensitive on windows so it should not affect the target, while fixing cross building mingw at the same time.
The only downside to using lowercase W is someone would be restricted if they tried to use the MSVC SDK from a non windows machine that is case sensitive.

@chapuni tends to deal with all mingw on linux stuff from reading here https://reviews.llvm.org/D30107

mstorsjo edited edge metadata.May 1 2017, 12:15 PM

The file is Windows.h in the SDK, so why are you changing it to the lower case?

Mingw headers do not follow the uppercase naming conventions of the windows sdk.
Projects that are typically build from not windows platforms follow the mingw convention when supporting both msvc and mingw.
Example https://github.com/videolan/vlc/blob/master/modules/video_output/win32/common.c#L38

The reason for me changing to lowercase is that MSVC is case insensitive on windows so it should not affect the target, while fixing cross building mingw at the same time.
The only downside to using lowercase W is someone would be restricted if they tried to use the MSVC SDK from a non windows machine that is case sensitive.

FWIW, the official Windows SDK isn't internally consistent with this either - e.g. files are included with a different variant of upper/lowercase than the actual filenames.

I'm using the windows SDK both with MSVC (run via wine) and with clang from linux on case sensitive filesystems, and to make this work properly, I normally end up lowercasing all the filenames (matching the mingw headers), despite starting out with intentions to modify it as little as possible.

@mstorsjo would enabling this cause any issues with your work?

I haven't read up on all what this entails, but... When building for WoA in MSVC mode, I don't use compiler-rt/builtins at all, since it all should use the helper functions that MSVC uses. So this particular change shouldn't hurt me at all.

The projects I test on WoA doesn't use TLS at all either so I'm not sure if it is broken (or gets broken by any recent change) either though.

@mstorsjo Yeah, clang supports proper TLS on Windows on ARM. This is only needed if you are explicitly going out of your way to use the emulated TLS (via -femulated-tls). Otherwise, this code path shouldn't be hit.

I have a local patch (well, it's either on reviews.llvm.org or on the mailing list as well) that emulates the case insensitivity, but that is expensive, and I'd rather keep the hit to the actual file when possible. How about adding a guard around the incorrect case (yes, Microsoft doesn't get the case right, but the SDK provides the file with the capital name, so that should be the official version IMO).

chapuni edited edge metadata.May 1 2017, 5:55 PM

I have a local patch (well, it's either on reviews.llvm.org or on the mailing list as well) that emulates the case insensitivity, but that is expensive, and I'd rather keep the hit to the actual file when possible. How about adding a guard around the incorrect case (yes, Microsoft doesn't get the case right, but the SDK provides the file with the capital name, so that should be the official version IMO).

I really wish you to stop following its capital file names. <windows.h> should be fine.

martell added a comment.EditedMay 1 2017, 6:20 PM

I have a local patch (well, it's either on reviews.llvm.org or on the mailing list as well) that emulates the case insensitivity, but that is expensive, and I'd rather keep the hit to the actual file when possible. How about adding a guard around the incorrect case (yes, Microsoft doesn't get the case right, but the SDK provides the file with the capital name, so that should be the official version IMO).

Adding a Guard for having an upper and lower case windows.h include would be very ugly and is not done anywhere else in the codebase.
Here is a reference to another location where windows.h is included in LLVM.
https://github.com/llvm-mirror/llvm/blob/master/lib/Support/Windows/WindowsSupport.h#L47

Building for mingw i686 and x86_64 from linux is broken for me atm without this patch.
I just need the go ahead to push to fix that :)

<windows.h> should be fine.

Oops, I missed @chapuni's reply.
Thanks

This revision was automatically updated to reflect the committed changes.