Author: Martin Storsjö Date: 2023-12-22T00:40:12+02:00 New Revision: f70b229e9643ddb895d491b62a5ec0655917f6f8
URL: https://github.com/llvm/llvm-project/commit/f70b229e9643ddb895d491b62a5ec0655917f6f8 DIFF: https://github.com/llvm/llvm-project/commit/f70b229e9643ddb895d491b62a5ec0655917f6f8.diff LOG: [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. Added: Modified: lldb/CMakeLists.txt lldb/include/lldb/Host/HostGetOpt.h Removed: ################################################################################ diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 4a53d7ef3d0da0..7844d93d78d29a 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 746e03e1bd1ee2..52cfdf4dbb89c2 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> _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits