From 2d58a25d72a11ef84254bdda36ebe2f642cc5259 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 5 May 2023 17:32:05 -0600 Subject: [PATCH 1/5] Go now require to add -lresolv when compiling for darwin with go1.20. Reference bug: https://github.com/golang/go/issues/58159 --- internal/command/darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/command/darwin.go b/internal/command/darwin.go index dd03678..c43277d 100644 --- a/internal/command/darwin.go +++ b/internal/command/darwin.go @@ -234,7 +234,7 @@ func (cmd *darwin) setupContainerImages(flags *darwinFlags, args []string) error zigCXX := fmt.Sprintf("zig c++ -v -target %s -isysroot /sdk -iwithsysroot /usr/include -iframeworkwithsysroot /System/Library/Frameworks", zigTarget) image.SetEnv("CC", zigCC) image.SetEnv("CXX", zigCXX) - image.SetEnv("CGO_LDFLAGS", "--sysroot /sdk -F/System/Library/Frameworks -L/usr/lib") + image.SetEnv("CGO_LDFLAGS", "--sysroot /sdk -F/System/Library/Frameworks -L/usr/lib -lresolv") image.SetEnv("GOOS", "darwin") if !cmd.localBuild { From b9df8627414569a2c2b86055e7688d6030e35701 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 5 May 2023 17:42:53 -0600 Subject: [PATCH 2/5] Add support for local build too. --- internal/command/darwin.go | 7 +++++++ internal/command/ios.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/internal/command/darwin.go b/internal/command/darwin.go index c43277d..2954b01 100644 --- a/internal/command/darwin.go +++ b/internal/command/darwin.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "runtime" + "strings" "github.com/fyne-io/fyne-cross/internal/log" "github.com/fyne-io/fyne-cross/internal/volume" @@ -250,6 +251,12 @@ func (cmd *darwin) setupContainerImages(flags *darwinFlags, args []string) error } image.SetMount("sdk", flags.MacOSXSDKPath, "/sdk") } + } else { + if v, ok := ctx.Env["GOFLAGS"]; ok { + ctx.Env["GOFLAGS"] = strings.TrimSpace(v + " -ldflags=-extldflags -ldflags=-lresolv") + } else { + ctx.Env["GOFLAGS"] = "-ldflags=-extldflags -ldflags=-lresolv" + } } cmd.Images = append(cmd.Images, image) diff --git a/internal/command/ios.go b/internal/command/ios.go index ac40274..f2e2735 100644 --- a/internal/command/ios.go +++ b/internal/command/ios.go @@ -3,6 +3,7 @@ package command import ( "fmt" "runtime" + "strings" "github.com/fyne-io/fyne-cross/internal/log" "github.com/fyne-io/fyne-cross/internal/volume" @@ -158,6 +159,12 @@ func (cmd *iOS) setupContainerImages(flags *iosFlags, args []string) error { return err } + if v, ok := ctx.Env["GOFLAGS"]; ok { + ctx.Env["GOFLAGS"] = strings.TrimSpace(v + " -ldflags=-extldflags -ldflags=-lresolv") + } else { + ctx.Env["GOFLAGS"] = "-ldflags=-extldflags -ldflags=-lresolv" + } + cmd.Images = append(cmd.Images, runner.createContainerImage("", iosOS, overrideDockerImage(flags.CommonFlags, iosImage))) return nil From 2d253e1985110b6b39eb6121d0159bd166113702 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 5 May 2023 19:12:12 -0600 Subject: [PATCH 3/5] Add debug message in k8s backend to match docker/podman backend --- internal/command/kubernetes.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/command/kubernetes.go b/internal/command/kubernetes.go index 594290f..3c0ff8b 100644 --- a/internal/command/kubernetes.go +++ b/internal/command/kubernetes.go @@ -151,6 +151,7 @@ func (i *kubernetesContainerImage) close() error { } func (i *kubernetesContainerImage) Run(vol volume.Volume, opts options, cmdArgs []string) error { + log.Debug(opts.WorkDir, cmdArgs) return i.pod.Run(opts.WorkDir, cmdArgs) } @@ -228,6 +229,8 @@ func (i *kubernetesContainerImage) Prepare() error { name := fmt.Sprintf("fyne-cross-%s-%x", i.ID(), unique) namespace := i.runner.namespace + log.Debug("Creating pod", name, namespace, i.DockerImage, mount, env) + i.pod, err = i.runner.client.NewPod(context.Background(), name, i.DockerImage, namespace, i.runner.storageLimit, i.runner.vol.WorkDirContainer(), mount, env) From 817d80463eda118d39d85b6fc7cb506a5a806f66 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 5 May 2023 19:30:06 -0600 Subject: [PATCH 4/5] This should actually work in all case with the same code. --- internal/command/darwin.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/command/darwin.go b/internal/command/darwin.go index 2954b01..067bc49 100644 --- a/internal/command/darwin.go +++ b/internal/command/darwin.go @@ -235,9 +235,15 @@ func (cmd *darwin) setupContainerImages(flags *darwinFlags, args []string) error zigCXX := fmt.Sprintf("zig c++ -v -target %s -isysroot /sdk -iwithsysroot /usr/include -iframeworkwithsysroot /System/Library/Frameworks", zigTarget) image.SetEnv("CC", zigCC) image.SetEnv("CXX", zigCXX) - image.SetEnv("CGO_LDFLAGS", "--sysroot /sdk -F/System/Library/Frameworks -L/usr/lib -lresolv") + image.SetEnv("CGO_LDFLAGS", "--sysroot /sdk -F/System/Library/Frameworks -L/usr/lib") image.SetEnv("GOOS", "darwin") + if v, ok := ctx.Env["GOFLAGS"]; ok { + ctx.Env["GOFLAGS"] = strings.TrimSpace(v + " -ldflags=-extldflags -ldflags=-lresolv") + } else { + ctx.Env["GOFLAGS"] = "-ldflags=-extldflags -ldflags=-lresolv" + } + if !cmd.localBuild { if flags.MacOSXSDKPath == "unset" { // This is checking if the provided container image has the macOSX SDK installed @@ -251,12 +257,6 @@ func (cmd *darwin) setupContainerImages(flags *darwinFlags, args []string) error } image.SetMount("sdk", flags.MacOSXSDKPath, "/sdk") } - } else { - if v, ok := ctx.Env["GOFLAGS"]; ok { - ctx.Env["GOFLAGS"] = strings.TrimSpace(v + " -ldflags=-extldflags -ldflags=-lresolv") - } else { - ctx.Env["GOFLAGS"] = "-ldflags=-extldflags -ldflags=-lresolv" - } } cmd.Images = append(cmd.Images, image) From f76d5e2e54f8c9aabea2971153e7a9164a4b7c95 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Sat, 6 May 2023 02:50:03 +0100 Subject: [PATCH 5/5] We need to be able to specify we are using a container with sdk even on a darwin host. --- internal/command/darwin.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/command/darwin.go b/internal/command/darwin.go index 067bc49..81221e5 100644 --- a/internal/command/darwin.go +++ b/internal/command/darwin.go @@ -67,9 +67,8 @@ func (cmd *darwin) Parse(args []string) error { // Add flags to use only on darwin host if runtime.GOOS == darwinOS { flagSet.BoolVar(&cmd.localBuild, "local", true, "If set uses the fyne CLI tool installed on the host in place of the docker images") - } else { - flagSet.StringVar(&flags.MacOSXSDKPath, "macosx-sdk-path", "unset", "Path to macOS SDK (setting it to 'bundled' indicates that the sdk is expected to be in the container) [required]") } + flagSet.StringVar(&flags.MacOSXSDKPath, "macosx-sdk-path", "unset", "Path to macOS SDK (setting it to 'bundled' indicates that the sdk is expected to be in the container) [required]") // flags used only in release mode flagSet.StringVar(&flags.Category, "category", "", "The category of the app for store listing")