Makefile: Make all builds explicitly fully static by default (disable CGO)

This commit is contained in:
Jöran Karl
2024-09-12 18:54:09 +02:00
parent 6e46ae3090
commit 90525a6a1d
2 changed files with 9 additions and 7 deletions

View File

@@ -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)") go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
GOBIN ?= $(shell go env GOPATH)/bin 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)' 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 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/' VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'
build: generate build-quick build: generate build-quick
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: 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 build-tags: fetch-tags build

View File

@@ -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), recommended because it doesn't build micro with version information (necessary for the plugin manager),
and doesn't disable debug mode. 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 By default, the micro binary is linked statically to increase the portability of the prebuilt binaries.
recommended for security and portability). However, there is a fully static prebuilt binary that This behavior can simply be overriden by providing `CGO_ENABLED=1` to the build target.
is provided for amd64 as `linux-static.tar.gz`, and to build a fully static binary from source, run
``` ```
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 ### 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. 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.