diff options
author | Martin Storsjö <martin@martin.st> | 2023-12-22 00:40:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-22 00:40:12 +0200 |
commit | f70b229e9643ddb895d491b62a5ec0655917f6f8 (patch) | |
tree | c316b84fc1205e80048f69f716314a265de70206 | |
parent | e64f5d6305c447b1ec3bc31128753b28f4e87f32 (diff) |
[LLDB] Define _BSD_SOURCE globally, to get optreset available in mingw's getopt.h (#76137)
We previously were defining _BSD_SOURCE right before including getopt.h.
However, on mingw-w64, getopt.h is also transitively included by
unistd.h, and unistd.h can be transitively included by many headers
(recently, by some libc++ headers).
Therefore, to be safe, we need to define _BSD_SOURCE before including
any header. Thus do this in CMake.
This fixes https://github.com/llvm/llvm-project/issues/76050.
-rw-r--r-- | lldb/CMakeLists.txt | 4 | ||||
-rw-r--r-- | lldb/include/lldb/Host/HostGetOpt.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 4a53d7ef3d0d..7844d93d78d2 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -44,6 +44,10 @@ endif() if (WIN32) add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) + if (NOT MSVC) + # _BSD_SOURCE is required for MinGW's getopt.h to define optreset + add_definitions(-D_BSD_SOURCE) + endif() endif() if (LLDB_ENABLE_PYTHON) diff --git a/lldb/include/lldb/Host/HostGetOpt.h b/lldb/include/lldb/Host/HostGetOpt.h index 746e03e1bd1e..52cfdf4dbb89 100644 --- a/lldb/include/lldb/Host/HostGetOpt.h +++ b/lldb/include/lldb/Host/HostGetOpt.h @@ -11,10 +11,6 @@ #if !defined(_MSC_VER) && !defined(__NetBSD__) -#ifdef _WIN32 -#define _BSD_SOURCE // Required so that getopt.h defines optreset -#endif - #include <getopt.h> #include <unistd.h> |