2

I'm unable to diagnose the cause of an error when attempting to build MPFR 4.0.1 with MinGW-w64 8.1.0. I'm using msys2 and Windows 10. The result of running mingw32-make is:

$ make
Making all in doc
make[1]: Entering directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/doc'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/doc'
Making all in src
make[1]: Entering directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/src'
C:/development-tools/mingw-w64-8.1.0/mingw64/bin/make  all-am
make[2]: Entering directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/src'
C:/development-tools/msys2/usr/bin/sh.exe ../libtool  --tag=CC   --mode=compile gcc -DMPFR_WANT_ASSERT=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_DOUBLE_IEEE_LITTLE_ENDIAN=1 -DHAVE_LITTLE_ENDIAN=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1 -DHAVE_STRUCT_LCONV_DECIMAL_POINT=1 -DHAVE_STRUCT_LCONV_THOUSANDS_SEP=1 -DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_SIGNAL=1 -DHAVE_LONG_LONG=1 -DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_PRINTF_MAXLM=\"ll\" -DMPFR_HAVE_NORETURN=1 -DMPFR_HAVE_BUILTIN_UNREACHABLE=1 -DMPFR_HAVE_CONSTRUCTOR_ATTR=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DMPFR_HAVE_FESETROUND=1 -DHAVE_DENORMS=1 -DHAVE_DENORMS_FLT=1 -DHAVE_SIGNEDZ=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 -DHAVE_CEIL=1 -DHAVE_NEARBYINT=1 -DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1 -DMPFR_USE_THREAD_SAFE=1 -DMPFR_USE_C11_THREAD_SAFE=1 -DMPFR_WANT_DECIMAL_FLOATS=1 -DMPFR_WANT_FLOAT128=1 -DMPFR_USE_STATIC_ASSERT=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_ATTRIBUTE_MODE=1 -DNPRINTF_J=1 -DNPRINTF_L=1 -DNPRINTF_T=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -DHAVE___GMPN_INVERT_LIMB=1 -DHAVE___GMPN_RSBLSH_N=1 -DMPFR_LONG_WITHIN_LIMB=1 -I. -I../../src/src   -IC:/development-personal-builds/gmp-6.1.2/build-1/include  -Wall -Wmissing-prototypes -Wpointer-arith -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -MT exceptions.lo -MD -MP -MF .deps/exceptions.Tpo -c -o exceptions.lo ../../src/src/exceptions.c
libtool: compile:  gcc -DMPFR_WANT_ASSERT=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 "-DLT_OBJDIR=\\.libs/\" -DHAVE_DOUBLE_IEEE_LITTLE_ENDIAN=1 -DHAVE_LITTLE_ENDIAN=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1 -DHAVE_STRUCT_LCONV_DECIMAL_POINT=1 -DHAVE_STRUCT_LCONV_THOUSANDS_SEP=1 -DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_SIGNAL=1 -DHAVE_LONG_LONG=1 -DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_PRINTF_MAXLM=\"ll\" -DMPFR_HAVE_NORETURN=1 -DMPFR_HAVE_BUILTIN_UNREACHABLE=1 -DMPFR_HAVE_CONSTRUCTOR_ATTR=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DMPFR_HAVE_FESETROUND=1 -DHAVE_DENORMS=1 -DHAVE_DENORMS_FLT=1 -DHAVE_SIGNEDZ=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 -DHAVE_CEIL=1 -DHAVE_NEARBYINT=1 -DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1 -DMPFR_USE_THREAD_SAFE=1 -DMPFR_USE_C11_THREAD_SAFE=1 -DMPFR_WANT_DECIMAL_FLOATS=1 -DMPFR_WANT_FLOAT128=1 -DMPFR_USE_STATIC_ASSERT=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_ATTRIBUTE_MODE=1 -DNPRINTF_J=1 -DNPRINTF_L=1 -DNPRINTF_T=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -DHAVE___GMPN_INVERT_LIMB=1 -DHAVE___GMPN_RSBLSH_N=1 -DMPFR_LONG_WITHIN_LIMB=1 -I. -I../../src/src -IC:/development-personal-builds/gmp-6.1.2/build-1/include -Wall -Wmissing-prototypes -Wpointer-arith -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -MT exceptions.lo -MD -MP -MF .deps/exceptions.Tpo -c -o exceptions.lo ../../src/src/exceptions.c"  -DDLL_EXPORT -DPIC -o .libs/exceptions.o
gcc.exe: fatal error: no input files
compilation terminated.
make[2]: *** [Makefile:807: exceptions.lo] Error 1
make[2]: Leaving directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/src'
make[1]: *** [Makefile:476: all] Error 2
make[1]: Leaving directory 'C:/development-personal-builds/mpfr-4.0.1/build-1/src'
make: *** [Makefile:498: all-recursive] Error 1

The command used to execute configure was:

cd build-1
../src/configure \
--prefix=C:/development-personal-builds/mpfr-4.0.1/build-1 \
--build=x86_64-w64-mingw32 \
--enable-assert \
--enable-shared=yes \
--enable-static=no \
--with-gmp=C:/development-personal-builds/gmp-6.1.2/build-1

The GMP build I supplied was built by me and it passed all 'make check' tests.

Attempts to Fix Following advice given by Mike, I've fed gcc the corrected string via the CC flag, but get a new error as gcc can only write to one file:

CC="--mode=compile gcc -DMPFR_WANT_ASSERT=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_DOUBLE_IEEE_LITTLE_ENDIAN=1 -DHAVE_LITTLE_ENDIAN=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_LOCALE_H=1 -DHAVE_WCHAR_H=1 -DHAVE_STDARG=1 -DHAVE_SYS_TIME_H=1 -DHAVE_STRUCT_LCONV_DECIMAL_POINT=1 -DHAVE_STRUCT_LCONV_THOUSANDS_SEP=1 -DHAVE_VA_COPY=1 -DHAVE_SETLOCALE=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_SIGNAL=1 -DHAVE_LONG_LONG=1 -DHAVE_INTMAX_T=1 -DMPFR_HAVE_INTMAX_MAX=1 -DMPFR_PRINTF_MAXLM=\"ll\" -DMPFR_HAVE_NORETURN=1 -DMPFR_HAVE_BUILTIN_UNREACHABLE=1 -DMPFR_HAVE_CONSTRUCTOR_ATTR=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DMPFR_HAVE_FESETROUND=1 -DHAVE_DENORMS=1 -DHAVE_DENORMS_FLT=1 -DHAVE_SIGNEDZ=1 -DHAVE_ROUND=1 -DHAVE_TRUNC=1 -DHAVE_FLOOR=1 -DHAVE_CEIL=1 -DHAVE_NEARBYINT=1 -DHAVE_LDOUBLE_IEEE_EXT_LITTLE=1 -DMPFR_USE_THREAD_SAFE=1 -DMPFR_USE_C11_THREAD_SAFE=1 -DMPFR_WANT_DECIMAL_FLOATS=1 -DMPFR_WANT_FLOAT128=1 -DMPFR_USE_STATIC_ASSERT=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_ATTRIBUTE_MODE=1 -DNPRINTF_J=1 -DNPRINTF_L=1 -DNPRINTF_T=1 -DHAVE___GMPN_SBPI1_DIVAPPR_Q=1 -DHAVE___GMPN_INVERT_LIMB=1 -DHAVE___GMPN_RSBLSH_N=1 -DMPFR_LONG_WITHIN_LIMB=1 -I. -I../../src/src -IC:/development-personal-builds/gmp-6.1.2/build-1/include -Wall -Wmissing-prototypes -Wpointer-arith -O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8 -MT exceptions.lo -MD -MP -MF .deps/exceptions.Tpo -c -o exceptions.lo ../../src/src/exceptions.c -DDLL_EXPORT -DPIC -o .libs/exceptions.o"

The command is still messed up, as I now get this error:

libtool:   error: you cannot specify '-o' more than once

