From: Evgeny Karpov <[email protected]>

The commit "diagnostics: add experimental SARIF JSON-RPC notifications
for IDEs [PR115970]"

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8a155c170b443e332b3db4922f0f0d588a17604f

introduces a regression when building the toolchain for the
aarch64-w64-mingw32 host, at least. It is most likely the same for
*-*-mingw32 targets.

This patch resolves the issue when using sockets for SARIF JSON-RPC
notifications on MinGW host and adds the required socket library to the
host file for *-*-mingw.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r16-5362-g5ce13174c0cf82.

Signed-off-by: Evgeny Karpov <[email protected]>

gcc/ChangeLog:
        PR diagnostics/122666
        * config/i386/x-mingw32 (LIBS): Add -lws2_32
        * diagnostics/sarif-sink.cc: Move sockets includes to before
        config.h and support __MINGW32__.

Signed-off-by: David Malcolm <[email protected]>
---
 gcc/config/i386/x-mingw32     | 3 +++
 gcc/diagnostics/sarif-sink.cc | 9 +++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/x-mingw32 b/gcc/config/i386/x-mingw32
index 8900bfccb6cbe..5ebe0882f4d88 100644
--- a/gcc/config/i386/x-mingw32
+++ b/gcc/config/i386/x-mingw32
@@ -21,6 +21,9 @@
 #
 local_includedir=$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 
's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include
 
+# Add Windows socket library.
+LIBS += -lws2_32
+
 # On MinGW, we use "%IA64d" to print 64-bit integers, and the format-checking
 # code does not handle that, so we have to disable checking here.
 WERROR_FLAGS += -Wno-format
diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc
index 0595074829f5b..01de2297b851f 100644
--- a/gcc/diagnostics/sarif-sink.cc
+++ b/gcc/diagnostics/sarif-sink.cc
@@ -18,6 +18,13 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#ifdef __MINGW32__
+#include <winsock2.h>
+#include <afunix.h>
+#else
+#include <sys/un.h>
+#include <sys/socket.h>
+#endif
 
 #include "config.h"
 #define INCLUDE_LIST
@@ -55,8 +62,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "backtrace.h"
 #include "xml.h"
 #include "intl.h"
-#include <sys/un.h>
-#include <sys/socket.h>
 
 namespace diagnostics {
 
-- 
2.26.3

Reply via email to