Skip to content

Commit 4c6b22d

Browse files
authored
Merge pull request #1175 from AkihiroSuda/fix-macos-10-15
Fix compilation on macOS 10.15
2 parents 3c9eb1b + 52d4e54 commit 4c6b22d

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ jobs:
145145
# GHA macOS is slow and flaky, so we only test a few YAMLS here.
146146
# Other yamls are tested on Linux instances of Cirrus.
147147

148+
catalina:
149+
name: "macOS 10.15 (deprecated)"
150+
# Will be fully unsupported by 12/1/22 https://github.com/actions/runner-images/issues/5583
151+
runs-on: macos-10.15
152+
timeout-minutes: 20
153+
steps:
154+
- uses: actions/setup-go@v3
155+
with:
156+
go-version: 1.19.x
157+
- uses: actions/checkout@v3
158+
with:
159+
fetch-depth: 1
160+
- name: Make
161+
run: make
162+
- name: Install
163+
run: make install
164+
148165
vmnet:
149166
name: "VMNet test"
150167
runs-on: macos-11

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ bat = .bat
1313
exe = .exe
1414
endif
1515

16+
GO_BUILDTAGS ?=
17+
ifeq ($(GOOS),darwin)
18+
MACOS_VERSION=$(shell sw_vers -productVersion | cut -d . -f 1)
19+
ifeq ($(shell test $(MACOS_VERSION) -lt 13; echo $$?),0)
20+
# The "vz" mode needs macOS 13 or later
21+
GO_BUILDTAGS += no_vz
22+
endif
23+
endif
24+
1625
PACKAGE := github.com/lima-vm/lima
1726

1827
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
1928
VERSION_TRIMMED := $(VERSION:v%=%)
2029

21-
GO_BUILD := $(GO) build -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)"
30+
GO_BUILD := $(GO) build -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERSION)" -tags "$(GO_BUILDTAGS)"
2231

2332
.NOTPARALLEL:
2433

pkg/vz/vm_darwin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build darwin && !no_vz
2+
// +build darwin,!no_vz
3+
14
package vz
25

36
import (

pkg/vz/vz_driver_darwin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build darwin && !no_vz
2+
// +build darwin,!no_vz
3+
14
package vz
25

36
import (

pkg/vz/vz_driver_others.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
//go:build !darwin
2-
// +build !darwin
1+
//go:build !darwin || no_vz
2+
// +build !darwin no_vz
33

44
package vz
55

66
import (
77
"context"
8-
"fmt"
8+
"errors"
99

1010
"github.com/lima-vm/lima/pkg/driver"
1111
)
1212

13+
var ErrUnsupported = errors.New("vm driver 'vz' needs macOS 13 or later (Hint: try recompiling Lima if you are seeing this error on macOS 13)")
14+
1315
type LimaVzDriver struct {
1416
*driver.BaseDriver
1517
}
@@ -21,17 +23,17 @@ func New(driver *driver.BaseDriver) *LimaVzDriver {
2123
}
2224

2325
func (l *LimaVzDriver) Validate() error {
24-
return fmt.Errorf("driver 'vz' is only supported on darwin")
26+
return ErrUnsupported
2527
}
2628

2729
func (l *LimaVzDriver) CreateDisk() error {
28-
return fmt.Errorf("driver 'vz' is only supported on darwin")
30+
return ErrUnsupported
2931
}
3032

3133
func (l *LimaVzDriver) Start(ctx context.Context) (chan error, error) {
32-
return nil, fmt.Errorf("driver 'vz' is only supported on darwin")
34+
return nil, ErrUnsupported
3335
}
3436

3537
func (l *LimaVzDriver) Stop(_ context.Context) error {
36-
return fmt.Errorf("driver 'vz' is only supported on darwin")
38+
return ErrUnsupported
3739
}

0 commit comments

Comments
 (0)