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 dune exec -- on Windows _always_ rebuilds the executable #5466

Closed
MisterDA opened this issue Feb 21, 2022 · 12 comments
Closed

Dune 3 dune exec -- on Windows _always_ rebuilds the executable #5466

MisterDA opened this issue Feb 21, 2022 · 12 comments
Labels

Comments

@MisterDA
Copy link
Contributor

With dune.3 on Windows, when I dune exec -- using the executable public_name, without the .exe, the executable is always rebuild. I think that's a regression.
Using the "local" name (e.g., ./main.exe) also forces recompilation each time.

Possibly related to (but I don't think so):

Fixes dune exec not adding .exe on Windows (#4371, fixes #3322)

@snowleopard wrote:

I have a suspicion that this may be related to the "artifact substitution" mechanism that changes the contents of executables. I saw some issues with executable targets being re-promoted (but not re-built) but never had a chance to look into this

@bobot
Copy link
Collaborator

bobot commented Feb 21, 2022

My two cents: artifact subtitution is not done inside _build, and not done before executing with dune exec --.

You can perhaps test with --debug-cache=workspace-local to get information about what is not considered up to date.

@MisterDA
Copy link
Contributor Author

$ dune init project main && cd main
Success: initialized project component named main

$ dune exec --debug-cache=workspace-local -- main
Workspace-local cache miss: _build/default/.dune/configurator: never seen this target before
Workspace-local cache miss: _build/default/.dune/configurator.v2: never seen this target before
Workspace-local cache miss: _build/default/bin/.merlin-conf/exe-main: never seen this target before
Workspace-local cache miss: _build/default/bin/main.ml: never seen this target before
Workspace-local cache miss: _build/default/bin/main.mli: never seen this target before
Workspace-local cache miss: _build/default/lib/.merlin-conf/lib-main: never seen this target before
Workspace-local cache miss: _build/default/lib/main.ml-gen: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/byte/main.cmi: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/native/main.cmx: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/native/dune__exe__Main.cmx: never seen this target before
Workspace-local cache miss: _build/default/lib/main.a: never seen this target before
Workspace-local cache miss: _build/default/bin/main.exe: never seen this target before
Workspace-local cache miss: _build/install/default/bin/main.exe: never seen this target before
Hello, World!

$ dune exec --debug-cache=workspace-local -- main
Workspace-local cache miss: _build/default/.dune/configurator: never seen this target before
Workspace-local cache miss: _build/default/.dune/configurator.v2: never seen this target before
Workspace-local cache miss: _build/default/bin/.merlin-conf/exe-main: never seen this target before
Workspace-local cache miss: _build/default/bin/main.ml: never seen this target before
Workspace-local cache miss: _build/default/bin/main.mli: never seen this target before
Workspace-local cache miss: _build/default/lib/.merlin-conf/lib-main: never seen this target before
Workspace-local cache miss: _build/default/lib/main.ml-gen: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/byte/main.cmi: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/native/main.cmx: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/native/dune__exe__Main.cmx: never seen this target before
Workspace-local cache miss: _build/default/lib/main.a: never seen this target before
Workspace-local cache miss: _build/default/bin/main.exe: never seen this target before
Workspace-local cache miss: _build/install/default/bin/main.exe: never seen this target before
Hello, World!

$ tree -la _build
_build
├── default
│   ├── .dune
│   │   ├── configurator
│   │   └── configurator.v2
│   ├── bin
│   │   ├── .main.eobjs
│   │   │   ├── byte
│   │   │   │   ├── dune__exe__Main.cmi
│   │   │   │   └── dune__exe__Main.cmti
│   │   │   └── native
│   │   │       ├── dune__exe__Main.cmx
│   │   │       └── dune__exe__Main.o
│   │   ├── .merlin-conf
│   │   │   └── exe-main
│   │   ├── main.exe
│   │   ├── main.ml
│   │   └── main.mli
│   └── lib
│       ├── .main.objs
│       │   ├── byte
│       │   │   ├── main.cmi
│       │   │   ├── main.cmo
│       │   │   └── main.cmt
│       │   └── native
│       │       ├── main.cmx
│       │       └── main.o
│       ├── .merlin-conf
│       │   └── lib-main
│       ├── main.a
│       ├── main.cmxa
│       └── main.ml-gen
├── install
│   └── default
│       └── bin
│           └── main.exe
└── log

So even if the targets are present on the filesystem, they're ignored.

@snowleopard
Copy link
Collaborator

Oh, wow, judging by the output you get, everything gets rebuilt for you (not just the executable).

Could you do the same with dune build main.exe --debug-cache=workspace-local instead of dune exec?

@MisterDA
Copy link
Contributor Author

The target main (or any variation around it) wasn't recognized.

$ dune build --debug-cache=workspace-local
Workspace-local cache miss: _build/default/.dune/configurator: never seen this target before
Workspace-local cache miss: _build/default/.dune/configurator.v2: never seen this target before
Workspace-local cache miss: _build/default/META.main: never seen this target before
Workspace-local cache miss: _build/default/main.dune-package: never seen this target before
Workspace-local cache miss: _build/default/main.opam: never seen this target before
Workspace-local cache miss: _build/install/default/lib/main/META: never seen this target before
Workspace-local cache miss: _build/install/default/lib/main/dune-package: never seen thistarget before
Workspace-local cache miss: _build/install/default/lib/main/opam: never seen this target before
Workspace-local cache miss: _build/default/bin/.merlin-conf/exe-main: never seen this target before
Workspace-local cache miss: _build/default/test/.merlin-conf/exe-main: never seen this target before
Workspace-local cache miss: _build/default/bin/main.mli: never seen this target before
Workspace-local cache miss: _build/default/test/main.mli: never seen this target before
Workspace-local cache miss: _build/default/bin/main.ml: never seen this target before
Workspace-local cache miss: _build/default/test/main.ml: never seen this target before
Workspace-local cache miss: _build/default/lib/.merlin-conf/lib-main: never seen this target before
Workspace-local cache miss: _build/default/lib/main.ml-gen: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/byte/main.cmi: never seen this target before
Workspace-local cache miss: _build/default/test/.main.eobjs/byte/dune__exe__Main.cmi: never seen this target before
Workspace-local cache miss: _build/default/lib/main.cma: never seen this target before
Workspace-local cache miss: _build/default/lib/.main.objs/native/main.cmx: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi: never seen this target before
Workspace-local cache miss: _build/default/test/.main.eobjs/native/dune__exe__Main.cmx: never seen this target before
Workspace-local cache miss: _build/default/bin/.main.eobjs/native/dune__exe__Main.cmx: never seen this target before
Workspace-local cache miss: _build/default/lib/main.a: never seen this target before
Workspace-local cache miss: _build/default/test/main.exe: never seen this target before
Workspace-local cache miss: _build/default/bin/main.exe: never seen this target before
Workspace-local cache miss: _build/default/lib/main.cmxs: never seen this target before
Workspace-local cache miss: _build/install/default/bin/main.exe: never seen this target before
Workspace-local cache miss: _build/default/main.install: never seen this target before
$ dune build --debug-cache=workspace-local
# nothing

@MisterDA
Copy link
Contributor Author

Running dune exec after dune build doesn't rebuild everything! Maybe dune exec doesn't create a root dependency?

@MisterDA
Copy link
Contributor Author

The same problem seems to appear with dune utop.

@MisterDA
Copy link
Contributor Author

@snowleopard any other idea? let me know if I can help.

@snowleopard
Copy link
Collaborator

@snowleopard any other idea? let me know if I can help.

Sorry, I couldn't find a chance to investigate this yet.

What needs to be done is debugging why Dune's workspace-local cache isn't effective in this case. The main module that is responsible for caching build rules is src/dune_engine/rule_cache.ml -- perhaps, you could try finding the cause?

@rgrinberg
Copy link
Member

@MisterDA could you submit a cram test that reproduces this problem? That would be a good first step to address this.

@emillon
Copy link
Collaborator

emillon commented May 18, 2022

FWIW, I can't reproduce this. The second run is a clean "Hello, world" without any cache message.

@emillon
Copy link
Collaborator

emillon commented May 18, 2022

(dune 3.1.1)

@emillon
Copy link
Collaborator

emillon commented May 18, 2022

The bug is in 3.0.2 but not in 3.1.1. Not sure by what, but I think that we can close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants