Problem compiling mpir with clang-cl

I’m trying to compile mpir (the Windows port of GMP) with clang 3.7.0, using the release version of Visual C++ 2015. The following is a sample of the resulting messages.

Notes:

An immediately preceding attempt to compile the same version of mpir in the same directory with the same version of Visual C++ succeeded; as far as I know, nothing else changed in the meantime.

I’m using https://github.com/russellw/wic to redirect the cl calls to clang-cl so the procedure is as seamless as possible.

mpir.h exists - I’ve appended its location after the error messages - and was found by the build with Visual C++.

Anyone have any idea what might be causing this or what might be a fruitful line of investigation?

Error messages:

cmd.exe /C “C:\Users\w\AppData\Local\Temp\tmp4f8795ae47164f55b788fae62ca2c5e7.cmd”
“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"vsyasm.exe -Xvc -f x64 -g cv8 -i “…..\mpn\x86_64w\” -o “x64\Release\mpn\” -rnasm -pnasm …..\mpn\x86_64w\add_err1_n.asm …..\mp
n\x86_64w\add_err2_n.asm …..\mpn\x86_64w\core2\add_n.asm …..\mpn\x86_64w\core2\addadd_n.asm …..\mpn\x86_64w\core2\addlsh1_n.asm …..\mpn\x86_64w\core2\addlsh_n.asm …..\mpn\x86_64w\cor
e2\addmul_1.asm …..\mpn\x86_64w\core2\addmul_2.asm …..\mpn\x86_64w\core2\addsub_n.asm …..\mpn\x86_64w\core2\and_n.asm …..\mpn\x86_64w\core2\andn_n.asm …..\mpn\x86_64w\core2\com_n.asm
…..\mpn\x86_64w\core2\copyd.asm …..\mpn\x86_64w\core2\copyi.asm …..\mpn\x86_64w\divexact_1.asm …..\mpn\x86_64w\divexact_by3c.asm …..\mpn\x86_64w\core2\divexact_byff.asm …..\mpn\x
86_64w\divexact_byfobm1.asm …..\mpn\x86_64w\divrem_2.asm …..\mpn\x86_64w\divrem_euclidean_qr_1.asm …..\mpn\x86_64w\divrem_euclidean_qr_2.asm …..\mpn\x86_64w\core2\divrem_hensel_qr_1_2.a
sm …..\mpn\x86_64w\core2\hamdist.asm …..\mpn\x86_64w\core2\ior_n.asm …..\mpn\x86_64w\core2\iorn_n.asm …..\mpn\x86_64w\core2\karaadd.asm …..\mpn\x86_64w\core2\karasub.asm …..\mpn\x
86_64w\core2\lshift.asm …..\mpn\x86_64w\core2\lshift1.asm …..\mpn\x86_64w\core2\mod_1_1.asm …..\mpn\x86_64w\core2\mod_1_2.asm …..\mpn\x86_64w\core2\mod_1_3.asm …..\mpn\x86_64w\modexa
ct_1c_odd.asm …..\mpn\x86_64w\core2\mul_1.asm …..\mpn\x86_64w\core2\mul_2.asm …..\mpn\x86_64w\core2\mul_basecase.asm …..\mpn\x86_64w\mulmid_basecase.asm …..\mpn\x86_64w\core2\nand_n.
asm …..\mpn\x86_64w\core2\nior_n.asm …..\mpn\x86_64w\core2\popcount.asm …..\mpn\x86_64w\core2\redc_1.asm …..\mpn\x86_64w\core2\rsh1add_n.asm …..\mpn\x86_64w\core2\rsh1sub_n.asm ….
.\mpn\x86_64w\core2\rsh_divrem_hensel_qr_1_2.asm …..\mpn\x86_64w\core2\rshift.asm …..\mpn\x86_64w\core2\rshift1.asm …..\mpn\x86_64w\sqr_basecase.asm …..\mpn\x86_64w\core2\store.asm …
…\mpn\x86_64w\sub_err1_n.asm …..\mpn\x86_64w\sub_err2_n.asm …..\mpn\x86_64w\core2\sub_n.asm …..\mpn\x86_64w\core2\subadd_n.asm …..\mpn\x86_64w\core2\sublsh1_n.asm …..\mpn\x86_64w\co
re2\submul_1.asm …..\mpn\x86_64w\core2\sumdiff_n.asm …..\mpn\x86_64w\core2\udiv_qrnnd.asm …..\mpn\x86_64w\core2\umul_ppmm.asm …..\mpn\x86_64w\core2\xnor_n.asm …..\mpn\x86_64w\core2\x
or_n.asm
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /I…..\ /Zi /nologo /W1 /WX- /Ox /Oi /D NDEBUG /D WIN32 /D _LIB /D HAVE_CONFIG_H /D _WIN64 /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Release\” /Fd"C:\mpir\build.vc14\lib_mpir_core2\x64\Release\mpir.pdb" /Gd /TC /errorReport:queue …..\assert.c …..\errno.c “…..\extract-dbl.c”
…..\invalid.c …..\memory.c …..\mp_bpl.c …..\mp_clz_tab.c …..\mp_dv_tab.c …..\mp_get_fns.c …..\mp_minv_tab.c …..\mp_set_fns.c …..\nextprime.c …..\primesieve.c …..\randbui.c …
..\randclr.c …..\randdef.c …..\randiset.c …..\randlc2s.c …..\randlc2x.c …..\randmt.c …..\randmts.c …..\randmui.c …..\rands.c …..\randsd.c …..\randsdui.c “…..\tal-reent.c” …
…\version.c
clang-cl.exe : warning : argument unused during compilation: ‘/Gm-’ [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
clang-cl.exe : warning : argument unused during compilation: ‘/GS’ [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
In file included from …..\mp_clz_tab.c:28:
…../longlong.h(255,12): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_BitScanReverse64)

^
…../longlong.h(265,12): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_BitScanForward64)

