fix(go): Compilation errors on GOOS=windows#1723
Open
j-dubb-dev wants to merge 4 commits intoaws:mainfrom
Open
fix(go): Compilation errors on GOOS=windows#1723j-dubb-dev wants to merge 4 commits intoaws:mainfrom
j-dubb-dev wants to merge 4 commits intoaws:mainfrom
Conversation
… 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'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
#1722
Description of changes:
Fixes #1722 by moving the implementation of
GetProcessCpuTimeMillisto an os specificextern_{os}.gofile. 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. Thesyscallpackage is the main culprit here, which does not implement the same functions or types across unix-like and windows versions.Changed
GetProcessCpuTimeMillis, that only works on unix-like build targets (unix,linux,darwin,freebsd,etc) out ofStandardLibrary/runtimes/go/ImplementationFromDafny-go/Time_/externs.goto a file calledexterns_unix.goin the same directory. This is because the current implementation uses thesyscall.Getrusagefunction and thesyscall.Rusagetype which are only implemented in the unix-like versions of the syscall package. Adding the compiler directive//go:build !windowsalong with the file name ensures this implementation will only be used on unix-like build targets and preserves backwards compatibility.Added
extern_windows.goadded with an implementation ofGetProcessCpuTimeMillisthat uses the .This file utilizes the
//go:build windowscompiler directive so only windows builds (GOOS=windowsor-tags=windows) use this implementation. It uses theGetProcessTimesfunction from the windows API to acquire the same information asGetRusagewindows-latestas an os to test with in/library/.github/workflows/library_go_tests.ymlSquash/merge commit message, if applicable:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.