ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.23k stars 351 forks source link

`make cold` on Windows: inconsistent assumptions over implementation Stdlib__Sys #5628

Closed talex5 closed 1 year ago

talex5 commented 1 year ago

I'm trying to follow the instructions at https://opam.ocaml.org/blog/opam-2-2-0-alpha2/ to install opam 2.2 on Windows (as there didn't seem to be any Windows binaries at https://github.com/ocaml/opam/releases/tag/2.2.0-alpha2).

I started with a VM with OCaml 4.14 and cygwin pre-installed. I used the cygwin GUI to install the requested packages and then ran make cold. That failed after a bit with:

[...]
checking for x86_64-w64-mingw32-i686-w64-mingw32-gcc... no
checking for i686-w64-mingw32-gcc... no
configure: error: amd64 C compiler not found - opam-putenv cannot be built

I then used the cygwin GUI to install the main gcc package and also mingw64-i686-gcc-g++ (it wasn't clear to me if both were needed or not, but the configure script was checking for both so I installed both).

Then I did make clean and make cold, which ran for a while and then failed with:

../../ocamlopt.opt.exe -g -nostdlib -I ../../stdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66-70 -warn-err
or +A -bin-annot -safe-string -strict-formats -I byte -I native -pack -o native/dynlink_compilerlibs.cmx dynlink_compilerlibs/binuti
ls.cmx dynlink_compilerlibs/config.cmx dynlink_compilerlibs/build_path_prefix_map.cmx dynlink_compilerlibs/misc.cmx dynlink_compiler
libs/identifiable.cmx dynlink_compilerlibs/numbers.cmx dynlink_compilerlibs/arg_helper.cmx dynlink_compilerlibs/clflags.cmx dynlink_
compilerlibs/profile.cmx dynlink_compilerlibs/consistbl.cmx dynlink_compilerlibs/terminfo.cmx dynlink_compilerlibs/warnings.cmx dynl
ink_compilerlibs/local_store.cmx dynlink_compilerlibs/load_path.cmx dynlink_compilerlibs/int_replace_polymorphic_compare.cmx dynlink
_compilerlibs/lazy_backtrack.cmx dynlink_compilerlibs/location.cmx dynlink_compilerlibs/longident.cmx dynlink_compilerlibs/docstring
s.cmx dynlink_compilerlibs/syntaxerr.cmx dynlink_compilerlibs/ast_helper.cmx dynlink_compilerlibs/ast_mapper.cmx dynlink_compilerlib
s/attr_helper.cmx dynlink_compilerlibs/builtin_attributes.cmx dynlink_compilerlibs/ident.cmx dynlink_compilerlibs/path.cmx dynlink_c
ompilerlibs/primitive.cmx dynlink_compilerlibs/type_immediacy.cmx dynlink_compilerlibs/shape.cmx dynlink_compilerlibs/types.cmx dynl
ink_compilerlibs/btype.cmx dynlink_compilerlibs/subst.cmx dynlink_compilerlibs/predef.cmx dynlink_compilerlibs/datarepr.cmx dynlink_
compilerlibs/cmi_format.cmx dynlink_compilerlibs/persistent_env.cmx dynlink_compilerlibs/env.cmx dynlink_compilerlibs/debuginfo.cmx 
dynlink_compilerlibs/lambda.cmx dynlink_compilerlibs/runtimedef.cmx dynlink_compilerlibs/instruct.cmx dynlink_compilerlibs/opcodes.c
mx dynlink_compilerlibs/bytesections.cmx dynlink_compilerlibs/dll.cmx dynlink_compilerlibs/meta.cmx dynlink_compilerlibs/symtable.cm
x dynlink_compilerlibs/asttypes.cmx dynlink_compilerlibs/parsetree.cmx dynlink_compilerlibs/outcometree.cmx dynlink_compilerlibs/cmo
_format.cmx dynlink_compilerlibs/cmxs_format.cmx
File "/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1/otherlibs/dynlink/native/dynlink_compilerlibs.cmx", lin
e 1:
Error: Files /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1/otherlibs/dynlink/dynlink_compilerlibs/config.cm
x
       and /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1/otherlibs/dynlink/dynlink_compilerlibs/binutils.cm
x
       make inconsistent assumptions over implementation Stdlib__Sys
make[5]: *** [Makefile:198: native/dynlink_compilerlibs.cmx] Error 2
make[5]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1/otherlibs/dynlink'
make[4]: *** [Makefile:35: allopt] Error 2
make[4]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1/otherlibs'
make[3]: *** [Makefile:964: otherlibrariesopt] Error 2
make[3]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1'
make[2]: *** [Makefile:254: opt.opt] Error 2
make[2]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1'
make[1]: *** [Makefile:312: world.opt] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml-4.14.1'
make: *** [Makefile:278: compiler] Error 2
kit-ty-kate commented 1 year ago

I started with a VM with OCaml 4.14

it looks like it picked up something from your already installed OCaml. Could you list the environment variables that are present?

talex5 commented 1 year ago
talex5@vdi3 ~
$ env
ProgramFiles(x86)=C:\Program Files (x86)
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
!C:=C:\Users\talex5
!ExitCode=00000000
SHELL=c:\windows\system32\cmd.exe
NUMBER_OF_PROCESSORS=4
PROCESSOR_LEVEL=23
HOSTNAME=vdi3
PROGRAMFILES=C:\Program Files
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
OS=Windows_NT
HOMEDRIVE=C:
USERDOMAIN=WINDOWS
PWD=/cygdrive/c/Users/talex5
USERPROFILE=C:\Users\talex5
LOGNAME=windows\talex5
PRINTER=Microsoft Print to PDF
TZ=Etc/UTC
ALLUSERSPROFILE=C:\ProgramData
ORIGINAL_PATH=/cygdrive/c/OpenSSH-Win64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Window
s/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/OpenSSH:/cygdrive/c/Program Files/WinGet:/cygdrive/c/Program Files/Git/cmd:/cy
gdrive/c/Program Files/dotnet:/cygdrive/c/cygwin/usr/bin:/cygdrive/c/ocamlmgw64/bin:/cygdrive/c/Program Files/vim/vim90:/cygdrive/c/Program F
iles/Microsoft VS Code/bin:/usr/local/bin:/cygdrive/c/Users/talex5/AppData/Local/Microsoft/WindowsApps
CommonProgramW6432=C:\Program Files\Common Files
HOME=/cygdrive/c/Users/talex5
USERNAME=talex5
LANG=en_US.UTF-8
OneDrive=C:\Users\talex5\OneDrive
COMSPEC=C:\Windows\system32\cmd.exe
APPDATA=C:\Users\talex5\AppData\Roaming
SYSTEMROOT=C:\Windows
LOCALAPPDATA=C:\Users\talex5\AppData\Local
SSH_CONNECTION=...
PROMPT=windows\talex5@VDI3 $P$G
COMPUTERNAME=VDI3
INFOPATH=/usr/local/info:/usr/share/info:/usr/info
TERM=xterm-256color
USER=talex5
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
TEMP=/tmp
SHLVL=1
PROCESSOR_REVISION=0102
DriverData=C:\Windows\System32\Drivers\DriverData
COMMONPROGRAMFILES=C:\Program Files\Common Files
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 1 Stepping 2, AuthenticAMD
PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
SSH_CLIENT=...
HOMEPATH=\Users\talex5
TMP=/tmp
PATH=/usr/local/bin:/usr/bin:/cygdrive/c/OpenSSH-Win64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cy
gdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Windows/System32/OpenSSH:/cygdrive/c/Program Files/WinGet:/cygdrive/c/Program Fi
les/Git/cmd:/cygdrive/c/Program Files/dotnet:/cygdrive/c/cygwin/usr/bin:/cygdrive/c/ocamlmgw64/bin:/cygdrive/c/Program Files/vim/vim90:/cygdr
ive/c/Program Files/Microsoft VS Code/bin:/usr/local/bin:/cygdrive/c/Users/talex5/AppData/Local/Microsoft/WindowsApps
ProgramW6432=C:\Program Files
PROFILEREAD=true
SSH_TTY=windows-pty
WINDIR=C:\Windows
PROCESSOR_ARCHITECTURE=AMD64
OPAMROOT=c:\opam
PUBLIC=C:\Users\Public
SYSTEMDRIVE=C:
EXECIGNORE=*.dll
OLDPWD=/cygdrive/c/Users/talex5
ProgramData=C:\ProgramData
_=/usr/bin/env
kit-ty-kate commented 1 year ago

What happens if you remove /cygdrive/c/ocamlmgw64/bin: from your PATH, followed by git clean -xdf and make cold?

talex5 commented 1 year ago

Then I hit https://github.com/ocaml/opam/issues/5600:

checking for flexdll sources... no
checking for flexlink... flexlink
checking whether flexlink works... no
configure: error: flexlink does not work
make: *** [Makefile:278: compiler] Error 1

I then used cygwin to install flexdll, but that didn't make any difference.

kit-ty-kate commented 1 year ago

it looks like the ocaml configure script is detecting a flexlink.exe in your PATH. Could you try removing it and also uninstall flexdll?

talex5 commented 1 year ago

I emptied /usr/local/bin, which had some flexlink stuff and also removed the flexdll package. But there's still one copy present and doing make cold still fails as before:

$ which flexlink
/cygdrive/c/ocamlmgw64/bin/flexlink

$ rm -rf opam-full-2.2.0-alpha2

$ tar xf opam-full-2.2.0-alpha2.tar.gz 

$ cd opam-full-2.2.0-alpha2

$ make cold
[...]
checking for flexdll sources... no
checking for flexlink... flexlink
checking whether flexlink works... no
configure: error: flexlink does not work
make: *** [Makefile:278: compiler] Error 1
kit-ty-kate commented 1 year ago

could you remove /cygdrive/c/ocamlmgw64/bin/ from your PATH again so it can't find flexlink at all?

talex5 commented 1 year ago

Oops! I logged out and forgot to update it again. Retrying got a lot further:

$ export PATH=$(echo $PATH | sed 's!/cygdrive/c/ocamlmgw64/bin:!!')
$ make cold
[...]
File "src/stubs/libacl/opamlibACL.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "src_ext/dose3/src/common/dune", line 16, characters 0-255:
16 | (rule
17 |  (targets gitVersionInfo.ml)
18 |  ; Ensures the hash update whenever a source file is modified ;
19 |  (deps
20 |   (source_tree %{workspace_root}/.git)
21 |   (:script get-git-info.mlt))
22 |  (action
23 |   (with-stdout-to
24 |    %{targets}
25 |    (run %{ocaml} unix.cma %{script}))))
Cannot load required shared library dllunix.
Reason: dllunix.so: dynamic loading not supported on this platform.
make[1]: *** [Makefile:144: build-opam] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2'
make: *** [Makefile:285: cold] Error 2
kit-ty-kate commented 1 year ago

mmh, does the directory /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml contain a directory named flexdll or a file named 0.42.tar.gz ?

If they aren't here (or actually in any case) could you add set -x to ./shell/bootstrap-ocaml.sh and call make compiler and post the result of the script (maybe comment the make invocations before to speed up the test and clean up the log)

talex5 commented 1 year ago

mmh, does the directory /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml contain a directory named flexdll or a file named 0.42.tar.gz ?

No (and not in any subdirectories either):

$ ls /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml
bin  lib  man  share

Here is the result of make compiler with make disabled and the extra logging:

$ export PATH=$(echo $PATH | sed 's!/cygdrive/c/ocamlmgw64/bin:!!')
$ make compiler
env MAKE=make BOOTSTRAP_EXTRA_OPTS= BOOTSTRAP_TARGETS=world.opt BOOTSTRAP_ROOT=.. BOOTSTRAP_DIR=bootstrap ./shell/bootstrap-ocaml.sh

+ GEN_CONFIG_ONLY=0
+ command -v curl
+ CURL='curl -OLSfs'
+ BOOTSTRAP_DIR=bootstrap
+ BOOTSTRAP_ROOT=..
+ BOOTSTRAP_TARGETS=world.opt
+ mkdir -p bootstrap
+ cd bootstrap
++ sed -ne 's/URL_ocaml *= *//p' ../src_ext/Makefile
++ tr -d '\r'
+ URL=https://caml.inria.fr/pub/distrib/ocaml-4.14/ocaml-4.14.1.tar.gz
++ sed -ne 's/MD5_ocaml *= *//p' ../src_ext/Makefile
++ tr -d '\r'
+ MD5=c45b013a233c9a4b80c3930d723d19dd
++ echo https://caml.inria.fr/pub/distrib/ocaml-4.14/ocaml-4.14.1.tar.gz
++ sed -e 's|.*/\([^/]*\)\.tar\.gz|\1|'
+ V=ocaml-4.14.1
++ sed -ne 's/URL_flexdll *= *//p' ../src_ext/Makefile
++ tr -d '\r'
+ FV_URL=https://github.com/ocaml/flexdll/archive/0.43.tar.gz
++ echo https://github.com/ocaml/flexdll/archive/0.43.tar.gz
++ sed -e 's|.*/\([^/]*\)|\1|'
+ FLEXDLL=0.43.tar.gz
+ '[' '!' -e ocaml-4.14.1.tar.gz ']'
++ openssl md5 ocaml-4.14.1.tar.gz
++ cut -f 2 -d ' '
+ ACTUALMD5=c45b013a233c9a4b80c3930d723d19dd
+ '[' -z c45b013a233c9a4b80c3930d723d19dd ']'
+ '[' c45b013a233c9a4b80c3930d723d19dd '!=' c45b013a233c9a4b80c3930d723d19dd ']'
+ '[' 0 -eq 0 ']'
+ tar -zxf ocaml-4.14.1.tar.gz
+ cd ocaml-4.14.1
+ PATH_PREPEND=
+ LIB_PREPEND=
+ INC_PREPEND=
+ '[' -n '' -a -n 'C:\Windows\system32\cmd.exe' -a -x 'C:\Windows\system32\cmd.exe' ']'
++ cd ..
++ pwd
+ PREFIX=/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml
+ '[' 0 -eq 0 ']'
+ ./configure --prefix /cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml --disable-stdlib-manpages
configure: Configuring OCaml version 4.14.1
checking build system type... x86_64-pc-cygwin
checking host system type... x86_64-pc-cygwin
checking target system type... x86_64-pc-cygwin
checking for ld... ld
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... ld
checking if the linker (ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking how to convert x86_64-pc-cygwin file names to x86_64-pc-cygwin format... func_convert_file_noop
checking how to convert x86_64-pc-cygwin file names to toolchain format... func_convert_file_noop
checking for ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for dlltool... dlltool
checking how to associate runtime and link libraries... func_cygming_dll_for_implib
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking C compiler vendor... gcc-11-4
checking whether host executables can be run in the build... yes
checking whether #! works in shell scripts... yes
checking for flexdll sources... no
checking for flexlink... no
checking flexdll.h usability... yes
checking flexdll.h presence... yes
checking for flexdll.h... yes
configure: WARNING: flexlink not found: shared library support disabled.
checking for a BSD-compatible install... /usr/bin/install -c
checking for cos in -lm... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
checking for dirent.h... yes
checking for sys/select.h... yes
checking for off_t... yes
checking size of int... 4
checking size of long... 8
checking size of long *... 8
checking size of short... 2
checking size of long long... 8
configure: Target is a 64 bits architecture
checking whether byte ordering is bigendian... no
checking alignment of double... 8
checking alignment of long... 8
checking alignment of long long... 8
checking whether the C compiler supports -fno-tree-vrp... yes
checking whether the C compiler supports __attribute__((aligned(n)))... yes
checking whether the C compiler supports __attribute__((optimize("tree-vectorize")))... yes
checking for ld... ld
checking for rlwrap... no
configure: checking semantics of signal handlers
checking for sigaction... yes
checking for sigprocmask... yes
configure: POSIX signal handling found.
checking for expm1... yes
checking for log1p... yes
checking for hypot... yes
checking for fma... yes
checking for exp2... yes
checking for log2... yes
checking for cbrt... yes
checking for acosh... yes
checking for asinh... yes
checking for atanh... yes
checking for erf... yes
checking for erfc... yes
checking for trunc... yes
checking for round... yes
checking for copysign... yes
checking whether round works... yes
checking whether fma works... no
configure: WARNING: fma does not work; emulation enabled
checking for getrusage... yes
checking for times... yes
checking for secure_getenv... yes
checking for issetugid... yes
checking for library containing clock_gettime... none required
checking for socket... yes
checking for socketpair... yes
checking for bind... yes
checking for listen... yes
checking for accept... yes
checking for connect... yes
checking for socklen_t... yes
checking for inet_aton... yes
checking for struct sockaddr_in6... yes
checking for getaddrinfo... yes
checking for getnameinfo... yes
checking for inet_pton... yes
checking for inet_ntop... yes
checking for rewinddir... yes
checking for lockf... yes
checking for mkfifo... yes
checking for getcwd... yes
checking whether system is declared... yes
checking for sys/types.h... (cached) yes
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking for utime... yes
checking for utimes... yes
checking for fchmod... yes
checking for fchown... yes
checking for truncate... yes
checking for ftruncate... yes
checking for select... yes
checking for fd_set... yes
checking for nanosleep... yes
checking for symlink... yes
checking for readlink... yes
checking for lstat... yes
checking for realpath... yes
checking for waitpid... yes
checking for wait4... yes
checking for getgroups... yes
checking for setgroups... yes
checking for initgroups... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for tcgetattr... yes
checking for tcsetattr... yes
checking for tcsendbreak... yes
checking for tcflush... yes
checking for tcflow... yes
checking for setitimer... yes
checking for gethostname... yes
checking sys/utsname.h usability... yes
checking sys/utsname.h presence... yes
checking for sys/utsname.h... yes
checking for uname... yes
checking for gettimeofday... yes
checking for mktime... yes
checking for putenv... yes
checking for setenv... yes
checking for unsetenv... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for newlocale... yes
checking for freelocale... yes
checking for uselocale... yes
checking xlocale.h usability... no
checking xlocale.h presence... no
checking for xlocale.h... no
checking for strtod_l... yes
configure: Dynamic loading of shared libraries is not supported.
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking for mmap... yes
checking for munmap... yes
checking for pwrite... yes
checking whether the C compiler supports -fdebug-prefix-map... yes
checking for struct stat.st_atim.tv_nsec... yes
configure: stat supports nanosecond precision
checking how many arguments gethostbyname_r() takes... cannot find function declaration in netdb.h
checking how many arguments gethostbyaddr_r() takes... cannot find function declaration in netdb.h
checking for mkstemp... yes
checking for nice... yes
checking for dup3... yes
checking for pipe2... yes
checking for accept4... yes
checking for getauxval... no
checking sys/shm.h usability... yes
checking sys/shm.h presence... yes
checking for sys/shm.h... yes
checking for shmat... yes
checking for execvpe... yes
checking spawn.h usability... yes
checking spawn.h presence... yes
checking for spawn.h... yes
checking for posix_spawn... yes
checking for posix_spawnp... yes
checking for ffs... yes
checking for _BitScanForward... yes
configure: replay debugger supported
checking whether stack overflows can be detected... no
checking whether gcc is Clang... no
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... no
configure: the POSIX threads library is supported
checking for sigwait... yes
checking whether the assembler supports --debug-prefix-map... no
checking whether the assembler supports CFI directives... yes
configure: not using frame pointers
checking whether mmap supports huge pages... no
configure: No support for function sections on x86_64-pc-cygwin.
configure: Disabling function sections.
configure: creating ./config.status
config.status: creating Makefile.build_config
config.status: creating Makefile.config
config.status: creating stdlib/sys.ml
config.status: creating manual/src/version.tex
config.status: creating manual/src/html_processing/src/common.ml
config.status: creating tools/eventlog_metadata
config.status: creating runtime/caml/m.h
config.status: runtime/caml/m.h is unchanged
config.status: creating runtime/caml/s.h
config.status: runtime/caml/s.h is unchanged
config.status: creating runtime/caml/version.h
config.status: runtime/caml/version.h is unchanged
config.status: executing libtool commands
+ for target in $BOOTSTRAP_TARGETS
+ echo make -j world.opt
make -j world.opt
+ echo make install
make install
+ OCAMLLIB=/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml/lib/ocaml
+ '[' 0 -eq 0 ']'
+ echo 'https://caml.inria.fr/pub/distrib/ocaml-4.14/ocaml-4.14.1.tar.gz https://github.com/ocaml/flexdll/archive/0.43.tar.gz'      
++ echo ''
++ sed -e 's/#/\\#/g' -e 's/\$/$$/g'
+ PATH_PREPEND=
+ echo 'export PATH:=/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml/bin:$(PATH)'
+ '[' -n '' ']'
+ '[' -n '' ']'
+ echo 'export OCAMLLIB=/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/bootstrap/ocaml/lib/ocaml'
+ echo 'unexport CAML_LD_LIBRARY_PATH'
+ echo 'unexport OPAM_SWITCH_PREFIX'
kit-ty-kate commented 1 year ago

Thanks a lot for that, it was really helpful! Could you try with the following diff?

diff --git a/Makefile b/Makefile
index 0c79f5a28..922e0c584 100644
--- a/Makefile
+++ b/Makefile
@@ -267,11 +267,9 @@ release-%:

 ifeq ($(OCAML_PORT),)
 ifneq ($(COMSPEC),)
-ifeq ($(shell which gcc 2>/dev/null),)
 OCAML_PORT=auto
 endif
 endif
-endif

 .PHONY: compiler cold
 compiler:

If the ocaml configure script doesn't show configure: Dynamic loading of shared libraries is not supported. you should be good to go ahead and try a full make cold again (don't forget to uncomment the calls to make you commented earlier)

talex5 commented 1 year ago

Gets quite a long way with that (BTW, I'm testing with PATH back to its original value now), but:

talex5@vdi3 ~
$ tar xf opam-full-2.2.0-alpha2.tar.gz 

talex5@vdi3 ~
$ cd opam-full-2.2.0-alpha2

talex5@vdi3 ~/opam-full-2.2.0-alpha2
$ patch < ../patch 
patching file Makefile

talex5@vdi3 ~/opam-full-2.2.0-alpha2
$ make cold
[...]
checking for flexdll sources... $(ROOTDIR)/flexdll
checking for flexlink... flexlink
checking flexdll.h usability... yes
checking flexdll.h presence... yes
checking for flexdll.h... yes
[...]
Opam will be built WITH its default built-in solver

Executables will be installed in /usr/local/bin
Manual pages will be installed in /usr/local/share/man

Downloading vendored source dependencies...
done
Extracting vendored source dependencies in src_ext/... done
env PATH="`pwd`/bootstrap/ocaml/bin:$PATH" CAML_LD_LIBRARY_PATH= make
make[1]: Entering directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2'
cd src_ext/dune-local && ocaml bootstrap.ml
ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot unix.cma boot/libs.ml boot/duneboot.ml
.\.duneboot.exe
/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2/src_ext/dune-local/dune.exe build --profile=release --root .  --promote-insta
ll-files -- opam-installer.install opam.install
fatal: not a git repository (or any parent up to mount point /cygdrive)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /cygdrive)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
File "doc/man/opam-admin-topics.inc", line 25, characters 0-390:
25 | (rule
26 |   (targets opam-admin-add-constraint.1 opam-admin-add-constraint.err)
27 |   (deps using-built-opam)
28 |   (action (progn (with-stderr-to opam-admin-add-constraint.err
29 |                    (with-stdout-to opam-admin-add-constraint.1 (run %{bin:opam} admin add-constraint --help=groff)))    
30 |                  (diff opam-admin-add-constraint.err %{dep:opam-admin-add-constraint.0})))
31 |   (package opam))
Command exited with code -1073741515.
[...]
Command exited with code -1073741515.
make[1]: *** [Makefile:144: build-opam] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/talex5/opam-full-2.2.0-alpha2'
make: *** [Makefile:283: cold] Error 2
kit-ty-kate commented 1 year ago

What does ./_build/install/bin/opam.exe admin add-constraint --help=groff give you? (or if ./_build/install/bin/opam.exe doesn’t exist, ./_build/default/src/client/opamMain.exe should be there)

kit-ty-kate commented 1 year ago

Command exited with code -1073741515.

I looked around and this exit code seems to be related to a "missing DLL" so it would be good to know which one is missing. The command above should tell you that hopefully.

talex5 commented 1 year ago
$ ./_build/install/bin/opam.exe admin add-constraint --help=groff
bash: ./_build/install/bin/opam.exe: No such file or directory

$ ./_build/install/default/bin/opam.exe admin add-constraint --help=groff
C:/Users/talex5/opam-full-2.2.0-alpha2/_build/install/default/bin/opam.exe: error while loading shared libraries: libstdc++
-6.dll: cannot open shared object file: No such file or directory

$ ./_build/default/src/client/opamMain admin add-constraint --help=groff
C:/Users/talex5/opam-full-2.2.0-alpha2/_build/default/src/client/opamMain.exe: error while loading shared libraries: libstd
c++-6.dll: cannot open shared object file: No such file or directory
kit-ty-kate commented 1 year ago

$ ./_build/install/default/bin/opam.exe admin add-constraint --help=groff C:/Users/talex5/opam-full-2.2.0-alpha2/_build/install/default/bin/opam.exe: error while loading shared libraries: libstdc++-6.dll: cannot open shared object file: No such file or directory

I believe this should be fixed by the Hint section in https://opam.ocaml.org/blog/opam-2-2-0-alpha2/#How-to-Test-opam-on-Windows I'm not entirely sure how to improve this after reading https://github.com/ocaml/opam/pull/3255. Maybe we could link those libraries statically instead.

kit-ty-kate commented 1 year ago

If you're struggling, going the MSVC route instead (i.e. installing Visual Studio and calling make cold OCAML_PORT=msvc64 worked fine for me locally, where it didn't with MinGW.

talex5 commented 1 year ago

Closing, as the original issue is fixed. I'll have another go later.