^
…../longlong.h(275,13): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_umul128)

^
3 warnings generated.
In file included from …..\randmui.c:24:
…../longlong.h(255,12): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_BitScanReverse64)

^
…../longlong.h(265,12): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_BitScanForward64)

^
…../longlong.h(275,13): warning : unknown pragma ignored [-Wunknown-pragmas] [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]

pragma intrinsic(_umul128)

^
3 warnings generated.
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /I…..\ /Zi /nologo /W1 /WX- /Ox /Oi /D NDEBUG /D WIN32 /D _LIB /D HAVE_CONFIG_H /D _WIN64 /Gm- /EHsc /MT /GS /fp:pre
cise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Release\fft\" /Fd"C:\mpir\build.vc14\lib_mpir_core2\x64\Release\mpir.pdb" /Gd /TC /errorReport:queue …..\fft\adjust.c …..\fft\adjust_sqrt2.c …
..\fft\butterfly_lshB.c …..\fft\butterfly_rshB.c …..\fft\combine_bits.c …..\fft\div_2expmod_2expp1.c …..\fft\fermat_to_mpz.c …..\fft\fft_mfa_trunc_sqrt2.c …..\fft\fft_mfa_trunc_sqrt2_i
nner.c …..\fft\fft_negacyclic.c …..\fft\fft_radix2.c …..\fft\fft_trunc.c …..\fft\fft_trunc_sqrt2.c …..\fft\ifft_mfa_trunc_sqrt2.c …..\fft\ifft_negacyclic.c …..\fft\ifft_radix2.c …..
\fft\ifft_trunc.c …..\fft\ifft_trunc_sqrt2.c …..\fft\mul_2expmod_2expp1.c …..\fft\mul_fft_main.c …..\fft\mul_mfa_trunc_sqrt2.c …..\fft\mul_trunc_sqrt2.c …..\fft\mulmod_2expp1.c …..\ff
t\normmod_2expp1.c …..\fft\revbin.c …..\fft\split_bits.c
clang-cl.exe : warning : argument unused during compilation: ‘/Gm-’ [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
clang-cl.exe : warning : argument unused during compilation: ‘/GS’ [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
…..\fft\adjust.c(31,10): fatal error : ‘mpir.h’ file not found [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
#include “mpir.h”
^
1 error generated.
…..\fft\adjust_sqrt2.c(31,10): fatal error : ‘mpir.h’ file not found [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
#include “mpir.h”
^
1 error generated.
…..\fft\butterfly_lshB.c(31,10): fatal error : ‘mpir.h’ file not found [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
#include “mpir.h”
^
1 error generated.
…..\fft\butterfly_rshB.c(31,10): fatal error : ‘mpir.h’ file not found [C:\mpir\build.vc14\lib_mpir_core2\lib_mpir_core2.vcxproj]
#include “mpir.h”
^
1 error generated.

Location of the header file:

C:\mpir>dir /s mpir.h
Volume in drive C is OS
Volume Serial Number is C685-B1F1

Directory of C:\mpir

23/07/2015 12:59 96,496 mpir.h
1 File(s) 96,496 bytes

Directory of C:\mpir\lib\x64\Release

23/07/2015 12:59 96,496 mpir.h
1 File(s) 96,496 bytes

Total Files Listed:
2 File(s) 192,992 bytes
0 Dir(s) 157,248,802,816 bytes free

Could you try and reduce this somehow? Is mpir.h in the same directory as the source file you’re compiling? What happens when you call the compiler manually. Using -v should give you some idea about header search paths.

Okay, I’ve tried to replicate the problem by issuing compiler commands by hand.

As far as I can see, the working directory for the actual compilation is:

cd \mpir\build.vc14\lib_mpir_core2

This means mpir.h is located two levels higher up, which is consistent with the /I…..\ compiler switch.

I then issued the compiler command that seems to be causing the trouble:

“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe” /c /I…..\ /Zi /nologo /W1 /WX- /Ox /Oi /D NDEBUG /D WIN32 /D _LIB /D HAVE_CONFIG_H /D _WIN64 /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"x64\Release\fft\" /Fd"C:\mpir\build.vc14\lib_mpir_core2\x64\Release\mpir.pdb" /Gd /TC /errorReport:queue …..\fft\adjust.c …..\fft\adjust_sqrt2.c …..\fft\butterfly_lshB.c …..\fft\butterfly_rshB.c …..\fft\combine_bits.c …..\fft\div_2expmod_2expp1.c …..\fft\fermat_to_mpz.c …..\fft\fft_mfa_trunc_sqrt2.c …..\fft\fft_mfa_trunc_sqrt2_inner.c …..\fft\fft_negacyclic.c …..\fft\fft_radix2.c …..\fft\fft_trunc.c …..\fft\fft_trunc_sqrt2.c …..\fft\ifft_mfa_trunc_sqrt2.c …..\fft\ifft_negacyclic.c …..\fft\ifft_radix2.c …..\fft\ifft_trunc.c …..\fft\ifft_trunc_sqrt2.c …..\fft\mul_2expmod_2expp1.c …..\fft\mul_fft_main.c …..\fft\mul_mfa_trunc_sqrt2.c …..\fft\mul_trunc_sqrt2.c …..\fft\mulmod_2expp1.c …..\fft\normmod_2expp1.c …..\fft\revbin.c …..\fft\split_bits.c

But this works fine even with clang enabled. (I get the few warning messages, which prove clang is indeed running, but no errors.)

Maybe the problem is some arcane property of MSbuild?