Hello,

I found a portability issue while building GNU Make 4.4.90 from the development 
tree natively for Windows ARM64 using Visual Studio 2022's MSVC ARM64 toolchain.

The Windows build script does not currently provide an ARM64 option, but adding:

if "%1" == "--arm64" goto SetARM64
and:

:SetARM64
set ARCH=arm64
echo - Building ARM64 GNU Make
shift
goto ParseSW
allows build_w32.bat --arm64 to select the native HostARM64\arm64\cl.exe 
compiler successfully.

The resulting build then fails in arscan.c with:

stdint.h(45): error C2632: '__int64' followed by 'long' is illegal
stdint.h(46): error C2632: '__int64' followed by 'long' is illegal
The cause appears to be in src/config.h.W32. The definitions of HAVE_INTTYPES_H 
and HAVE_STDINT_H are currently guarded by __MINGW32__:

#ifdef __MINGW32__
#define HAVE_INTTYPES_H 1
#endif

...

#ifdef __MINGW32__
#define HAVE_STDINT_H 1
#endif
When compiling with MSVC, __MINGW32__ is not defined, even though MSVC supplies 
both headers. Consequently both feature macros remain undefined, and this 
fallback later becomes active:

#if !HAVE_STDINT_H && !HAVE_INTTYPES_H
#define intmax_t long long
#define uintmax_t unsigned long long
#endif
Those are macros rather than typedefs, and they interfere with Microsoft's 
<stdint.h>:

typedef long long intmax_t;
typedef unsigned long long uintmax_t;
which are preprocessed into invalid declarations equivalent to:

typedef long long long long;
typedef unsigned long long unsigned long long;
This produces the C2632 errors above.

I confirmed the diagnosis with a minimal test including the generated config.h:

HAVE_STDINT_H = NO
HAVE_INTTYPES_H = NO
intmax_t = MACRO
uintmax_t = MACRO
Changing the two guarded definitions in src/config.h.W32 to:

#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
allows the ARM64 MSVC build to proceed through all source files and link 
successfully.

The resulting executable is built with Microsoft's native ARM64 compiler 
(HostARM64\arm64\cl.exe).

It therefore seems that config.h.W32 should recognise the availability of 
<stdint.h> and <inttypes.h> when using MSVC as well as MinGW.

Thanks for GNU Make, and please let me know if any further reproduction 
information would be useful.

Best regards,
Iain

Reply via email to