Cross-compiler for building "darwin" target
afbjorklund opened this issue · comments
Description
It would be nice to be able to build all targets, before having it fail in CI on a VM
Something like https://github.com/neilotoole/xcgo and use a container builder?
Main issue is that github.com/Code-Hex/vz/v3
doesn't build (cgo).
Not sure if darwin is still open enough, or if it would need a mock?
i.e. trying to build with GOOS=darwin
, from a Linux host
# github.com/Code-Hex/vz/v3
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:11:8: undefined: VirtualMachineStateStopped
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:12:8: undefined: VirtualMachineStateRunning
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:13:8: undefined: VirtualMachineStatePaused
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:14:8: undefined: VirtualMachineStateError
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:15:8: undefined: VirtualMachineStateStarting
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:16:8: undefined: VirtualMachineStatePausing
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:17:8: undefined: VirtualMachineStateResuming
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:18:8: undefined: VirtualMachineStateStopping
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:19:8: undefined: VirtualMachineStateSaving
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:27:9: undefined: VirtualMachineState
../go/pkg/mod/github.com/!code-!hex/vz/v3@v3.1.0/virtualmachinestate_string.go:19:8: too many errors
Being able to run unit tests (with binfmt_misc) would be nice.
i.e. similar to current GOOS=windows
support (as in 8028e50)
Integration and release tests still need hardware, of course.
https://github.com/tpoechtrager/osxcross
https://github.com/multiarch/crossbuild
#cgo darwin CFLAGS: -mmacosx-version-min=11 -x objective-c -fno-objc-arc
#cgo darwin LDFLAGS: -lobjc -framework Foundation -framework Virtualization -framework Cocoa
#import <Availability.h>
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <Virtualization/Virtualization.h>
This seems to be what I want, for running the unit tests (similar to wine
for windows):
~ $ uname
Linux
~ $ darling shell
Darling [~]$ uname
Darwin
It doesn't have to be perfect.
This seems challenging in both technological and legal aspects.
It is unlikely that we can work on this.😢
The legal was supposed to be covered, if not it should be avoided for sure.
We only directly use those parts of Darwin that are released as fully free software.
But, like Wine, I don't think it is something that is needed upstream.
If the user have such an environment already, they can "just use it"...
If not, they would have to remote to a real Windows or Darwin machine.
(like the VMs that are being used in the GitHub Action workflows in CI)
Also, for testing purposes the no_vz
tag avoided most* of the build issues...
* except for my copy/paste errors in the vz driver code itself, that is :-)
There are some odd modules that still refuse to cross-compile, not sure why?
# github.com/lima-vm/lima/pkg/hostagent
pkg/hostagent/inotify_darwin.go:6:47: undefined: notify.FSEventsInodeMetaMod
The cgo compilation failed, when trying to run cc -E -dM
to get some macro definitions:
clang: error: argument unused during compilation: '-arch x86_64' [-Werror,-Wunused-command-line-argument]
That is, there was no actual code being compiled but it wanted to get a enum value...
FSEventsInodeMetaMod = 0x00400