-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support building in older version of macOS #41
Comments
I've been trying to do something similar, but limited to macOS 11/12 and the file sharing API, see I'm refining this a little at the moment, and was going to start a similar discussion very soon! |
@balajiv113 Thanks for creating a new issue! I think you said macOS 11.x not 10.x. right? I supported both versions with go module versioning systems. For 11.x, You can get Please read README 🙏 |
Maybe I missed something when I looked at this schemed, but I don't think this is enough. I want to ship a prebuilt binary which will run on macOS 11 or newer, but I also want my binary to use the file sharing API when it's running on macOS 12. On macOS 11, I want my binary to print an error if the user tries to use file sharing. My understanding is that I cannot achieve this with Code-Hex/vz at the moment? I can build a binary which works on macOS11, but which won't have filesharing, or I can build a binary which will only work on macOS12 but with the filesharing API? |
@Code-Hex I do know the macOS Virtualization is not supported in 10.x. Am looking for an option to compile in 10.x and throw error in runtime. This way, while using this library i don't need to worry about checking the base minimum version. Also, now with new API's being release for macOS 13, we might even have /v3 released. This modal surely works for tools that update to latest version as soon as OS is released. But it won't work when we need to support multiple OS versions i believe. Please do correct me if am wrong :) |
@cfergeau @balajiv113 Thanks! These are my thoughts.
We can detect os version like below. This method was used in Go official repository. package main
import (
"fmt"
"syscall"
)
func main() {
osver, err := syscall.Sysctl("kern.osrelease")
if err != nil {
return
}
fmt.Println(osver, err)
} Indeed, as @cfergeau points out, the |
Maybe this? |
Do you have any suggestions?
|
I'm not sure panic() is a good outcome, I'd prefer an error to be returned. Otherwise the client application needs to have the knowledge of which API is supported with which macOS version. |
I've started trying to make use of this flag in my branch ( https://github.com/cfergeau/vz/tree/shared-folders2 ), otherwise it's indeed not very convenient. A binary built on macOS 11 with |
For OS version detection, I'm using a different method, which has the big advantage of also using
|
It looks like a way of returning an error would also be good.
I think this method does not have an advantage. Because We have to use cgo always to check the OS version. It does not seem good practice to have a C function for every such trivial change. (It takes a long time to compile.) |
Yes, this is similar to what I introduced in cfergeau@a9717d7 , though my changes are more limited in scope since at that time there was only the file sharing API. I did not add an error to all the filesharing API since some of the methods cannot be used without a
But if we have this code in virtualization.m, it's only going to be compiled when virtualization.m changes, it's not going to be re-compiled when go code changes? I did not understand what is problematic? :( |
I want to say, not only in the New-related APIs, but also, for example, in the case of Stop; the same applies to CanStop. Signatures after changes are annoying maybe. - func (v *VirtualMachine) CanStop() bool
- func (v *VirtualMachine) Stop(fn func(error))
+ func (v *VirtualMachine) CanStop() (bool, error)
+ func (v *VirtualMachine) Stop(fn func(error)) error The library development side. I have no complaints if anyone contributes the test code :D
|
I'll work on this in the next days, and file a PR so that we can refine this! |
How about cross-compiling distributions on the latest version of the macOS and each method determine if it is available at runtime? Even if all versions could be compiled, this problem would still occur. The case of concern
In this case, I think the user cannot use any methods for 12.x. This is because some methods that are only available in 11.x version are compiled into the binary. Maybe the user have to install again for using the latest features. |
I'll test again later today, but compiling on macOS 11 and then being able to use the file sharing API when running on macOS 12 works fine. This is how https://github.com/code-ready/vfkit/releases/tag/v0.0.2 was built (on macOS 11 even if there is file sharing) because I hadn't searched yet for the |
I've been looking again at this suggestion, as doing the version detection with @available looks a bit long/silly when you want to detect macOS 10/11/12/13/...
|
@cfergeau Thanks for checked! This is your configuration. And I checked your actions job history :) |
The action creates 2 binaries https://github.com/code-ready/vfkit/actions/runs/2753739630 with the macos version as a suffix. |
I also confirmed the build and execution results in https://github.com/Code-Hex/mac-build-test. (Build history) @cfergeau's understanding seemed to be correct. However, looking at the logs during the build on GitHub actions, it appears that whether or not it can be compiled depends on the version of xcode installed on the mac. e.g.
Therefore I attempted to compile an API that will be added in macOS 13 called VZSpiceAgentPortAttachment. However, this is not supported by xcode at the moment, so the compilation failed even with https://github.com/Code-Hex/mac-build-test/runs/8250778147?check_suite_focus=true In conclusion, whether or not you can compile depends on the xcode installed on the machine you are using. |
From the above, these are my thoughts
|
If |
The compilation result depends on xcode, I think this is not possible, as commented at the beginning of this issue.
At least the latest API is likely to require the latest xcode installed which is supported by the API. If you have a macOS that is one major version earlier, you might be able to install xcode that meets this requirement :D |
At the moment, the xcode I have on my macOS 11 x86_64 macbook can still build vz code with file sharing. I'll try it with my |
I think it is possible because the Directory Sharing API is provided in macOS v12. (v11 is one major version earlier than v12) For example, older versions than v10 would not compile. Good ref: https://xcodereleases.com/ (Please pay attention Requires and SDKs) |
When this is added to vz, we'll see if I can compile for the macOS 13 API on this macOS 11 laptop :) |
To add a bit more info, Xcode 12.3 is the latest version that can be installed on macOS v10. The SDK supported by this xcode is up to macOS 11.1. (from xcodereleases.com) I need to understand xcode release cycles... |
I have errors added in most places in https://github.com/cfergeau/vz/tree/macos11 I'm not sure how to add annotations/report errors for Same for Apart from that, I need to cleanup a bit the git history, group some of the commits, and test it, and it should be good for a PR! |
@balajiv113 #48 should return proper errors when trying to use virtualization framework on macOS 10, but I could not test it. Can you give it a try if you have the appropriate setup? |
@cfergeau Sure will give a shot and let you know the results |
@cfergeau I tried compiling In macOS 10.15.7. But unfortunately ended up with the following error
|
Ah yes, this enables running a binary using Code-Hex/vz on older macOS versions, but it has to be built on a newer macOS with |
@balajiv113 I said, virtualization framework cannot compile under v10 because it depends on xcode sdk. But I think if you have installed xcode 12.4, You can build on your version because xcode sdk for v11.1 is supported. |
Thanks a lot for this awesome library.
For better integration with existing products, it would be great if we could support building in older version.
For Instance,
macOS 10.x - Building will successful & execution will throw error saying virtualization not supported
macOS 12.x - Building will successful & execution will be successful as well
With this support, it will be easier to integrate to existing tools that still supports macOS 10.x
The text was updated successfully, but these errors were encountered: