Skip to content

Added HAVE_ALLOCA for mingw64#23

Open
Jamaika1 wants to merge 1 commit into
coreutils:masterfrom
Jamaika1:patch-1
Open

Added HAVE_ALLOCA for mingw64#23
Jamaika1 wants to merge 1 commit into
coreutils:masterfrom
Jamaika1:patch-1

Conversation

@Jamaika1

Copy link
Copy Markdown

No description provided.

@pixelb

pixelb commented Jul 13, 2026

Copy link
Copy Markdown
Member

There is special alloca handling for mingw mentioned at:

gnulib/lib/alloca.in.h

Lines 35 to 43 in 1eb434d

#ifndef alloca
/* Some version of mingw have an <alloca.h> that causes trouble when
included after 'alloca' gets defined as a macro. As a workaround,
include this <alloca.h> first and define 'alloca' as a macro afterwards
if needed. */
# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
# include_next <alloca.h>
# endif
#endif

Also no other includes of alloca.h are likewise protected in gnulib?

@Jamaika1

Jamaika1 commented Jul 13, 2026

Copy link
Copy Markdown
Author

There is special alloca handling for mingw mentioned at:

I don't know anything about special allocation handling for mingw but definition below is.

#if HAVE_ALLOCA
    if (buf_neededlength < 4000 / sizeof (TCHAR_T))
      {
        buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
        buf_malloced = NULL;
      }
    else
#endif

@pixelb

pixelb commented Jul 13, 2026

Copy link
Copy Markdown
Member

a replacement alloca.h should be provided by gnulib.
Can you look into why gnulib's alloca.h is not being found for your build?
Maybe the fix in ef75da095f fixes up this issue as a side effect?

@Jamaika1

Jamaika1 commented Jul 13, 2026

Copy link
Copy Markdown
Author

There is no file in the <allaca.h> system in the downloaded msys2 ucrt library
https://ftp.nluug.nl/pub/os/windows/msys2/builds/mingw/ucrt64/mingw-w64-ucrt-x86_64-headers-13.0.0.r453.gfd36ef357-1-any.pkg.tar.zst
/* Some version of mingw have an <alloca.h> that causes trouble when
included after 'alloca' gets defined as a macro. As a workaround,
include this <alloca.h> first and define 'alloca' as a macro afterwards
if needed. */

In file included from vasnprintf.c:78:
alloca.h:41:17: fatal error: alloca.h: No such file or directory
   41 | #  include_next <alloca.h>
      |                 ^~~~~~~~~~

.... but I use gettext. I manage to create files.

#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# ifdef _MSC_VER
#  include <malloc.h>
#  define alloca _alloca
# else
#  if defined HAVE_ALLOCA_H || defined _LIBC
#   include <alloca.h>
#  else

@pixelb

pixelb commented Jul 13, 2026

Copy link
Copy Markdown
Member

what does your config.log say about things after you run ./configure ?
It should say something like "checking for working alloca.h" ...
Note it seems to be finding an alloca.h somewhere during the configure,
as HAVE_ALLOCA_H is used as a guard around your problematic include_next line.
So perhaps you could dig into why HAVE_ALLOCA_H is being defined, but then can't be found during the build phase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants