Giter VIP home page Giter VIP logo

Comments (13)

murmour avatar murmour commented on June 12, 2024

I have the same problem on Debian 11, with OCaml 4.14.

from opam-cross-windows.

muqiuhan avatar muqiuhan commented on June 12, 2024

I have the same problem on Manjaro, with OCaml 4.14.0

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

The flexdll.h file should be installed by flexdll-windows. Do y'all have it installed?

$ find ~/.opam/ -name flexdll.h
/home/opam/.opam/4.12.0/lib/flexdll-windows/flexdll.h

from opam-cross-windows.

lonelyfloat avatar lonelyfloat commented on June 12, 2024

I have it installed and it still doesn't work.

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

Hmm indeed I can confirm that the check for flexdll.h fails but allows the ./configure script to keep running when installing via opam inside the mxe cross compilation image:

- checking whether host executables can be run in the build...
- no
- checking whether #! works in shell scripts... yes
- checking for flexdll sources... checking for flexlink... no
- checking flexdll.h usability... no
- checking flexdll.h presence...
- no
- checking for flexdll.h... no
- 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

While it fails outside of it, including when running it manually inside the same image:

checking whether #! works in shell scripts... yes
checking for flexdll sources... no
checking for flexlink... no
checking flexdll.h usability... no
checking flexdll.h presence... no
checking for flexdll.h... no
configure: error: flexdll.h is required for native Win32

Investigating the difference...

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

It looks like the difference is because of the host name: the docker image build uses x86_64-w64-mingw32.static which breaks some of the windows-specific tests in ./configure compared to x86_64-w64-mingw32... 😬

from opam-cross-windows.

shindere avatar shindere commented on June 12, 2024

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

Unfortunately, it also breaks when ran as:

./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32

from opam-cross-windows.

shindere avatar shindere commented on June 12, 2024

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

It is an issue related to cross-compiling the ocaml compiler for mingw-w64 on a linux host.

Steps to reproduce on a clean debian distribution (for instance a docker image) with x86_64 architecture:

  • Install mingw-w64
  • Initialize opam with OCaml 4.14.0
  • Add the ocaml-cross repository:
opam repository add windows https://github.com/ocaml-cross/opam-cross-windows.git
  • Install ocaml-windows

The error relates to the configure script not being able to find flexdll.h. The header and a cross-compiled binary are installed via the flexdll-windows package. However, when pointed directly to its installation location, both binary detection (via $PATH) and header (via $CFLAGS) fail.

Header is accepted b/c the configure script eventually accepts the compiler over the linker but the binary is considered not runnable. The configure script should either know how to run it using wine or simply skip trying to run it when build and host are not the same.

This went unnoticed b/c the automated build images for this are using a different host, as explained above, x86_64-w64-mingw32.static. This non-standard name confuses the configure which turns off requirement for flexdll and makes it pass.

I haven't dived into the build process in a while but, essentially, we do some bootstrapping based off the configure script output and then provide our own Makefile.config and proceed with the final build:

./configure --host=$1

make -C runtime primitives sak SAK_CC=cc SAK_LINK='cc -o $(1) $(2)'

cp `which ocamlrun` runtime/ocamlrun
cp -f Makefile.cross Makefile.config
cp -f s-nt.h runtime/caml/s.h
cp -f m-nt.h runtime/caml/m.h

if grep "WITH_SPACETIME=true" Makefile.config >/dev/null 2>/dev/null; then
  echo "#define WITH_SPACETIME" >> runtime/caml/m.h
  echo "#define WITH_PROFINFO" >> runtime/caml/m.h
fi

make world opt \
  compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa \
  compilerlibs/ocamloptcomp.cmxa driver/main.cmx driver/optmain.cmx \
  PROGRAMS= \
  OCAMLRUN=ocamlrun \
  NEW_OCAMLRUN=ocamlrun

Any suggestion as to how to improve this would be gladly welcome!

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

Working on this. It looks like it should be possible to cross-compile ocaml with the existing configure/makefile system but I haven't found the right magical invocation yet.

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

Happy to report that this is now fixed. I was also able to find a way to build the cross-compiler using the upstream configure/make system, which should make it even more robust and hopefully easy to update to future versions.

from opam-cross-windows.

toots avatar toots commented on June 12, 2024

The issue with host triplet has been fixed upstream. There are a couple more small issues related to flexlink that I might push upstream at some point as well.

from opam-cross-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.