aantron/dream

Failed to compile with ocaml 4.12.x, okay with ocaml 4.13.x

pyx opened this issue · 5 comments

pyx commented

All examples failed to compile with:

  • opam 2.1.2 with ocaml 4.14.0
  • gcc (Gentoo 11.2.1_p20220115 p4) 11.2.1 20220115
  • esy 0.6.12-dev
gcc -c -O2 -fno-strict-aliasing -fwrapv -Wall -Wdeclaration-after-statement -fno-common -fexcess-precision=standard -fno-tree-vrp -ffunction-sections -g  -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE   -DCAMLDLLIMPORT= -DNATIVE_CODE -DTARGET_amd64 -DMODEL_default -DSYS_linux   -o freelist.n.o freelist.c
    signals_nat.c:184:13: error: variably modified 'sig_alt_stack' at file scope
      184 | static char sig_alt_stack[SIGSTKSZ];
          |             ^~~~~~~~~~~~~
    make[3]: *** [Makefile:367: signals_nat.n.o] Error 1
    make[3]: *** Waiting for unfinished jobs....
    make[3]: Leaving directory '/home/pyx/.esy/3/b/ocaml-4.12.0-bfdfbfff/runtime'
    make[2]: *** [Makefile:765: makeruntimeopt] Error 2
    make[2]: Leaving directory '/home/pyx/.esy/3/b/ocaml-4.12.0-bfdfbfff'
    make[1]: *** [Makefile:215: opt.opt] Error 2
    make[1]: Leaving directory '/home/pyx/.esy/3/b/ocaml-4.12.0-bfdfbfff'
    make: *** [Makefile:275: world.opt] Error 2
    error: command failed: './esy-build' (exited with 2)
    esy-build-package: exiting with errors above...
    
  building ocaml@4.12.0
esy: exiting due to errors above

Works fine when I changed the ocaml version to 4.13.x in esy.json

  "dependencies": {
    "@opam/dream": "1.0.0~alpha4",
    "@opam/dune": "^2.0",
    "ocaml": "4.13.x"
  },

@pyx, based on the log, this appears to be an error during compiling the OCaml compiler itself (rather than Dream or another library). Could you report it at https://github.com/ocaml/ocaml/issues/new?

Also, to clarify,

  • opam 2.1.2 with ocaml 4.14.0

It appears that you are using esy rather than opam, and OCaml 4.12.0 rather than 4.14.0. Can you confirm?

pyx commented

@pyx, based on the log, this appears to be an error during compiling the OCaml compiler itself (rather than Dream or another library). Could you report it at https://github.com/ocaml/ocaml/issues/new?

Also, to clarify,

  • opam 2.1.2 with ocaml 4.14.0

It appears that you are using esy rather than opam, and OCaml 4.12.0 rather than 4.14.0. Can you confirm?

Hi Anton,

Thank you for the reply, I am getting back into OCaml after quite a few years, so esy is new to me.

My system's (gentoo linux, ~amd64) default installation of OCaml now is 4.14.0, and I also have Opam 2.1.2 installed, both from gentoo's official repository. I was guessing esy is some kind of make/build/packaging tool that's using Opam so that version information of Opam and OCaml would help.

You are right that it is a problem in compiling OCaml 4.12.x in my system, I am reporting here in case that it is due to some kind of incompatible upgrade in the tool chain that requiring different OCaml version. For example, application A works (think syntax) with compiler C 1.0+, while the build tool B that's been upgraded recently requiring C 2.0+ because it will cause C1.0 failed to build since C itself also use B to bootstrap, in that case, upgrading the build dependency (the requiring version) might be the way to go.

Since I am just getting back into OCaml, I don't have enough understanding of esy, dream, latest opam, dune, and OCaml's new features since around 4.08, to tell if it is the dependency hell situation I mentioned, or it is the problem in my system, now that it seems the problem has nothing to do with dream, please feel free to close this issue.

BTW, I've been waiting for a good web framework in OCaml for the longest time, (not that Opium and Ocsigen weren't good, I never have the stamina to go beyond the first few chapters of Ocsigen's tutorial 😂), thank you for dream.

EDIT:
I was using esy to build the examples, as mentioned in the README:

$ npm install esy && npx esy
$ npx esy start

and esy in turn builds OCaml 4.12.0 as required in esy.json, and failed.

It works with OCaml 4.13.x after I changed the requirement to "4.13.x".

Welcome back :)

The esy build should be fully self-contained. If you are not yet using your system-installed OCaml 4.14 and opam, try removing them. If the esy OCaml 4.12 build still fails, it is definitely a problem with the self-contained 4.12 build (which should be reported upstream AFAIK).

I will check soon for whether the examples support 4.13 (or even 4.14). The reason I left them at 4.12 is that there was some deep dependency in the OCaml packages that was holding everything back. Hopefully, that has been resolved by now, and we can just sidestep this whole issue for the examples :) Thanks for checking 4.13 and reporting on that.

pyx commented

Thank you, I tried 4.14 before trying 4.13, 4.14 failed.

It's good to know that esy is self-contained, it is better to have a standalone development installation of OCaml for a specific project.

But I am old enough to know "left-pad"🤔, for example, I was trying to compile some other examples today, 12 hours later, npx esy start failed with "You cannot require a package ("@npmcli/config") that is not declared in your dependencies...", I know that's unrelated to dream/esy and OCaml, because esy start works fine. It's just too many fast moving parts in JS ecosystem (I am not complaining😂)

I have the examples building with 4.14.1 (though not Gentoo). I realize you observed them failing on 4.14, but at least the examples are not using 4.12 since #256, so I'm going to close this issue for now. Please let me know if you observe build failures on 4.14!