From 4d2ddc794011d9ad6e518aa08ff6df3413a90dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:43:19 +0200 Subject: [PATCH 1/6] Makefile: Simplify `build-tags` build target --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b73becff..604758ce 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,7 @@ build-quick: build-dbg: go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro -build-tags: fetch-tags generate - go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro +build-tags: fetch-tags build build-all: build From 6e46ae309052b8832f3fc3a25ec8428ffdf8f8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:05:37 +0200 Subject: [PATCH 2/6] Makefile: Remove "-s -w" from `build-dbg` target This will keep the symbol table and the DWARF information. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 604758ce..cda96241 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ build-quick: go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro build-dbg: - go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro + go build -trimpath -ldflags "$(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro build-tags: fetch-tags build From 90525a6a1dff5d638b59682911ee8b0be1cae52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:54:09 +0200 Subject: [PATCH 3/6] Makefile: Make all builds explicitly fully static by default (disable CGO) --- Makefile | 5 +++-- README.md | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index cda96241..398a4bee 100644 --- a/Makefile +++ b/Makefile @@ -10,16 +10,17 @@ ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \ go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)") GOBIN ?= $(shell go env GOPATH)/bin GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)' +CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0) DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/' build: generate build-quick build-quick: - go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro + CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro build-dbg: - go build -trimpath -ldflags "$(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro + CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "$(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro build-tags: fetch-tags build diff --git a/README.md b/README.md index b5d19ff6..709f71b2 100644 --- a/README.md +++ b/README.md @@ -180,16 +180,17 @@ You can install directly with `go get` (`go get github.com/zyedidia/micro/cmd/mi recommended because it doesn't build micro with version information (necessary for the plugin manager), and doesn't disable debug mode. -### Fully static binary +### Fully static or dynamically linked binary -By default, the micro binary will dynamically link with core system libraries (this is generally -recommended for security and portability). However, there is a fully static prebuilt binary that -is provided for amd64 as `linux-static.tar.gz`, and to build a fully static binary from source, run +By default, the micro binary is linked statically to increase the portability of the prebuilt binaries. +This behavior can simply be overriden by providing `CGO_ENABLED=1` to the build target. ``` -CGO_ENABLED=0 make build +CGO_ENABLED=1 make build ``` +Afterwards the micro binary will dynamically link with the present core system libraries. + ### macOS terminal If you are using macOS, you should consider using [iTerm2](http://iterm2.com/) instead of the default terminal (Terminal.app). The iTerm2 terminal has much better mouse support as well as better handling of key events. For best keybinding behavior, choose `xterm defaults` under `Preferences->Profiles->Keys->Presets...`, and select `Esc+` for `Left Option Key` in the same menu. The newest versions also support true color. From 6722cc81de2f1f02769f5f7922a67d6fe9092f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Wed, 11 Sep 2024 21:35:45 +0200 Subject: [PATCH 4/6] tools/cross-compile: Mark "Linux 64 fully static" to be same as "Linux 64" It is kept for the next release only to support... https://github.com/benweissmann/getmic.ro/blob/f90870e948afab8be9ec40884050044b59ed5b7c/index.sh#L197-L204 ...and allow a fluent switch via: https://github.com/benweissmann/getmic.ro/pull/40 --- tools/cross-compile.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/cross-compile.sh b/tools/cross-compile.sh index f98d7c24..a617773c 100755 --- a/tools/cross-compile.sh +++ b/tools/cross-compile.sh @@ -54,8 +54,12 @@ if ./tools/package-deb.sh $VERSION; then fi create_artefact_generic "linux64" -echo "Linux 64 fully static" -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build +echo "Linux 64 fully static (same as linux64)" +# It is kept for the next release only to support... +# https://github.com/benweissmann/getmic.ro/blob/f90870e948afab8be9ec40884050044b59ed5b7c/index.sh#L197-L204 +# ...and allow a fluent switch via: +# https://github.com/benweissmann/getmic.ro/pull/40 +GOOS=linux GOARCH=amd64 make build create_artefact_generic "linux64-static" echo "Linux 32" From fcc7421bca28f4bcdf4ec13f04958da127d34427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Tue, 17 Sep 2024 21:04:43 +0200 Subject: [PATCH 5/6] Makefile: Fix native darwin/macOS builds with forced CGO --- Makefile | 15 +++++++++++---- README.md | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 398a4bee..8862e058 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,21 @@ VERSION = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH HASH = $(shell git rev-parse --short HEAD) DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \ go run tools/build-date.go) -ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \ - GOARCH=$(shell go env GOHOSTARCH) \ - go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)") GOBIN ?= $(shell go env GOPATH)/bin GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)' -CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0) DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/' +CGO_ENABLED := $(if $(CGO_ENABLED),$(CGO_ENABLED),0) + +ADDITIONAL_GO_LINKER_FLAGS := "" +GOHOSTOS = $(shell go env GOHOSTOS) +ifeq ($(GOHOSTOS), darwin) + # Native darwin resp. macOS builds need external and dynamic linking + ADDITIONAL_GO_LINKER_FLAGS += $(shell GOOS=$(GOHOSTOS) \ + GOARCH=$(shell go env GOHOSTARCH) \ + go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)") + CGO_ENABLED = 1 +endif build: generate build-quick diff --git a/README.md b/README.md index 709f71b2..b395afee 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,9 @@ CGO_ENABLED=1 make build Afterwards the micro binary will dynamically link with the present core system libraries. +**Note for Mac:** +Native macOS builds are done with `CGO_ENABLED=1` forced set to support adding the "Information Property List" in the linker step. + ### macOS terminal If you are using macOS, you should consider using [iTerm2](http://iterm2.com/) instead of the default terminal (Terminal.app). The iTerm2 terminal has much better mouse support as well as better handling of key events. For best keybinding behavior, choose `xterm defaults` under `Preferences->Profiles->Keys->Presets...`, and select `Esc+` for `Left Option Key` in the same menu. The newest versions also support true color. From 3f1e5ea6df46ed08765e46cc7fbc1f583b9a88ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:10:46 +0200 Subject: [PATCH 6/6] README: Remove superflous whitespace --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b395afee..0a7f9f21 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Here is a picture of micro editing its source code. ![Screenshot](./assets/micro-solarized.png) To see more screenshots of micro, showcasing some of the default color schemes, see [here](https://micro-editor.github.io). - + You can also check out the website for Micro at https://micro-editor.github.io. - - -