Skip to content

time_stubs.c: add fallback for Windows 7#13905

Merged
nojb merged 2 commits intoocaml:mainfrom
nojb:windows7
Mar 24, 2026
Merged

time_stubs.c: add fallback for Windows 7#13905
nojb merged 2 commits intoocaml:mainfrom
nojb:windows7

Conversation

@nojb
Copy link
Copy Markdown
Collaborator

@nojb nojb commented Mar 24, 2026

Adds a fallback for GetSystemTimePreciseAsFileTime for old versions of Windows (< 8).

Fixes #13871

nojb added 2 commits March 24, 2026 13:43
Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
@Alizter Alizter self-requested a review March 24, 2026 12:45
}
if (GetSystemTime == NULL) { /* < Windows 8 */
GetSystemTime = GetSystemTimeAsFileTime;
}
Copy link
Copy Markdown
Collaborator

@Alizter Alizter Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an else and a printf here, however I am seeing that this is getting called quite a few times. Shouldn't this only be happening once? (On Win 11)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be called only once per process. Could there be more than one Dune process active?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've solved the mystery. We have rules that generate the help pages so there were multiple dune processes happening when I did dune build dune.install. :-)

@nojb
Copy link
Copy Markdown
Collaborator Author

nojb commented Mar 24, 2026

CI failure is unrelated.

@nojb nojb merged commit 70c38ef into ocaml:main Mar 24, 2026
28 of 29 checks passed
@nojb nojb deleted the windows7 branch March 24, 2026 16:38
@Alizter Alizter mentioned this pull request Mar 24, 2026
25 tasks
@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Mar 24, 2026

We get this new warning on mingw:

time_stubs.c: In function 'dune_clock_gettime_realtime':
time_stubs.c:19:21: warning: assignment to 'void (*)(struct _FILETIME *)' from incompatible pointer type 'FARPROC' {aka 'long long int (*)()'} [-Wincompatible-pointer-types]
   19 |       GetSystemTime = GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
      |                     ^

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Mar 25, 2026

I've made #13914 to fix the warning.

Alizter added a commit that referenced this pull request Mar 25, 2026
`GetProcAddress` returns `FARPROC` and therefore needs an explicit cast.
This fixes the warning introduced in
#13905.
@rgrinberg
Copy link
Copy Markdown
Member

Does OCaml 4.14 even support windows 7? If not, then this change is kind of pointless as it will be broken by the next release anyway.

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Mar 26, 2026

@rgrinberg I was able to test the patch in a Windows 7 VM so that's a yes.

shonfeder pushed a commit that referenced this pull request Mar 27, 2026
Adds a fallback for `GetSystemTimePreciseAsFileTime` for old versions of
Windows (< 8).

Fixes #13871

Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
shonfeder pushed a commit that referenced this pull request Mar 27, 2026
Adds a fallback for `GetSystemTimePreciseAsFileTime` for old versions of
Windows (< 8).

Fixes #13871

Signed-off-by: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
Signed-off-by: Shon Feder <shon.feder@gmail.com>
shonfeder added a commit that referenced this pull request Mar 27, 2026
Backport #13905 to the release branch for 3.22.1
shonfeder pushed a commit that referenced this pull request Mar 27, 2026
`GetProcAddress` returns `FARPROC` and therefore needs an explicit cast.
This fixes the warning introduced in
#13905.

(cherry picked from commit d2120ac)
Signed-off-by: Shon Feder <shon.feder@gmail.com>
shonfeder pushed a commit that referenced this pull request Mar 27, 2026
`GetProcAddress` returns `FARPROC` and therefore needs an explicit cast.
This fixes the warning introduced in
#13905.

(cherry picked from commit d2120ac)
Signed-off-by: Shon Feder <shon.feder@gmail.com>
shonfeder added a commit to shonfeder/opam-repository that referenced this pull request Apr 1, 2026
CHANGES:

### Fixed

- Restore compatibility with Windows 7 (ocaml/dune#13905, @nojb)

- `dune test` now runs tests in the default context only. When there is a
  single context, it is treated as the default. This fixes a crash when the
  workspace has no context named "default".
  (ocaml/dune#13930, fixes ocaml/dune#13904, @Alizter)

- Fix `dune trace cat --chrome-trace` to adhere to the Chrome Trace Event
  Format by providing timestamps and durations at microsecond granularity
  (ocaml/dune#13911, fixes ocaml/dune#13906, @Alizter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dune 3.22.0 bootstrap fails on Windows < 8 — GetSystemTimePreciseAsFileTime not found in KERNEL32.dll

3 participants