fdopen / opam-repository-mingw

windows package repository for OPAM (mingw and msvc)
https://fdopen.github.io/opam-repository-mingw/
Creative Commons Zero v1.0 Universal
96 stars 34 forks source link

Carriage return issue in generated prims.c #41

Closed ncannasse closed 7 years ago

ncannasse commented 7 years ago

On a fresh Windows 10 box I'm doing the following:

opam init --yes default https://github.com/fdopen/opam-repository-mingw.git --comp 4.03.0+mingw32

But quickly during the make world I'm getting an error in prims.s about missing closing " character. I had some hard time breaking opam before it deletes the tmp files but I managed to get the generated prims.c and it looks like this (the names parts):

"caml_value_xxxx
",
"caml_value_yyy
",

I also verified that the primitives file generated by make + sed does have CRLF endings, that might be the reason for this.

I have set my windows GIT to checkout as-it and commit as-it. I have autocrlf = false

ncannasse commented 7 years ago

Tried various GIT configurations with no luck.

ncannasse commented 7 years ago

Same error with 4.05.0, here's the terminal output:

=-=- Installing compiler 4.05.0+mingw32 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[compiler.get] https://github.com/ocaml/ocaml/archive/4.05.0.tar.gz downloaded
Now compiling OCaml. This may take a while, please bear with us...
[ERROR] Compiler build failed at "make world.opt":
        # opam-version 1.3.0~dev (2c2399d98ad0ebcb43a4bc856f3636030bb376db)
        # os           win32
        # command      make world.opt
        # path         D:/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/build/ocaml
        # exit-code    2
        # env-file     D:/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/build/ocaml\log-528-97bbf8.env
        # stdout-file  D:/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/build/ocaml\log-528-97bbf8.out
        # stderr-file  D:/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/build/ocaml\log-528-97bbf8.err
        ### stdout ###
        # [...]
        # (echo '#define CAML_INTERNALS'; \
        #          echo '#include "caml/mlvalues.h"'; \
        #  echo '#include "caml/prims.h"'; \
        #  sed -e 's/.*/extern value &();/' primitives; \
        #  echo 'c_primitive caml_builtin_cprim[] = {'; \
        #  sed -e 's/.*/        &,/' primitives; \
        #  echo '        0 };'; \
        #  echo 'char * caml_names_of_builtin_cprim[] = {'; \
        #  sed -e 's/.*/        "&",/' primitives; \
        #  echo '        0 };') > prims.c
        # i686-w64-mingw32-gcc -march=i686 -mtune=generic -O2 -mms-bitfields
        -DOCAML_STDLIB_DIR='"D:/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/lib/ocaml"'
        -I"D:/Projects/hxtools/ocamhaxe/lib/flexdll" -DCAML_NAME_SPACE -Wall -Wno-unused -fno-tree-vrp -c prims.c
        # make[1]: Leaving directory '/cygdrive/d/Projects/hxtools/ocamhaxe/.opam/4.05.0+mingw32/build/ocaml/byterun'
        ### stderr ###
        # [...]
        # prims.c:2084:1: warning: missing terminating " character
        # prims.c:2084:1: error: missing terminating " character
        # prims.c:2085:2: warning: missing terminating " character
        # prims.c:2085:2: error: missing terminating " character
        # prims.c:2086:1: warning: missing terminating " character
        # prims.c:2086:1: error: missing terminating " character
        # prims.c:2087:2: warning: missing terminating " character
        # prims.c:2087:2: error: missing terminating " character
        # prims.c:2088:1: warning: missing terminating " character
        # prims.c:2088:1: error: missing terminating " character
        # make[1]: *** [Makefile:206: prims.o] Error 1
        # make: *** [Makefile:362: coldstart] Error 2

[ERROR] Initialisation failed
OpamStd.OpamSys.Exit(66)
fdopen commented 7 years ago

Don't use "windows git", instead make sure that you have the cygwin version of git installed (via cygwin's setup). "Windows Git" ships its own *nix tools (bash,etc). Things get messy, if sometimes tools of "windows git" are used and sometimes cygwin's tools.

ncannasse commented 7 years ago

I tried uninstalling Windows GIT and use Cygwin GIT instead, with no luck.

fdopen commented 7 years ago

Can you post the output of

