Skip to content

Commit 86692a2

Browse files
committed
Update Go version used for project to 1.16
When this update was done for Arduino CLI, some difficulties were encountered with the release build system, the workarounds for which required some changes to the "DistTasks.yml" taskfile. The extensive comments added in that file explain the situation.
1 parent 2889722 commit 86692a2

File tree

6 files changed

+50
-9
lines changed

6 files changed

+50
-9
lines changed

.github/workflows/check-go-task.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Check Go
33

44
env:
55
# See: https://github.com/actions/setup-go/tree/v2#readme
6-
GO_VERSION: "1.14"
6+
GO_VERSION: "1.16"
77

88
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
99
on:

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install Go
4848
uses: actions/setup-go@v2
4949
with:
50-
go-version: "1.14"
50+
go-version: "1.16"
5151

5252
- name: Install Taskfile
5353
uses: arduino/setup-task@v1

DistTasks.yml

+45-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ version: "3"
1919

2020
vars:
2121
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
22-
GO_VERSION: "1.14.7"
22+
GO_VERSION: "1.16.4"
2323
CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"
2424

2525
tasks:
@@ -141,7 +141,7 @@ tasks:
141141
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
142142
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
143143
BUILD_PLATFORM: "linux/armv7"
144-
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
144+
CONTAINER_TAG: "{{.GO_VERSION}}-armhf"
145145
PACKAGE_PLATFORM: "Linux_ARMv7"
146146
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
147147

@@ -163,7 +163,35 @@ tasks:
163163
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
164164
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
165165
BUILD_PLATFORM: "linux/armv6"
166-
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
166+
# We are experiencing the following error with ARMv6 build:
167+
#
168+
# # github.com/arduino/arduino-cli
169+
# net(.text): unexpected relocation type 296 (R_ARM_V4BX)
170+
# panic: runtime error: invalid memory address or nil pointer dereference
171+
# [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51ae53]
172+
#
173+
# goroutine 1 [running]:
174+
# cmd/link/internal/loader.(*Loader).SymName(0xc000095c00, 0x0, 0xc0000958d8, 0x5a0ac)
175+
# /usr/local/go/src/cmd/link/internal/loader/loader.go:684 +0x53
176+
# cmd/link/internal/ld.dynrelocsym2(0xc000095880, 0x5a0ac)
177+
# /usr/local/go/src/cmd/link/internal/ld/data.go:777 +0x295
178+
# cmd/link/internal/ld.(*dodataState).dynreloc2(0xc007df9800, 0xc000095880)
179+
# /usr/local/go/src/cmd/link/internal/ld/data.go:794 +0x89
180+
# cmd/link/internal/ld.(*Link).dodata2(0xc000095880, 0xc007d00000, 0x60518, 0x60518)
181+
# /usr/local/go/src/cmd/link/internal/ld/data.go:1434 +0x4d4
182+
# cmd/link/internal/ld.Main(0x8729a0, 0x4, 0x8, 0x1, 0xd, 0xe, 0x0, 0x0, 0x6d7737, 0x12, ...)
183+
# /usr/local/go/src/cmd/link/internal/ld/main.go:302 +0x123a
184+
# main.main()
185+
# /usr/local/go/src/cmd/link/main.go:68 +0x1dc
186+
# Error: failed building for linux/armv6: exit status 2
187+
#
188+
# This seems to be a problem in the go builder 1.16.x that removed support for the R_ARM_V4BX instruction:
189+
# https://github.com/golang/go/pull/44998
190+
# https://groups.google.com/g/golang-codereviews/c/yzN80xxwu2E
191+
#
192+
# Until there is a fix released we must use a recent gcc for Linux_ARMv6 build, so for this
193+
# build we select the debian10 based container.
194+
CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian10"
167195
PACKAGE_PLATFORM: "Linux_ARMv6"
168196
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"
169197

@@ -207,6 +235,19 @@ tasks:
207235
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
208236
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
209237
BUILD_PLATFORM: "darwin/amd64"
210-
CONTAINER_TAG: "{{.GO_VERSION}}-darwin"
238+
# We are experiencing the following error with macOS_64bit build:
239+
#
240+
# Undefined symbols for architecture x86_64:
241+
# "_clock_gettime", referenced from:
242+
# _runtime.walltime_trampoline in go.o
243+
# ld: symbol(s) not found for architecture x86_64
244+
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
245+
#
246+
# The reason seems that go 1.16.x use a macos API which is available since 10.12
247+
# https://github.com/techknowlogick/xgo/issues/100#issuecomment-780894190
248+
#
249+
# To compile it we need an SDK >=10.12 so we use the debian10 based container that
250+
# has the SDK 10.14 installed.
251+
CONTAINER_TAG: "{{.GO_VERSION}}-darwin-debian10"
211252
PACKAGE_PLATFORM: "macOS_64bit"
212253
PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz"

docs/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ submitting a PR:
7676

7777
To build Arduino Lint from sources you need the following tools to be available in your local environment:
7878

79-
- [Go](https://golang.org/doc/install) version 1.14 or later
79+
- [Go](https://golang.org/doc/install) version 1.16 or later
8080
- [Taskfile](https://taskfile.dev/#/installation) to help you run the most common tasks from the command line
8181

8282
If you want to run integration tests or work on documentation, you will also need:

docsgen/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/arduino/arduino-lint/docsgen
22

3-
go 1.14
3+
go 1.16
44

55
replace github.com/arduino/arduino-lint => ../
66

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/arduino/arduino-lint
22

3-
go 1.14
3+
go 1.16
44

55
require (
66
github.com/Microsoft/go-winio v0.4.16 // indirect

0 commit comments

Comments
 (0)