Skip to content
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

Binaries for linux-arm #2068

Closed
ljani opened this issue May 5, 2019 · 17 comments · Fixed by #3783
Closed

Binaries for linux-arm #2068

ljani opened this issue May 5, 2019 · 17 comments · Fixed by #3783
Labels
good first issue Good for newcomers help wanted We would love to have this done, but don't have the bandwidth, need help from contributors kind/feature-request meta/release priority/p3 agreed that this would be good to have, but no one is available at the moment.

Comments

@ljani
Copy link

ljani commented May 5, 2019

Expected behavior

Find a skaffold-linux-arm binary from the releases page.

Actual behavior

There is no skaffold-linux-arm binary.

Information

  • Skaffold version: v0.28.0
  • Operating system: Arch Linux ARM on Raspberry Pi 3B+ (armhf)

Thanks.

EDIT: cross compiling skaffold with GOOS=linux GOARCH=arm GOARM=5 seems to work very well.

@tejal29
Copy link
Member

tejal29 commented May 6, 2019

Great! Can you give it try by adding linux-arm to the Makefile SUPPORTED_PLATFORMS? and see it works?

@tejal29 tejal29 added area/release good first issue Good for newcomers help wanted We would love to have this done, but don't have the bandwidth, need help from contributors labels May 6, 2019
@ljani
Copy link
Author

ljani commented May 6, 2019

root@657e2b8716d2:/go/src/github.com/GoogleContainerTools/skaffold# git diff
diff --git a/Makefile b/Makefile
index 1f6a11ad..d2cdc804 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ GCP_PROJECT ?= k8s-skaffold
 GKE_CLUSTER_NAME ?= integration-tests
 GKE_ZONE ?= us-central1-a

-SUPPORTED_PLATFORMS := linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
+SUPPORTED_PLATFORMS := linux-arm linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
 BUILD_PACKAGE = $(REPOPATH)/cmd/skaffold

 VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
root@657e2b8716d2:/go/src/github.com/GoogleContainerTools/skaffold# make cross
make: *** No rule to make target 'out/skaffold-linux-arm', needed by 'out/skaffold-linux-arm.sha256'.  Stop.

So, it does not work. However the following works for skaffold-linux-arm, but obviously it's not the correct patch:

root@657e2b8716d2:/go/src/github.com/GoogleContainerTools/skaffold# git diff
diff --git a/Makefile b/Makefile
index 1f6a11ad..f93b17a1 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 GOOS ?= $(shell go env GOOS)
-GOARCH = amd64
+GOARCH = arm
 BUILD_DIR ?= ./out
 ORG := github.com/GoogleContainerTools
 PROJECT := skaffold
@@ -28,7 +28,7 @@ GCP_PROJECT ?= k8s-skaffold
 GKE_CLUSTER_NAME ?= integration-tests
 GKE_ZONE ?= us-central1-a

-SUPPORTED_PLATFORMS := linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
+SUPPORTED_PLATFORMS := linux-arm linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
 BUILD_PACKAGE = $(REPOPATH)/cmd/skaffold

 VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
root@657e2b8716d2:/go/src/github.com/GoogleContainerTools/skaffold# make cross
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-80-g25f1b664-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-06T19:20:21Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=25f1b66402507440a12a0c1173806b190ff76eb8 -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-linux-arm github.com/GoogleContainerTools/skaffold/cmd/skaffol
...
(And then darwin-arm fails)

EDIT: whoops, it's building linux-arm twice, but at least the point should be proven.
EDIT2: Ie. some restructuring is needed around $(GOARCH) and the make targets. I'm not sure how it should be done.

@tejal29
Copy link
Member

tejal29 commented May 6, 2019

Thanks for trying,
The makefile generates,
"out/skaffold/%-{GO-ARCH} rule here

Can you add an explicit rule for

$(BUILD_DIR)/$(PROJECT)-%-arm: ...

With the flags you mentioned?

@tejal29
Copy link
Member

tejal29 commented May 6, 2019

if that works, we can try introducing 2 archs for linux by creating a map of platforms to archs

@ljani
Copy link
Author

ljani commented May 7, 2019

Success:

root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# git diff
diff --git a/Makefile b/Makefile
index 1f6a11ad..e8c327ad 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ GCP_PROJECT ?= k8s-skaffold
 GKE_CLUSTER_NAME ?= integration-tests
 GKE_ZONE ?= us-central1-a

-SUPPORTED_PLATFORMS := linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
+SUPPORTED_PLATFORMS := linux-arm linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
 BUILD_PACKAGE = $(REPOPATH)/cmd/skaffold

 VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
@@ -55,6 +55,9 @@ $(BUILD_DIR)/$(PROJECT): $(BUILD_DIR)/$(PROJECT)-$(GOOS)-$(GOARCH)
 $(BUILD_DIR)/$(PROJECT)-%-$(GOARCH): $(GO_FILES) $(BUILD_DIR)
        GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $
