From: Torbjörn SVENSSON Date: Thu, 29 Jan 2026 16:44:13 +0000 (+0100) Subject: diagnostics: conditionally include afunix.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ef6df1db19f8e2894d5d398ee6cb61594f81823;p=thirdparty%2Fgcc.git diagnostics: conditionally include afunix.h afunix.h was first included in MinGW 10.0.0. For earlier versions, fall back to internal definition. gcc/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac (gcc_cv_header_afunix_h): New test. (HAVE_AFUNIX_H): New AC_DEFINE. * diagnostics/sarif-sink.cc: Conditionally include afunix.h if it's available, else fall back to internal definition. Signed-off-by: Torbjörn SVENSSON --- diff --git a/gcc/config.in b/gcc/config.in index 72d2eb1dc80..2feb1d12b1b 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -355,6 +355,12 @@ #endif +/* Define if you have a working header file. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AFUNIX_H +#endif + + /* Define if AF_INET6 supported. */ #ifndef USED_FOR_TARGET #undef HAVE_AF_INET6 diff --git a/gcc/configure b/gcc/configure index a26971e0ded..b708db893d8 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10485,6 +10485,40 @@ $as_echo "#define HAVE_INTTYPES_H 1" >>confdefs.h fi +# Use only if it exists, +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for afunix.h" >&5 +$as_echo_n "checking for afunix.h... " >&6; } +if ${gcc_cv_header_afunix_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +SOCKADDR_UN addr; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + gcc_cv_header_afunix_h=yes +else + gcc_cv_header_afunix_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_afunix_h" >&5 +$as_echo "$gcc_cv_header_afunix_h" >&6; } +if test $gcc_cv_header_afunix_h = yes; then + +$as_echo "#define HAVE_AFUNIX_H 1" >>confdefs.h + +fi + # Look for the ZSTD package. ZSTD_INCLUDE= ZSTD_LIB= @@ -21954,7 +21988,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21957 "configure" +#line 21991 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -22060,7 +22094,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22063 "configure" +#line 22097 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 3f6a6a171ca..a638d7cb0b6 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1484,6 +1484,21 @@ if test $gcc_cv_header_inttypes_h = yes; then [Define if you have a working header file.]) fi +# Use only if it exists, +AC_MSG_CHECKING(for afunix.h) +AC_CACHE_VAL(gcc_cv_header_afunix_h, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[#include +#include ]], + [[SOCKADDR_UN addr;]])], + [gcc_cv_header_afunix_h=yes], + [gcc_cv_header_afunix_h=no])]) +AC_MSG_RESULT($gcc_cv_header_afunix_h) +if test $gcc_cv_header_afunix_h = yes; then + AC_DEFINE(HAVE_AFUNIX_H, 1, + [Define if you have a working header file.]) +fi + # Look for the ZSTD package. ZSTD_INCLUDE= ZSTD_LIB= diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc index 94db35ca864..8e8947aa026 100644 --- a/gcc/diagnostics/sarif-sink.cc +++ b/gcc/diagnostics/sarif-sink.cc @@ -22,8 +22,15 @@ along with GCC; see the file COPYING3. If not see #ifdef __MINGW32__ #include +#ifdef HAVE_AFUNIX_H #include #else +struct sockaddr_un { + ADDRESS_FAMILY sun_family; + char sun_path[108]; +}; +#endif +#else #include #include #endif