Skip to content

Commit 94609ae

Browse files
authored
[Support] Remove an unnecessary include (llvm#123182)
In 1e53f95, the FileSystem.h header was changed to always include <sys/stat.h>, while it previously only was included if HAVE_SYS_STAT_H was defined. HAVE_SYS_STAT_H was defined in llvm/Config/config.h, while FileSystem.h only included llvm/Config/llvm-config.h. Thus, <sys/stat.h> was only being included in some but not all cases. The change to always include <sys/stat.h> broke compiling LLDB for MinGW targets, because the MinGW <sys/stat.h> header adds an "#define fstat _fstat64" define, which breaks LLDBs use of a struct with a member named "fstat". Remove the include of <sys/stat.h> in FileSystem.h, as it seems to not be necessary in practice, fixing compilation of LLDB for MinGW targets. Change one instance of defined(_MSC_VER) into defined(_WIN32) in ErrorHandling.cpp to get <io.h> included; this source file did include config.h before transitively including FileSystem.h. The include of <sys/stat.h> in FileSystem.h would bring in <io.h> (needed for ::write()), explaining why this ifdef didn't need to cover MinGW before.
1 parent 99a562b commit 94609ae

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

llvm/include/llvm/Support/FileSystem.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
#include <system_error>
4545
#include <vector>
4646

47-
#include <sys/stat.h>
48-
4947
namespace llvm {
5048
namespace sys {
5149
namespace fs {

llvm/lib/Support/ErrorHandling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#if defined(HAVE_UNISTD_H)
3434
# include <unistd.h>
3535
#endif
36-
#if defined(_MSC_VER)
36+
#if defined(_WIN32)
3737
# include <io.h>
3838
# include <fcntl.h>
3939
#endif

0 commit comments

Comments
 (0)