env
cygcheck -c
ncannasse commented 7 years ago
D:\Projects\hxtools\ocamhaxe>env
!::=::\
!C:=C:\Users\Nico
!D:=D:\Projects\hxtools\ocamhaxe
!ExitCode=00000000
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Nico\AppData\Roaming
COMMONPROGRAMFILES=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-9GM3BLU
COMSPEC=C:\WINDOWS\system32\cmd.exe
HOMEDRIVE=C:
HOMEPATH=\Users\Nico
LOCALAPPDATA=C:\Users\Nico\AppData\Local
LOGONSERVER=\\DESKTOP-9GM3BLU
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
PATH=/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/TortoiseGit/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin:/cygdrive/c/Users/Nico/AppData/Local/Microsoft/WindowsApps
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=5e03
ProgramData=C:\ProgramData
PROGRAMFILES=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINDOWS
TEMP=/cygdrive/c/Users/Nico/AppData/Local/Temp
TMP=/cygdrive/c/Users/Nico/AppData/Local/Temp
USERDOMAIN=DESKTOP-9GM3BLU
USERDOMAIN_ROAMINGPROFILE=DESKTOP-9GM3BLU
USERNAME=Nico
USERPROFILE=C:\Users\Nico
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
WINDIR=C:\WINDOWS
TERM=cygwin
HOME=/home/Nico
D:\Projects\hxtools\ocamhaxe>cygcheck -c
Cygwin Package Information
Package                                 Version                Status
_autorebase                             001006-1               OK
alternatives                            1.3.30c-10             OK
base-cygwin                             3.8-1                  OK
base-files                              4.2-4                  OK
bash                                    4.4.12-3               OK
bzip2                                   1.0.6-3                OK
ca-certificates                         2.16-1                 OK
coreutils                               8.26-2                 OK
csih                                    0.9.9-1                OK
curl                                    7.55.1-1               OK
cygrunsrv                               1.62-1                 OK
cygutils                                1.4.16-2               OK
cygwin                                  2.9.0-3                OK
dash                                    0.5.9.1-1              OK
desktop-file-utils                      0.23-1                 OK
diffutils                               3.5-2                  OK
editrights                              1.03-1                 OK
file                                    5.30-1                 OK
findutils                               4.6.0-1                OK
gamin                                   0.1.10-15              OK
gawk                                    4.1.4-3                OK
getent                                  2.18.90-4              OK
git                                     2.14.1-1               OK
grep                                    3.0-2                  OK
groff                                   1.22.3-1               OK
gsettings-desktop-schemas               3.24.1-1               OK
gzip                                    1.8-1                  OK
hostname                                3.13-1                 OK
info                                    6.5-1                  OK
ipc-utils                               1.0-2                  OK
less                                    487-1                  OK
libargp                                 20110921-3             OK
libattr1                                2.4.46-1               OK
libblkid1                               2.25.2-2               OK
libbz2_1                                1.0.6-3                OK
libcom_err2                             1.42.12-2              OK
libcrypt0                               2.1-1                  OK
libcurl4                                7.55.1-1               OK
libdb5.3                                5.3.28-1               OK
libedit0                                20130712-1             OK
libexpat1                               2.2.3-1                OK
libfam0                                 0.1.10-15              OK
libffi6                                 3.2.1-2                OK
libgc1                                  7.6.0-1                OK
libgcc1                                 6.4.0-1                OK
libgdbm4                                1.12-1                 OK
libglib2.0_0                            2.52.3-1               OK
libgmp10                                6.1.2-1                OK
libgnutls28                             3.3.27-1               OK
libgnutls30                             3.5.13-1               OK
libgssapi_krb5_2                        1.14.4-1               OK
libguile17                              1.8.8-3                OK
libguile2.0_22                          2.0.14-1               OK
libhogweed2                             2.7.1-1                OK
libhogweed4                             3.3-1                  OK
libiconv                                1.14-3                 OK
libiconv2                               1.14-3                 OK
libidn2_0                               2.0.2-1                OK
libintl8                                0.19.8.1-2             OK
libisl13                                0.14.1-1               OK
libk5crypto3                            1.14.4-1               OK
libkrb5_3                               1.14.4-1               OK
libkrb5support0                         1.14.4-1               OK
libltdl7                                2.4.6-5                OK
liblzma5                                5.2.3-1                OK
libmetalink3                            0.1.2-1                OK
libmpc3                                 1.0.3-1                OK
libmpfr4                                3.1.5-1p10             OK
libncursesw10                           6.0-11.20170617        OK
libnettle4                              2.7.1-1                OK
libnettle6                              3.3-1                  OK
libnghttp2_14                           1.23.1-1               OK
libopenldap2_4_2                        2.4.42-1               OK
libopenssl100                           1.0.2k-1               OK
libp11-kit0                             0.23.5-1               OK
libpcre1                                8.40-3                 OK
libpipeline1                            1.4.0-1                OK
libpopt-common                          1.16-2                 OK
libpopt0                                1.16-2                 OK
libpsl5                                 0.18.0-1               OK
libreadline7                            7.0.3-3                OK
libsasl2_3                              2.1.26-11              OK
libsigsegv2                             2.10-2                 OK
libsmartcols1                           2.25.2-2               OK
libssh2_1                               1.7.0-1                OK
libssp0                                 6.4.0-1                OK
libstdc++6                              6.4.0-1                OK
libtasn1_6                              4.12-1                 OK
libunistring2                           0.9.6-1                OK
libuuid1                                2.25.2-2               OK
libxml2                                 2.9.4-2                OK
login                                   1.11-1                 OK
make                                    4.2.1-2                OK
man-db                                  2.7.5-2                OK
mingw64-i686-binutils                   2.25.0.1.23f238d-1     OK
mingw64-i686-gcc-core                   5.4.0-4                OK
mingw64-i686-gcc-g++                    5.4.0-4                OK
mingw64-i686-headers                    5.0.2-1                OK
mingw64-i686-libzip                     0.11.2-2               OK
mingw64-i686-pcre                       8.40-3                 OK
mingw64-i686-pcre2                      10.23-2                OK
mingw64-i686-pkg-config                 0.29.1-1               OK
mingw64-i686-runtime                    5.0.2-1                OK
mingw64-i686-windows-default-manifest   6.4-1                  OK
mingw64-i686-winpthreads                5.0.2-1                OK
mingw64-i686-zlib                       1.2.11-1               OK
mingw64-x86_64-binutils                 2.25.0.1.23f238d-1     OK
mingw64-x86_64-gcc-core                 5.4.0-3                OK
mingw64-x86_64-gcc-g++                  5.4.0-3                OK
mingw64-x86_64-headers                  5.0.2-1                OK
mingw64-x86_64-pcre                     8.40-3                 OK
mingw64-x86_64-pkg-config               0.29.1-1               OK
mingw64-x86_64-runtime                  5.0.2-1                OK
mingw64-x86_64-windows-default-manifest 6.4-1                  OK
mingw64-x86_64-winpthreads              5.0.2-1                OK
mingw64-x86_64-zlib                     1.2.11-1               OK
mintty                                  2.7.9-0                OK
ncurses                                 6.0-11.20170617        OK
openssh                                 7.5p1-1                OK
openssl                                 1.0.2k-1               OK
p11-kit                                 0.23.5-1               OK
p11-kit-trust                           0.23.5-1               OK
patch                                   2.7.4-1                OK
perl                                    5.22.4-1               OK
perl-Carp                               1.38-1                 OK
perl-Error                              0.17025-1              OK
perl-TermReadKey                        2.37-1                 OK
perl_autorebase                         5.22.4-1               OK
perl_base                               5.22.4-1               OK
pkg-config                              0.29.1-1               OK
publicsuffix-list-dafsa                 20170828-1             OK
rebase                                  4.4.2-1                OK
rsync                                   3.1.2-1                OK
run                                     1.3.4-2                OK
sed                                     4.4-1                  OK
shared-mime-info                        1.8-1                  OK
tar                                     1.29-1                 OK
terminfo                                6.0-11.20170617        OK
tzcode                                  2016j-1                OK
tzdata                                  2017b-1                OK
unzip                                   6.0-17                 OK
util-linux                              2.25.2-2               OK
vim-minimal                             8.0.1052-1             OK
wget                                    1.19.1-2               OK
which                                   2.20-2                 OK
xz                                      5.2.3-1                OK
zlib0                                   1.2.11-1               OK
fdopen commented 7 years ago

You PATH looks very suspicous. You have a lot of paths in front of /usr/bin, so again, non-cygwin tools might get choosen, where cygwin's tools are expected. Move /usr/bin in front of every thing else. You can normally do it with:

eval $(ocaml-env cygwin --no-opam)
opam init --comp 4.03.0+mingw32 --switch 4.03.0+mingw32

But it might not work in your case, because your setup looks very suspicious anyway. Where is opam installed? It's normally inside /usr/local/bin which is missing from your PATH. Where is flexlink installed? Also m4 is not installed, so you won't be able to use ocamlfind.

ncannasse commented 7 years ago

opam / flexlink are in the ocamhaxe/bin directory (local ./bin)

I did the following:

D:\Projects\hxtools\ocamhaxe>set PATH=c:/progra~1/cygwin/bin;d:/projects/hxtools/ocamhaxe/bin;%PATH%
D:\Projects\hxtools\ocamhaxe>opam init --comp 4.03.0+mingw32 --switch 4.03.0+mingw32
Checking for available remotes: none.
  - you won't be able to use rsync and local repositories unless you install the rsync command on your system.
  - you won't be able to use git repositories unless you install the git command on your system.
  - you won't be able to use mercurial repositories unless you install the hg command on your system.
  - you won't be able to use darcs repositories unless you install the darcs command on your system.

[WARNING] No external solver found, one of aspucd, packup and mccs is recommended (see
          http://opam.ocaml.org/doc/Install.html#ExternalSolvers for details)
[WARNING] Recommended dependencies -- most packages rely on these:
            - make
            - m4
            - cc

[ERROR] Missing dependencies -- the following commands are required for OPAM to operate:
          - curl or wget
          - patch
          - tar
          - unzip

[ERROR] Initialisation failed
OpamStd.OpamSys.Exit(66)

Which is an error I already reported here https://github.com/ocaml/opam/issues/2896

So for the tools to be found I need to run opam from bash:

>bash -c "opam init --comp 4.03.0+mingw32 --switch 4.03.0+mingw32"

... and it seems to work !

Looks like indeed there was some other *nix tool in the PATH that was taking precedence over the cygwin one, I'll look into it to see what it might be and update my ocamhaxe script to enforce cygwin as the first in PATH, thanks for the help.