Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dune 3.4+ broken in esy on Windows #6098

Closed
phated opened this issue Aug 24, 2022 · 19 comments · Fixed by #6109 or ocaml/opam-repository#22317
Closed

Dune 3.4+ broken in esy on Windows #6098

phated opened this issue Aug 24, 2022 · 19 comments · Fixed by #6109 or ocaml/opam-repository#22317

Comments

@phated
Copy link

phated commented Aug 24, 2022

Expected Behavior

Dune 3.4+ should build inside esy on Windows.

Actual Behavior

Dune fails to build with this log:

# esy-build-package: building: @opam/dune@opam:3.4.1
# esy-build-package: pwd: C:\Users\grain\.esy\3\b\opam__s__dune-opam__c__3.4.1-4a143223
# esy-build-package: running: "ocaml" "bootstrap.ml" "-j" "4"
ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot unix.cma boot/libs.ml boot/duneboot.ml
.\.duneboot.exe -j 4
cd _boot && C:\Users\grain\.esy\3_\i\ocaml-4.14.0-cd77a8d9\bin\ocamlopt.opt.exe -o ..\dune.exe -g -I +threads unix.cmxa threads.cmxa -no-alias-deps -w -49-6 readdir.c wait3_stubs.c xdg_stubs.c spawn_stubs.c dune_stats_stubs.c fsevents_stubs.c inotify_stubs.c pthread_chdir_stubs.c -args mods_list -cclib -lshell32 -cclib -lole32 -cclib -luuid -alert -unstable
otherlibs/xdg\xdg_stubs.c: In function 'dune_xdg__get_known_folder_path':
otherlibs/xdg\xdg_stubs.c:35:9: warning: implicit declaration of function 'SHGetKnownFolderPath'; did you mean 'SHGetFolderPath'? [-Wimplicit-function-declaration]
otherlibs/xdg\xdg_stubs.c:41:38: error: 'WC_ERR_INVALID_CHARS' undeclared (first use in this function); did you mean 'MB_ERR_INVALID_CHARS'?
otherlibs/xdg\xdg_stubs.c:41:38: note: each undeclared identifier is reported only once for each function it appears in
error: command failed: "ocaml" "bootstrap.ml" "-j" "4"

The issues seem to be SHGetKnownFolderPath and WC_ERR_INVALID_CHARS in the xdg stubs.

Reproduction

  1. On Windows, create an esy.json with the following:
{
    "dependencies": {
        "ocaml": "4.14.0",
        "@opam/dune": "3.4.1"
    },
    "esy": {
        "build": [
            "dune build -p #{self.name}"
        ]
    }
}
  1. Try to build the project by running esy
  2. You'll see the same error as posted above

Specifications

  • Version of dune (output of dune --version): 3.4.1
  • Version of ocaml (output of ocamlc --version) 4.14.0
  • Operating system (distribution and version): Windows (Server 2019)

Additional information

  • Link to gist with verbose output (run dune with the --verbose flag):
@rgrinberg
Copy link
Member

cc @nojb

@nojb
Copy link
Collaborator

nojb commented Aug 25, 2022

Hello, which compiler are you using?

@phated
Copy link
Author

phated commented Aug 25, 2022

Hello, which compiler are you using?

Not sure I understand the question, but esy includes a mingw64 installation.

@nojb
Copy link
Collaborator

nojb commented Aug 25, 2022

Hello, which compiler are you using?

Not sure I understand the question, but esy includes a mingw64 installation.

Sorry, I meant: "which Windows compiler toolchain are you using", eg mingw64, msvc, etc.

@phated
Copy link
Author

phated commented Aug 25, 2022

👍 Esy builds everything on Windows in a tool they call esy-bash which is a cygwin environment with the mingw64 toolchain installed.

@nojb
Copy link
Collaborator

nojb commented Aug 25, 2022

I built Dune with mingw64 and it works, so there is something specific to esy that is at play here. I will try to investigate but it will take me longer because I will need to setup esy first, etc.

@phated
Copy link
Author

phated commented Aug 25, 2022

there is something specific to esy that is at play here.

I don't know, there's definitely something different (Kate mentioned something about headers)

@phated
Copy link
Author

phated commented Aug 29, 2022

@nojb It was suggested by @Et7f3 that I run x86_64-w64-mingw32-gcc --version inside the esy sandbox and this is what I get: x86_64-w64-mingw32-gcc (GCC) 7.4.0

Is there something else you'd like me to search for?

@phated
Copy link
Author

phated commented Aug 29, 2022

I don't understand this enough to know if this stackoverflow is correct but it says #define NTDDI_VERSION 0x06000000 is needed before #include <windows.h> 🤷

@nojb
Copy link
Collaborator

nojb commented Aug 29, 2022

@nojb It was suggested by @Et7f3 that I run x86_64-w64-mingw32-gcc --version inside the esy sandbox and this is what I get: x86_64-w64-mingw32-gcc (GCC) 7.4.0

Is there something else you'd like me to search for?

It seems you have an old compiler (Cygwin is currently on GCC 11); perhaps it is the same with the mingw64 headers. Are you able to try with a more recent version? The current mingw64 version in Cygwin is 10.0. Do you have a way to find out what the version of the installed mingw64 package is, in your environment?

@Et7f3
Copy link
Contributor

Et7f3 commented Aug 29, 2022

Hy,
I think esy when it install just take the latest at that point. Can you install on a new box ? And see if cygwin pick gcc10?

@phated
Copy link
Author

