I've been trying to build Ruby on Windows using Clang. The process fails at
configure stage with this error:
C:\ruby-2.2.2\win32\build>..\configure.bat
conftest.c(2,2) : error:
#error
^
1 error generated.
clang-cl.exe: warning: Creating verconf.mk: 'linker' input unused
clang-cl.exe: warning: argument unused during compilation:
'-Wno-invalid-token-paste'
clang-cl.exe: warning: argument unused during compilation: '-I ../..'
clang-cl.exe: warning: argument unused during compilation: '-I
../../include'
NMAKE : fatal error U1077: 'cl' : return code '0x1'
Stop.
conftest.c seems to be a phantom file - one that is created after the build
process starts and deleted before it ends and thus doesn't show up in the
filesystem - I wrote some instrumentation to capture it, and this is what
it looks like:
#include <stdio.h>
int main(void) {FILE *volatile f = stdin; return 0;}
But this doesn't seem to match the error message. There were a couple of
weird files alongside it that don't seem to match the error message either.
Does anyone know what the problem is here, or how to fix it?
AFAIR, config.log (or configure.log) contains the program that failed, i.e.,
the contents of "conftest.c" for the failing test. Can you have a look at it?
--- Eric
···
On Friday 17 July 2015 17:55:50, Russell Wallace <russell.wallace@gmail.com> wrote:
But this doesn't seem to match the error message. There were a couple of
weird files alongside it that don't seem to match the error message either.
Does anyone know what the problem is here, or how to fix it?
C:\ruby-2.2.2>dir /s conf*.log
Volume in drive C is OS
Volume Serial Number is C685-B1F1
File Not Found
Doesn't seem to be present - am I missing something?
···
On Fri, Jul 17, 2015 at 6:07 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:
On Friday 17 July 2015 17:55:50, Russell Wallace < > russell.wallace@gmail.com> > wrote:
> But this doesn't seem to match the error message. There were a couple of
> weird files alongside it that don't seem to match the error message
either.
>
> Does anyone know what the problem is here, or how to fix it?
AFAIR, config.log (or configure.log) contains the program that failed,
i.e.,
the contents of "conftest.c" for the failing test. Can you have a look at
it?
--- Eric
Probably not: The `configure' script run under Linux is a standard GNU
autotools script that creates config.log, whereas `configure.bat' is something
entirely different. Sorry for the confusion; I just assumed they were
exhibiting the same behavior.
With a quick grep over the relevant files in win32/, the only occurence of an
empty `#error' I see is the following code fragment:
-osname-: nul
@echo !ifndef TARGET_OS>>$(MAKEFILE)
@($(CC) -c <<conftest.c > nul && (echo TARGET_OS = mswin32) || (echo
TARGET_OS = mswin64)) >>$(MAKEFILE)
#ifdef _WIN64
#error
#endif
<<
@echo !endif>>$(MAKEFILE)
@$(WIN32DIR:/=\)\rm.bat conftest.*
-runtime-: nul
@$(CC) -MD <<conftest.c user32.lib -link > nul
#include <stdio.h>
int main(void) {FILE *volatile f = stdin; return 0;}
<<
@$(WIN32DIR:/=\)\rtname conftest.exe >>$(MAKEFILE)
@$(WIN32DIR:/=\)\rm.bat conftest.*
Try changing the plain `#error' to something more recognizable and see whether
you hit that. If so, you know the culprit.
I am unsure why the -osname- rule might be hit, though.
--- Eric
···
On Friday 17 July 2015 18:09:49, Russell Wallace <russell.wallace@gmail.com> wrote:
C:\ruby-2.2.2>dir /s conf*.log
Volume in drive C is OS
Volume Serial Number is C685-B1F1
File Not Found
Doesn't seem to be present - am I missing something?
Good call. Changing win32/setup.mak line 95 to #error foo gives:
C:\ruby-2.2.2\win32\build>..\configure.bat
conftest.c(2,2) : error: foo
#error foo
^
1 error generated.
clang-cl.exe: warning: Creating verconf.mk: 'linker' input unused
clang-cl.exe: warning: argument unused during compilation:
'-Wno-invalid-token-paste'
clang-cl.exe: warning: argument unused during compilation: '-I ../..'
clang-cl.exe: warning: argument unused during compilation: '-I
../../include'
NMAKE : fatal error U1077: 'cl' : return code '0x1'
Stop.
Okay, so why is that happening? On the face of it
#ifdef _WIN64
#error foo
#endif
would seem to be saying '64-bit on Windows is not supported for some
unspecified reason'. However, it was perfectly happy when using the
Microsoft compiler in 64-bit mode. The only change that prompted this error
was substituting clang-cl for cl.
···
On Fri, Jul 17, 2015 at 6:27 PM, Eric MSP Veith <eveith@wwweb-library.net> wrote:
On Friday 17 July 2015 18:09:49, Russell Wallace < > russell.wallace@gmail.com> > wrote:
> C:\ruby-2.2.2>dir /s conf*.log
> Volume in drive C is OS
> Volume Serial Number is C685-B1F1
> File Not Found
>
> Doesn't seem to be present - am I missing something?
Probably not: The `configure' script run under Linux is a standard GNU
autotools script that creates config.log, whereas `configure.bat' is
something
entirely different. Sorry for the confusion; I just assumed they were
exhibiting the same behavior.
With a quick grep over the relevant files in win32/, the only occurence of
an
empty `#error' I see is the following code fragment:
-osname-: nul
@echo !ifndef TARGET_OS>>$(MAKEFILE)
@($(CC) -c <<conftest.c > nul && (echo TARGET_OS = mswin32) ||
(echo
TARGET_OS = mswin64)) >>$(MAKEFILE)
#ifdef _WIN64
#error
#endif
<<
@echo !endif>>$(MAKEFILE)
@$(WIN32DIR:/=\)\rm.bat conftest.*
-runtime-: nul
@$(CC) -MD <<conftest.c user32.lib -link > nul
#include <stdio.h>
int main(void) {FILE *volatile f = stdin; return 0;}
<<
@$(WIN32DIR:/=\)\rtname conftest.exe >>$(MAKEFILE)
@$(WIN32DIR:/=\)\rm.bat conftest.*
Try changing the plain `#error' to something more recognizable and see
whether
you hit that. If so, you know the culprit.
I am unsure why the -osname- rule might be hit, though.
--- Eric
It could simply be that clang uses a different set of preprocessor defines
than MS C compiler. Maybe you can find out with compiler option -E - if
that exists.
Kind regards
robert
···
On Fri, Jul 17, 2015 at 7:46 PM, Russell Wallace <russell.wallace@gmail.com> wrote:
Good call. Changing win32/setup.mak line 95 to #error foo gives:
C:\ruby-2.2.2\win32\build>..\configure.bat
conftest.c(2,2) : error: foo
#error foo
^
1 error generated.
clang-cl.exe: warning: Creating verconf.mk: 'linker' input unused
clang-cl.exe: warning: argument unused during compilation:
'-Wno-invalid-token-paste'
clang-cl.exe: warning: argument unused during compilation: '-I ../..'
clang-cl.exe: warning: argument unused during compilation: '-I
../../include'
NMAKE : fatal error U1077: 'cl' : return code '0x1'
Stop.
Okay, so why is that happening? On the face of it
#ifdef _WIN64
#error foo
#endif
would seem to be saying '64-bit on Windows is not supported for some
unspecified reason'. However, it was perfectly happy when using the
Microsoft compiler in 64-bit mode. The only change that prompted this error
was substituting clang-cl for cl.
--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/
It rather seems like "clang-cl on 64-bit windows is not supported," but in
order to be sure, I'd rather try to find out why the -osname- target is called
and not, for example, -osname64-.
Following through with the setup.mak file (I've got no Windows handy, so I am
only reading the file and guessing) it seems that -osname- is along the
dependency chain for the "all" target, but wouldn't be invoked when nmake was
invoked with, e.g., "x64-mswin64."
Has nmake a debug/trace mode that shows how it operates?
--- Eric
···
On Friday 17 July 2015 18:46:02, Russell Wallace <russell.wallace@gmail.com> wrote:
Okay, so why is that happening? On the face of it
#ifdef _WIN64
#error foo
#endif
would seem to be saying '64-bit on Windows is not supported for some
unspecified reason'. However, it was perfectly happy when using the
Microsoft compiler in 64-bit mode. The only change that prompted this error
was substituting clang-cl for cl.
nmake doesn't, but I wrote some more instrumentation for that purpose.
Here's the monitor output - the actual sequence of create process system
calls - for configure with visual studio
cl -EP confargs.c
nmake -alf ~setup~.mak MAKEFILE=Makefile.new
C:\Windows\system32\cmd.exe /c del ~setup~.mak
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -lAL
-f ../setup.mak WIN32DIR=..
C:\Windows\system32\cmd.exe /c type
C:\Users\w\AppData\Local\Temp\nmAE6E.tmp > Makefile.new
C:\Windows\system32\cmd.exe /c for %I in (ruby.exe) do @echo BASERUBY =
%~s$PATH:I>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !if "$(BASERUBY)" == "">> Makefile.new
C:\Windows\system32\cmd.exe /c echo BASERUBY = echo executable host ruby is
required. use --with-baseruby option.^& exit 1 >> Makefile.new
C:\Windows\system32\cmd.exe /c echo HAVE_BASERUBY = no>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !else>> Makefile.new
C:\Windows\system32\cmd.exe /c echo HAVE_BASERUBY = yes>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !endif>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !ifndef TARGET_OS>>Makefile.new
C:\Windows\system32\cmd.exe /c (cl -nologo -c conftest.c > nul && (echo
TARGET_OS = mswin32) || (echo TARGET_OS = mswin64)) >>Makefile.new
cl -nologo -c conftest.c
C:\Windows\system32\cmd.exe /c echo !endif>>Makefile.new
C:\Windows\system32\cmd.exe /c ..\rm.bat conftest.*
C:\Windows\system32\cmd.exe /c cl -nologo -MD conftest.c user32.lib -link >
nul
cl -nologo -MD conftest.c user32.lib -link
"C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\BIN\x86_amd64\link.exe" /link /errorreport:queue
@"C:\Users\w\AppData\Local\Temp\_CL_876d45a2lk"
C:\Windows\system32\cmd.exe /c ..\rtname conftest.exe >>Makefile.new
C:\Windows\system32\cmd.exe /c dumpbin -dependents conftest.exe | findstr
-r -i "\<msvcr.*\.dll$"
dumpbin -dependents conftest.exe
findstr -r -i "\<msvcr.*\.dll$"
LINK /DUMP -dependents conftest.exe
C:\Windows\system32\cmd.exe /c ..\rm.bat conftest.*
C:\Windows\system32\cmd.exe /c echo RUBY_RELEASE_DATE \>verconf.mk
C:\Windows\system32\cmd.exe /c cl -nologo -EP -I../.. -I../../include
"Creating verconf.mk" | findstr "=" >>verconf.mk
cl -nologo -EP -I../.. -I../../include "Creating verconf.mk"
findstr "="
C:\Windows\system32\cmd.exe /c echo.>>Makefile.new
C:\Windows\system32\cmd.exe /c cl -nologo -EP -I../.. -I../../include
"Creating Makefile.new" | findstr "=" >>Makefile.new
cl -nologo -EP -I../.. -I../../include "Creating Makefile.new"
findstr "="
C:\Windows\system32\cmd.exe /c type
C:\Users\w\AppData\Local\Temp\nmB2A4.tmp >>Makefile.new
C:\Windows\system32\cmd.exe /c cl -nologo -EP conftest.c 2>nul | findstr =
Makefile.new
cl -nologo -EP conftest.c
findstr =
C:\Windows\system32\cmd.exe /c echo>>Makefile.new PROCESSOR_LEVEL = 6
C:\Windows\system32\cmd.exe /c echo.>>Makefile.new
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -f
Makefile.new -l -f ../../win32/enc-setup.mak srcdir="../.."
MAKEFILE=Makefile.new
C:\Windows\system32\cmd.exe /c echo BUILTIN_ENCOBJS = ascii.obj
us_ascii.obj unicode.obj utf_8.obj >> Makefile.new
C:\Windows\system32\cmd.exe /c echo BUILTIN_TRANSOBJS = newline.obj >>
Makefile.new
C:\Windows\system32\cmd.exe /c echo.>>Makefile.new
C:\Windows\system32\cmd.exe /c cl -nologo -EP confargs.c 2>&1 | findstr "!
=" >> Makefile.new
cl -nologo -EP confargs.c
findstr "! ="
C:\Windows\system32\cmd.exe /c del confargs.c
C:\Windows\system32\cmd.exe /c type
C:\Users\w\AppData\Local\Temp\nmB42B.tmp >>Makefile.new
C:\Windows\system32\cmd.exe /C ..\..\win32\rm.bat config.h config.status
C:\Windows\system32\cmd.exe /c echo "type `nmake' to make ruby."
C:\Windows\system32\cmd.exe /c if exist Makefile.old del Makefile.old
C:\Windows\system32\cmd.exe /c if exist Makefile ren Makefile Makefile.old
C:\Windows\system32\cmd.exe /c ren Makefile.new Makefile
And here's the equivalent with clang
cl -EP confargs.c
clang-cl.exe -Wno-invalid-token-paste -EP confargs.c
"C:\trunk\build\Release\bin\clang-cl.exe" -cc1 -triple
x86_64-pc-windows-msvc18.0.0 -E -disable-free -disable-llvm-verifier
-main-file-name confargs.c -mrelocation-model pic -pic-level 2
-mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -D_MT
--dependent-lib=libcmt --dependent-lib=oldnames -E -P -fms-volatile
-fdiagnostics-format msvc -momit-leaf-frame-pointer -dwarf-column-info
-resource-dir "C:\trunk\build\Release\bin\..\lib\clang\3.
nmake -alf ~setup~.mak MAKEFILE=Makefile.new
C:\Windows\system32\cmd.exe /c del ~setup~.mak
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -lAL
-f ../setup.mak WIN32DIR=..
C:\Windows\system32\cmd.exe /c type
C:\Users\w\AppData\Local\Temp\nmDFCA.tmp > Makefile.new
C:\Windows\system32\cmd.exe /c for %I in (ruby.exe) do @echo BASERUBY =
%~s$PATH:I>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !if "$(BASERUBY)" == "">> Makefile.new
C:\Windows\system32\cmd.exe /c echo BASERUBY = echo executable host ruby is
required. use --with-baseruby option.^& exit 1 >> Makefile.new
C:\Windows\system32\cmd.exe /c echo HAVE_BASERUBY = no>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !else>> Makefile.new
C:\Windows\system32\cmd.exe /c echo HAVE_BASERUBY = yes>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !endif>> Makefile.new
C:\Windows\system32\cmd.exe /c echo !ifndef TARGET_OS>>Makefile.new
C:\Windows\system32\cmd.exe /c (cl -nologo -c conftest.c > nul && (echo
TARGET_OS = mswin32) || (echo TARGET_OS = mswin64)) >>Makefile.new
cl -nologo -c conftest.c
clang-cl.exe -Wno-invalid-token-paste -nologo -c conftest.c
"C:\trunk\build\Release\bin\clang-cl.exe" -cc1 -triple
x86_64-pc-windows-msvc18.0.0 -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name conftest.c -mrelocation-model pic
-pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-D_MT --dependent-lib=libcmt --dependent-lib=oldnames -fms-volatile
-fdiagnostics-format msvc -momit-leaf-frame-pointer -dwarf-column-info
-coverage-file "C:\ruby-2.2.2\win32\build\co
C:\Windows\system32\cmd.exe /c echo !endif>>Makefile.new
C:\Windows\system32\cmd.exe /c ..\rm.bat conftest.*
C:\Windows\system32\cmd.exe /c cl -nologo -MD conftest.c user32.lib -link >
nul
cl -nologo -MD conftest.c user32.lib -link
clang-cl.exe -Wno-invalid-token-paste -nologo -MD conftest.c user32.lib
-link
"C:\trunk\build\Release\bin\clang-cl.exe" -cc1 -triple
x86_64-pc-windows-msvc18.0.0 -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name conftest.c -mrelocation-model pic
-pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-D_MT -D_DLL --dependent-lib=msvcrt --dependent-lib=oldnames -fms-volatile
-fdiagnostics-format msvc -momit-leaf-frame-pointer -dwarf-column-info
-resource-dir "C:\trunk\build\Release
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\link.exe"
-out:conftest.exe -nologo
"C:\Users\w\AppData\Local\Temp\conftest-a17a75.obj" user32.lib
C:\Windows\system32\cmd.exe /c ..\rtname conftest.exe >>Makefile.new
C:\Windows\system32\cmd.exe /c dumpbin -dependents conftest.exe | findstr
-r -i "\<msvcr.*\.dll$"
dumpbin -dependents conftest.exe
LINK /DUMP -dependents conftest.exe
findstr -r -i "\<msvcr.*\.dll$"
C:\Windows\system32\cmd.exe /c ..\rm.bat conftest.*
C:\Windows\system32\cmd.exe /c echo RUBY_RELEASE_DATE \>verconf.mk
C:\Windows\system32\cmd.exe /c cl -nologo -EP -I../.. -I../../include
"Creating verconf.mk" | findstr "=" >>verconf.mk
cl -nologo -EP -I../.. -I../../include "Creating verconf.mk"
clang-cl.exe -Wno-invalid-token-paste -nologo -EP -I../.. -I../../include
"Creating verconf.mk"
findstr "="
C:\Windows\system32\cmd.exe /c if exist Makefile.old del Makefile.old
C:\Windows\system32\cmd.exe /c if exist Makefile ren Makefile Makefile.old
C:\Windows\system32\cmd.exe /c ren Makefile.new Makefile
···
On Sat, Jul 18, 2015 at 11:50 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:
On Friday 17 July 2015 18:46:02, Russell Wallace < > russell.wallace@gmail.com> > wrote:
> Okay, so why is that happening? On the face of it
>
> #ifdef _WIN64
> #error foo
> #endif
>
> would seem to be saying '64-bit on Windows is not supported for some
> unspecified reason'. However, it was perfectly happy when using the
> Microsoft compiler in 64-bit mode. The only change that prompted this
error
> was substituting clang-cl for cl.
It rather seems like "clang-cl on 64-bit windows is not supported," but in
order to be sure, I'd rather try to find out why the -osname- target is
called
and not, for example, -osname64-.
Following through with the setup.mak file (I've got no Windows handy, so I
am
only reading the file and guessing) it seems that -osname- is along the
dependency chain for the "all" target, but wouldn't be invoked when nmake
was
invoked with, e.g., "x64-mswin64."
Has nmake a debug/trace mode that shows how it operates?
--- Eric