(BUILD_PACKAGE)

+$(BUILD_DIR)/$(PROJECT)-%-arm:
+       GOOS=$* GOARCH=arm CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(B
UILD_PACKAGE)
+
 %.sha256: %
        shasum -a 256 $< > $@

root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# make cross
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-89-gf25b09fa-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-07T09:53:36Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=f25b09fabc5ad683e9affae9301072f5b93ca8bb -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-linux-arm github.com/GoogleContainerTools/skaffold/cmd/skaffold
shasum -a 256 out/skaffold-linux-arm > out/skaffold-linux-arm.sha256
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-89-gf25b09fa-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-07T09:53:36Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=f25b09fabc5ad683e9affae9301072f5b93ca8bb -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-linux-amd64 github.com/GoogleContainerTools/skaffold/cmd/skaffold
shasum -a 256 out/skaffold-linux-amd64 > out/skaffold-linux-amd64.sha256
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-89-gf25b09fa-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-07T09:53:36Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=f25b09fabc5ad683e9affae9301072f5b93ca8bb -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-darwin-amd64 github.com/GoogleContainerTools/skaffold/cmd/skaffold
shasum -a 256 out/skaffold-darwin-amd64 > out/skaffold-darwin-amd64.sha256
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-89-gf25b09fa-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-07T09:53:36Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=f25b09fabc5ad683e9affae9301072f5b93ca8bb -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-windows-amd64 github.com/GoogleContainerTools/skaffold/cmd/skaffold
cp out/skaffold-windows-amd64 out/skaffold-windows-amd64.exe
shasum -a 256 out/skaffold-windows-amd64.exe > out/skaffold-windows-amd64.exe.sha256
rm out/skaffold-windows-amd64
root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# file out/skaffold-linux-arm
out/skaffold-linux-arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

GOARM seems to default to GOARM=5 for me at least. I'm not sure if it's needed, I'm not really familiar with go. (see edit below)

EDIT: Compiling skaffold-windows-arm works as well, but I have not tried the executable. Also it defaults to different ARM version by default.

root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# git diff
diff --git a/Makefile b/Makefile
index 1f6a11ad..6934f2e4 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ GCP_PROJECT ?= k8s-skaffold
 GKE_CLUSTER_NAME ?= integration-tests
 GKE_ZONE ?= us-central1-a

-SUPPORTED_PLATFORMS := linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
+SUPPORTED_PLATFORMS := linux-arm windows-arm.exe linux-$(GOARCH) darwin-$(GOARCH) windows-$(GOARCH).exe
 BUILD_PACKAGE = $(REPOPATH)/cmd/skaffold

 VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
@@ -55,6 +55,9 @@ $(BUILD_DIR)/$(PROJECT): $(BUILD_DIR)/$(PROJECT)-$(GOOS)-$(GOARCH)
 $(BUILD_DIR)/$(PROJECT)-%-$(GOARCH): $(GO_FILES) $(BUILD_DIR)
        GOOS=$* GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $
(BUILD_PACKAGE)

+$(BUILD_DIR)/$(PROJECT)-%-arm:
+       GOOS=$* GOARCH=arm CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -gcflags $(GO_GCFLAGS) -asmflags $(GO_ASMFLAGS) -tags $(GO_BUILD_TAGS) -o $@ $(B
UILD_PACKAGE)
+
 %.sha256: %
        shasum -a 256 $< > $@

root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# make cross
GOOS=windows GOARCH=arm CGO_ENABLED=0 go build -ldflags " -extldflags \"\" -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v0.28.0-89-gf25b09fa-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2019-05-07T10:09:37Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=f25b09fabc5ad683e9affae9301072f5b93ca8bb -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty " -gcflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -asmflags "all=-trimpath=/go/src/github.com/GoogleContainerTools/skaffold" -tags "kqueue" -o out/skaffold-windows-arm github.com/GoogleContainerTools/skaffold/cmd/skaffold
cp out/skaffold-windows-arm out/skaffold-windows-arm.exe
shasum -a 256 out/skaffold-windows-arm.exe > out/skaffold-windows-arm.exe.sha256
...
root@3897f05daf4c:/go/src/github.com/GoogleContainerTools/skaffold# file out/skaffold-windows-arm.exe
out/skaffold-windows-arm.exe: PE32 executable (console) ARMv7 Thumb (stripped to external PDB), for MS Windows

EDIT: Actually the output from file does not have anything to do with ARM version.

@balopat balopat added kind/feature-request priority/p3 agreed that this would be good to have, but no one is available at the moment. labels Aug 14, 2019
@d11wtq
Copy link
Contributor

d11wtq commented Nov 19, 2019

I'm interested in this too. Did this make it into a PR?

@pisymbol
Copy link

