Skip to content

Conversation

j-dubb-dev
Copy link

@j-dubb-dev j-dubb-dev commented Sep 21, 2025

Issue #, if available:

#1722

Description of changes:

Fixes #1722 by moving the implementation of GetProcessCpuTimeMillis to an os specific extern_{os}.go file. The file naming and use of compiler directives are required for go programs that have dependencies on packages that do no provide the same types/function signatures, etc across build targets. The syscall package is the main culprit here, which does not implement the same functions or types across unix-like and windows versions.

Changed

  • Moved current implementation of GetProcessCpuTimeMillis, that only works on unix-like build targets (unix,linux,darwin,freebsd,etc) out of StandardLibrary/runtimes/go/ImplementationFromDafny-go/Time_/externs.go to a file called externs_unix.go in the same directory. This is because the current implementation uses the syscall.Getrusage function and the syscall.Rusage type which are only implemented in the unix-like versions of the syscall package. Adding the compiler directive //go:build !windows along with the file name ensures this implementation will only be used on unix-like build targets and preserves backwards compatibility.

Added

  • extern_windows.go added with an implementation of GetProcessCpuTimeMillis that uses the .
    This file utilizes the //go:build windows compiler directive so only windows builds (GOOS=windows or -tags=windows) use this implementation. It uses the GetProcessTimes function from the windows API to acquire the same information as GetRusage
  • windows-latest as an os to test with in /library/.github/workflows/library_go_tests.yml

Squash/merge commit message, if applicable:

fix(go): Compilation errors on GOOS=windows

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

… windows api/syscalls on GOOS=windows builds
…o os specific extern file externs_unix.go since it uses a Type and Function from the syscall package that are only available when building unix-like (linux,darwin,freebsd,etc) targets.
…he windows specific implementation of GetProcessCpuTimeMillis which uses GetProcessTimes from the windows API instead of syscall.GetRusage
…since compiling currently fails for GOOS=windows as of 'releases/go/smithy-dafny-standard-library/v0.2.1'
@j-dubb-dev j-dubb-dev requested a review from a team as a code owner September 21, 2025 18:14
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.

BUG | GO module smithy-dafny-standard-library does not compile with GOOS=windows
1 participant