phated commented Aug 29, 2022

@nojb I have the ability to get you any information if you send me the commands to run.

@Et7f3 No, esy zips a version of these tools into esy-bash and unzips them when you install. These issues were discovered in CI which installs esy 0.6.12 fresh each time.

@nojb
Copy link
Collaborator

nojb commented Aug 29, 2022

@nojb I have the ability to get you any information if you send me the commands to run.

I don't have specific commands to run, but I would try to (re)build esy-bash so that it picks up the latest versions of the mingw64-* packages (they seem to be outdated in the version you are using).

@phated
Copy link
Author

phated commented Aug 29, 2022

I don't have specific commands to run, but I would try to (re)build esy-bash so that it picks up the latest versions of the mingw64-* packages (they seem to be outdated in the version you are using).

This isn't possible. According to @Et7f3, the function in the headers should have existed for 9+ years, so I think this can/should actually be solved in dune.

@nojb
Copy link
Collaborator

nojb commented Aug 29, 2022

the function in the headers should have existed for 9+ years,

Where can I see this?

this can/should actually be solved in dune.

Do you have step-by-step instructions to reproduce this problem?

@phated
Copy link
Author

phated commented Aug 29, 2022

Do you have step-by-step instructions to reproduce this problem?

The reproduction in the main issue shows this exact problem. Do you need me to include:

  1. Install nodejs + npm
  2. Install esy with npm i -g esy

@phated
Copy link
Author

phated commented Aug 29, 2022

All I have is @Et7f3 saying this in the OCaml Discord:

(Just checked the mingw header it was here for 9 years so it shouldn't be linked with april update)

I don't know which header they checked.

@nojb
Copy link
Collaborator

nojb commented Aug 29, 2022

Can you check with #6109 and see if it fixes your problem?

@phated
Copy link
Author

phated commented Aug 29, 2022

Thanks! I'll try it out.

emillon added a commit to emillon/opam-repository that referenced this issue Oct 11, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0~alpha1)

CHANGES:

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses findlib).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, fixes
  ocaml/dune#5650, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)
emillon added a commit to emillon/opam-repository that referenced this issue Oct 19, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0)

CHANGES:

- macOS: Handle unknown fsevents without crashing (ocaml/dune#6217, @rgrinberg)

- Enable file watching on MacOS SDK < 10.13. (ocaml/dune#6218, @rgrinberg)

- Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg)

- Add a `runtime_deps` field in the `cinaps` stanza to specify runtime
  dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg)

- Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg)

- Extend dune describe to include the root path of the workspace and the
  relative path to the build directory. (ocaml/dune#6136, @reubenrowe)

- Allow dune describe workspace to accept directories as arguments.
  The provided directories restrict the worskpace description to those
  directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope)

- Add a terminal persistence mode that attempts to clear the terminal history.
  It is enabled by setting terminal persistence to
  `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg)

- Disallow generating targets in sub direcories in inferred rules. The check to
  forbid this was accidentally done only for manually specified targets (ocaml/dune#6031,
  @rgrinberg)

- Do not ignore rules marked `(promote (until-clean))` when
  `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon)

- Dune no longer considers .aux files as targets during Coq compilation. This
  means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter)

- Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg)

- Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056,
  @rgrinberg)

- Introduce a `dirs` field in the `install` stanza to install entire
  directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg)

- Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg)

- Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes
  ocaml/dune#5945, @rgrinberg)

- Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg)

- Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine)

- Add an `(include <file>)` term to the `include_dirs` field for adding
  directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993,
  @gridbugs)

- Support `(extra_objects ...)` field in `(executable ...)` and `(library
  ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs)

- Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb)

- Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114,
  fixes ocaml/dune#6103, @emillon)

- odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes
  ocaml/dune#1117, @emillon)

- dune install: copy files in an atomic way (ocaml/dune#6150, @emillon)

- Add `%{coq:...}` macro for accessing data about the configuration about Coq.
  For instance `%{coq:version}` (ocaml/dune#6049, @Alizter)

- update vendored copy of cmdliner to 1.1.1. This improves the built-in
  documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon,
  ocaml/dune#6169, @shonfeder)

- The test suite for Coq now requires Coq >= 8.16 due to changes in the
  plugin loading mechanism upstream (which now uses `Findlib`).

- Starting with Coq build language 0.6, theories can be built without importing
  Coq's standard library by including `(stdlib no)`.
  (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek)

- on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, ocaml/dune#6231,
  fixes ocaml/dune#5650, fixes ocaml/dune#6226, @emillon)

- Added an (aliases ...) field to the (rules ...) stanza which allows the
  specification of multiple aliases per rule (ocaml/dune#6194, @Alizter)

- The `(coq.theory ...)` stanza will now ensure that for each declared `(plugin
 ...)`, the `META` file for it is built before calling `coqdep`. This enables
 the use of the new `Findlib`-based loading method in Coq 8.16; however as of
 Coq 8.16.0, Coq itself has some bugs preventing this to work yet. (ocaml/dune#6167 ,
 workarounds ocaml/dune#5767, @ejgallego)

- Allow include statement in install stanza (ocaml/dune#6139, fixes ocaml/dune#256, @gridbugs)

- Handle CSI n K code in ANSI escape codes from commands. (ocaml/dune#6214, fixes ocaml/dune#5528,
  @emillon)

- Add a new experimental feature `mode_specific_stubs` that allows the
  specification of different flags and sources for foreign stubs depending on
  the build mode (ocaml/dune#5649, @voodoos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment