[PATCH] D94707: [Flang] Fix compilation on MinGW-w64

مهدي شينون (Mehdi Chinoune) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 04:58:00 PST 2021


ChinouneMehdi added a comment.

In D94707#2500607 <https://reviews.llvm.org/D94707#2500607>, @mstorsjo wrote:

> In D94707#2500579 <https://reviews.llvm.org/D94707#2500579>, @ChinouneMehdi wrote:
>
>> In D94707#2500131 <https://reviews.llvm.org/D94707#2500131>, @mstorsjo wrote:
>>
>>> What part of the code in the ifdefs is msvc-specific? On a first glance, it looks like regular win32 code that should work fine on mingw. What's the error that it tries to fix?
>>
>>
>>
>>   D:/dev/llvm-project/flang/runtime/file.cpp:48:57: error: use of undeclared identifier '_S_IREAD'
>>     int fd{::_open(tempFileName, _O_CREAT | _O_TEMPORARY, _S_IREAD | _S_IWRITE)};
>>                                                           ^
>>   D:/dev/llvm-project/flang/runtime/file.cpp:48:68: error: use of undeclared identifier '_S_IWRITE'
>>     int fd{::_open(tempFileName, _O_CREAT | _O_TEMPORARY, _S_IREAD | _S_IWRITE)};
>
> The problem here is just that the right header for the `_S_IREAD` and `_S_IWRITE` constants haven't been included. Include `sys/stat.h` (which exists in both MSVC and mingw environments), i.e. move that include out of the ifdef/else, and this should work for mingw too.

This is the easiest fix I could find.
You are free to make modifications on my patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94707/new/

https://reviews.llvm.org/D94707



More information about the llvm-commits mailing list