Out of desperation, I've also tried:

  • Rolling back to MPFR 3.1.6 (the version "recommended" by the MinGW-w64 port here: https://github.com/emphasis87/libmpfr-msys2-mingw64);
  • Not using a bash script and running configure directly;
  • Converting the bash script to ANSI instead of UTF-8;
  • Using Cygwin;

Aaargh.

  • Since it's an Error 1, I've been trying to work out if it's literally a problem with GCC not being given input files, so a makefile problem? Just to check, I ran make with -k and it returned Error 1 for every single command. Does anyone know how to check what commands the compiler is being fed during build? –  Dec 05 '18 at 03:44
  • 1
    In the call of gcc, a lot of the arguments are within quotation marks: `-DHAVE_STDINT_H=1 "-DLT_OBJDIR= ... exceptions.c" -DDLL_EXPORT` That looks wrong. – ssbssa Dec 05 '18 at 11:21
  • Yes, that seems to be the problem, as Mike suggests in his answer. I haven't been able to find where these extra double quotes are actually being placed as the quotes aren't in the makefiles. –  Dec 06 '18 at 01:14

2 Answers2

1

In this commandline:

C:/development-tools/msys2/usr/bin/sh.exe ../libtool  --tag=CC   --mode=compile \
gcc -DMPFR_WANT_ASSERT=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DLT_OBJDIR=\".libs/\"...

We see that in -DLT_OBJDIR=\".libs/\" there are balanced quotation marks that are escaped. However in libtool's diagnostic:

libtool: compile:  gcc -DMPFR_WANT_ASSERT=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 "-DLT_OBJDIR=\\.libs/\"...

we see that the first of those escaped quotes has been removed and replaced with another escape:

\".libs/\"  <- before
\\.libs/\"  <- after

and that a new unescaped quotation mark has been prepended to the macro definition:

 -DLT_OBJDIR=\".libs/\" <- before
"-DLT_OBJDIR=\\.libs/\" <- after

thus creating a quoted string argument for gcc that commences "-DLT_OBJDIR=\\.libs/\"... and in fact consumes all the remainder of the commandline up to:

../../src/src/exceptions.c"

whereas in the original commandline we have:

../../src/src/exceptions.c

From where I'm sitting, I cannot explain the cause of this escape/quotation corruption, but it is the answer to the question:

Why does GCC (MinGW-w64) return a 'fatal error: no input files' when building MPFR?

I suggest you direct your investigation to that with the advantage of being the guy on the spot.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
  • Thanks for spotting that. Do you know if there's any way to override libtool's arguments to a corrected list? The error doesn't seem to be present in the makefiles as the extra double quotes aren't present; maybe a problem with sh? –  Dec 06 '18 at 01:13
  • Please see my update Mike, I'd appreciate your advice. –  Dec 06 '18 at 10:17
  • 1
    `CC=` should specify (what your choose to regard as) *your C compiler*, e.g. `gcc`. You have set it be an *entire libtool compilation commandline*. This will inevitably bust when the build appends its own compilation options, but in any case your compilation contains two `-o ` options, which is an error as compilation can only produce one object file. I'm sorry, but I can't get you further with this except by paying you a visit ;) – Mike Kinghan Dec 06 '18 at 10:39
  • I'll put the kettle on. ;) –  Dec 06 '18 at 12:17
0

I just hit the same problem trying to compile GNU GetText library on Windows with Mingw64, this article was the most relevant one I found but didn't really have a solution so I'm sharing what I found out...

I produced a small testcase demonstrating the problem:

Makefile:

ORIGINAL=arg1 arg2 -ARG3=\"string\" -ARG4=\"\" arg5
FIXED=$(subst ","",$(ORIGINAL))

.PHONY:all
all:
    echo ORIGINAL is: $(ORIGINAL)
    ./argdump.sh $(ORIGINAL)
    echo FIXED is: $(FIXED)
    ./argdump.sh $(FIXED)

Which calls to the argdump.sh script:

#!/bin/sh
echo Dumping arguments:
for i; do 
   echo Raw Arg: $i 
done
echo DONE.

Output when run in Mingw:

$ make
echo ORIGINAL is: arg1 arg2 -ARG3=\"string\" -ARG4=\"\" arg5
ORIGINAL is: arg1 arg2 -ARG3=\string" -ARG4="" arg5
./argdump.sh arg1 arg2 -ARG3=\"string\" -ARG4=\"\" arg5
Dumping arguments:
Raw Arg: arg1
Raw Arg: arg2
Raw Arg: -ARG3=\string" -ARG4="" arg5
DONE.
echo FIXED is: arg1 arg2 -ARG3=\""string\"" -ARG4=\""\"" arg5
FIXED is: arg1 arg2 -ARG3="string" -ARG4="" arg5
./argdump.sh arg1 arg2 -ARG3=\""string\"" -ARG4=\""\"" arg5
Dumping arguments:
Raw Arg: arg1
Raw Arg: arg2
Raw Arg: -ARG3="string"
Raw Arg: -ARG4=""
Raw Arg: arg5
DONE.

As can be seen dumping the "original" arguments all the trailing arguments from the first that uses a quote are clumped together - when this happens in the gnu lib makefile call to libtool.sh libtool can't process the clumped arguments correctly and you get the error like "no input files". So adding the $(subst ","",$(ARGS_VAR)) call fixes this, to be honest I found this substitution to work by experimentation so I can't tell you why it works any more than "it just does".

So for example in the GetText lib I added a line before the calls to the compiler (in the gettext-runtime/intl/Makefile.in file):

...
# Fix arg passing to libtool under mingw:
ifeq ($(build_os),mingw32)
  LTCOMPILE:=$(subst ","",$(LTCOMPILE))
endif
# Rules for compiling a .c file, that work even without a VPATH variable.
bindtextdom.lo: $(srcdir)/bindtextdom.c
    $(AM_V_CC)$(LTCOMPILE) -c -o $@ $(srcdir)/bindtextdom.c
dcgettext.lo: $(srcdir)/dcgettext.c
    $(AM_V_CC)$(LTCOMPILE) -c -o $@ $(srcdir)/dcgettext.c
...

Hope this helps the next person to experience this problem!

simond528
  • 1
  • 2