On Fri, 2026-01-30 at 15:06 +0100, Torbjörn SVENSSON wrote:

Hi Torbjörn; sorry about the breakage.

> Changes since v1:
> 
> - Replaced check for MinGW 10.0.0 or above with a configure-magic to
>   check if afunix.h is available or not.
> 
> In https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122666#c2, it's
> mentioned that
> the block was placed above the include of config.h, but I see no
> reason why it
> have to be, as long as it's above the include of system.h.

Sangamesh fixed the placement of config.h in that file yesterday in
r16-7139-gbc10a49c37501e; please can you rebase and retry your patch?

Thanks
Dave

> 
> Ok for trunk?


> 
> --
> 
> afunix.h was first included in MinGW 10.0.0.  For earlier versions,
> fall
> back to internal definition.
> 
> gcc/ChangeLog:
> 
>       * diagnostics/sarif-sink.cc: Conditionally include afunix.h
>         if it's available, else fall back to internal definition.
> 
> Signed-off-by: Torbjörn SVENSSON <[email protected]>
> ---
>  gcc/config.in                 |  6 ++++++
>  gcc/configure                 | 38
> +++++++++++++++++++++++++++++++++--
>  gcc/configure.ac              | 15 ++++++++++++++
>  gcc/diagnostics/sarif-sink.cc | 10 ++++++++-
>  4 files changed, 66 insertions(+), 3 deletions(-)
> 
> 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 <afunix.h> 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 40d40cb8daa..03f4d011ed6 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -10485,6 +10485,40 @@ $as_echo "#define HAVE_INTTYPES_H 1"
> >>confdefs.h
>  
>  fi
>  
> +# Use <afunix.h> 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 <winsock2.h>
> +#include <afunix.h>
> +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=
> @@ -21939,7 +21973,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 21942 "configure"
> +#line 21976 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -22045,7 +22079,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 22048 "configure"
> +#line 22082 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 85272df5a24..15f18b01dd8 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 <inttypes.h> header file.])
>  fi
>  
> +# Use <afunix.h> 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 <winsock2.h>
> +#include <afunix.h>]],
> +  [[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 <afunix.h> 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 78743df7f1d..8e8947aa026 100644
> --- a/gcc/diagnostics/sarif-sink.cc
> +++ b/gcc/diagnostics/sarif-sink.cc
> @@ -18,15 +18,23 @@ 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/>.  */
>  
> +#include "config.h"
> +
>  #ifdef __MINGW32__
>  #include <winsock2.h>
> +#ifdef HAVE_AFUNIX_H
>  #include <afunix.h>
>  #else
> +struct sockaddr_un {
> +  ADDRESS_FAMILY sun_family;
> +  char sun_path[108];
> +};
> +#endif
> +#else
>  #include <sys/un.h>
>  #include <sys/socket.h>
>  #endif
>  
> -#include "config.h"
>  #define INCLUDE_LIST
>  #define INCLUDE_MAP
>  #define INCLUDE_STRING

Reply via email to