Where are we with this?

@nkubala
Copy link
Contributor

nkubala commented Feb 13, 2020

I don't think this ever materialized into anything. @ljani are you interested in submitting a PR? we probably don't have time on our end right now but we'd be happy to accept a contribution.

@ljani
Copy link
Author

ljani commented Feb 13, 2020

Sorry, no. I abandoned my endeavour and moved back to amd64.

@pisymbol
Copy link

How hard would it be? Set GOARCH and type make?

@pisymbol
Copy link

Gave it a shot:

hack/generate-statik.sh
Collecting licenses
Error: go [list -e -json -compiled=false -test=false -export=false -deps=true -find=false -- github.com/GoogleContainerTools/skaffold/cmd/skaffold]: exit status 1: build github.com/Azure/go-autorest/tracing: cannot find module for path github.com/Azure/go-autorest/tracing

Usage:
  licenses save <package> [flags]

Flags:
      --force              Delete the destination directory if it already exists.
  -h, --help               help for save
      --save_path string   Directory into which files should be saved that are required by license terms

Global Flags:
      --alsologtostderr                  log to standard error as well as files
      --confidence_threshold float       Minimum confidence required in order to positively identify a license. (default 0.9)
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

F0217 08:13:49.776454    4073 main.go:43] go [list -e -json -compiled=false -test=false -export=false -deps=true -find=false -- github.com/GoogleContainerTools/skaffold/cmd/skaffold]: exit status 1: build github.com/Azure/go-autorest/tracing: cannot find module for path github.com/Azure/go-autorest/tracing
make: *** [Makefile:228: generate-statik] Error 1```

@nkubala
Copy link
Contributor

nkubala commented Feb 19, 2020

@pisymbol licenses also gives me issues for several different reasons, and it's hard for me to see if this is related to any changes you've made. why don't you try skipping the license check for now (just remove the rule from the Makefile) and see if you can get some binaries built? if you can get that far then we can figure out the license stuff last.

@pisymbol
Copy link

pisymbol commented Feb 23, 2020

@nkubala Works. No changes really other than setting GOARCH=arm:

pi@pimaster:~/skaffold $ ./out/skaffold version
v1.1.0-122-gea7953ea7-dirty

Note, I had to download and install latest golang than use 1.11 which had issues with io.StringWriter and other things.

@pisymbol
Copy link

pisymbol commented Feb 23, 2020

Note License retrieval now works too. So I think the only patch really needed (minimally):

diff --git a/Makefile b/Makefile
index 7a31e0e0e..2998df5bd 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 GOOS ?= $(shell go env GOOS)
-GOARCH = amd64
+GOARCH ?= amd64
 BUILD_DIR ?= ./out
 ORG := github.com/GoogleContainerTools
 PROJECT := skaffold

And then on the command line:

$ GOARCH=arm make
hack/generate-statik.sh
Collecting licenses
Collecting schemas
GOOS=linux GOARCH=arm CGO_ENABLED=1 go build -tags "osusergo netgo static_build release" -ldflags " -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.version=v1.1.0-122-gea7953ea7-dirty -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.buildDate=2020-02-23T15:06:23Z -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitCommit=ea7953ea71ec3935aec68dd4c399f3ac0463ba5d -X github.com/GoogleContainerTools/skaffold/pkg/skaffold/version.gitTreeState=dirty -s -w  -extldflags \"-static\"" -gcflags "all=-trimpath=/home/pi/skaffold" -asmflags "all=-trimpath=/home/pi/skaffold" -o out/skaffold-linux-arm github.com/GoogleContainerTools/skaffold/cmd/skaffold
cp ./out/skaffold-linux-arm out/skaffold

I guess we can autodiscovery the platform to be fancy.

This is the 1.2.0 release branch btw.

@nkubala
Copy link
Contributor

nkubala commented Mar 4, 2020

@pisymbol nice. want to submit a PR that updates the makefile here? you can put arm in the SUPPORTED_PLATFORMS field in the makefile and then we can verify that it works with the cross-compilation that we have set up in our release.

@pisymbol
Copy link

pisymbol commented Mar 4, 2020

@nkubala Sure. I can do that.

@pisymbol
Copy link

pisymbol commented Mar 5, 2020

@nkubala The SUPPORTED_PLATFORMS variable inherits from GOARCH so I don't think that is even necessary, right?

pisymbol added a commit to pisymbol/skaffold that referenced this issue Mar 5, 2020
Make GOARCH configurable in order to build skaffold on other platforms
such as arm and arm64.
dgageot added a commit that referenced this issue Mar 5, 2020
Make GOARCH configurable in order to build skaffold on other platforms
such as arm and arm64.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted We would love to have this done, but don't have the bandwidth, need help from contributors kind/feature-request meta/release priority/p3 agreed that this would be good to have, but no one is available at the moment.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants