Commit Graph

33 Commits

Author SHA1 Message Date
Jeffery To a80af7e443
golang: Update to 1.21.0, remove patch
Upstream has updated the Go compiler to not use gold when building for
arm, and is waiting for a fix to binutils (released in 2.41) before
doing the same for aarch64.[1]

Based on the above, it does not appear that
https://github.com/golang/go/pull/49748 will be merged. This removes the
patch from that pull request.

[1]: https://github.com/golang/go/issues/22040

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2023-08-15 11:57:28 +08:00
Jeffery To 8000a7f769
golang: Update to 1.20.6
Includes fix for CVE-2023-29406 (net/http: insufficient sanitization of
Host header).

This also updates the copyright information for various Go packaging
files.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2023-07-17 15:13:00 +08:00
Jeffery To 86fd1ebbe4 golang: Fix conditionals not stripped
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2022-04-15 15:18:12 -07:00
Jeffery To 8c0477a895 golang: Update to 1.18.1
Includes fixes for:
* CVE-2022-24675 - encoding/pem: stack overflow
* CVE-2022-28327 - crypto/elliptic: generic P-256 panic when scalar has
  too many leading zeroes

This also adds -buildvcs=false to omit VCS information in Go programs.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2022-04-15 15:18:12 -07:00
Jeffery To 478666b00b golang: Update to 1.18, update patch
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2022-03-28 19:42:59 -07:00
Jeffery To 9b3b837e20
golang: Remove deprecated variables in golang-package.mk
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2021-09-13 05:29:47 +08:00
Jeffery To d5dc30fe80
golang: Add option to enable Spectre mitigations
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-10-06 16:34:41 +08:00
Jeffery To 2d22a629f5
golang: Move package scripts into golang-build.sh
This also adds GO_PKG_INSTALL_BIN_PATH which determines the path where
binaries are installed by GoPackage/Package/Install/Bin (this was
previously hard-coded to /usr/bin).

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-10-06 16:34:40 +08:00
Jeffery To 4773c288cd
golang: Quote variables passed to the shell
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-10-06 16:34:40 +08:00
Jeffery To 9074dbd917
golang: Share build cache across package builds
This also adds a config option GOLANG_BUILD_CACHE_DIR to customize the
location of the build cache directory.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-10-06 16:28:06 +08:00
Jeffery To 3dd55b504c
golang: Move module cache into DL_DIR
This also adds a config option GOLANG_MOD_CACHE_WORLD_READABLE; if
enabled, chmod is run after a Go package build to make all
files/directories in the module cache world-readable.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-10-06 16:27:52 +08:00
Jeffery To 34a3e58a12 golang: Add GO_PKG_TAGS for Go packages
This adds a new Makefile variable, GO_PKG_TAGS, for Go packages. When
set, the value is passed as the parameter of the -tags option for 'go
install'.

This also updates syncthing to use this variable.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-07-15 21:09:17 -10:00
Jeffery To d73fe8ebc3
golang: Evaluate "go install" arguments during Build/Compile
This evaluates the arguments passed to "go install" during Build/Compile
rather than when golang-package.mk is included.

This also changes build directory-related variables to be recursively
expanded, because PKG_BUILD_DIR depends on BUILD_VARIANT and so can
change during different runs of Build/Compile.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-06-29 02:24:52 +08:00
Jeffery To 25a7f0045e golang: Move "go install" arguments logic, add buildid
The moves the setting of arguments for "go install" out of the shell
script in GoPackage/Build/Compile and into make.

This also adds the -buildid link flag for reproducible builds.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-05-13 16:07:27 +08:00
Jeffery To d2f5e6966b golang: Rename GoPackage/Environment to GO_PKG_VARS
The variable is a list of shell variables; the new name is more in-line
with other parts the build system (CONFIGURE_VARS, MAKE_VARS, etc.).

GoPackage/Environment is kept (for now) in case other feeds are using
it.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-05-13 16:07:20 +08:00
Jeffery To bcdd6e64fa golang: Remove RSTRIP definition from golang-package.mk
Since RSTRIP is defined in rules.mk as a recursively expanded variable,
there is no need to define it again after setting STRIP in
golang-package.mk.

This also adds a note to the comment for GO_PKG_LDFLAGS to say that -s
and -w flags are not necessary.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-05-13 00:18:50 +08:00
Jeffery To 89d3f0ab54 golang: Reorganize GoPackage/Environment and Makefile variables
* Move more environment variables into GoPackage/Environment
* Split GoPackage/Environment into target and build sections
* Do not set GOROOT_FINAL for Go packages (setting it should only affect
  the Go compiler and not Go packages)
* Set CGO_LDFLAGS to $(TARGET_LDFLAGS)
* Move GO_TARGET_* variables from golang-values.mk, and GO_VERSION_*
  variables from golang-version.mk, into golang/Makefile

This also updates runc, containerd, and docker-ce to reflect the changes
in GoPackage/Environment.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-02-05 14:19:34 +08:00
Jeffery To 3b5f1c73fb golang: Improve build isolation from user environment
* Set GOENV=off when building Go compiler and packages, to ignore user's
  environment configuration file
* Set GOCACHE when building host Go
* Unset GOTMPDIR, to use the buildroot temp directory instead of temp
  directories in build_dir

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-02-04 04:05:29 +08:00
Jeffery To b621d1b0f3 golang: Update for ASLR PIE tristate option change
The ASLR PIE option was changed to a tristate option
(openwrt/openwrt@19cbac7d26). This updates
the Go compiler package and golang-package.mk to account for this
change.

This also adds warning messages for when the user has selected PIE but
Go does not have PIE support for the chosen target.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-01-15 19:36:09 +08:00
Jeffery To c18adadd91 golang: Add support for ASLR/PIE for Go packages
This adds support to compile position-independent executables for
packages that use golang-package.mk.

Go packages will have PIE enabled if:
* Go supports PIE on the target platform;
* CONFIG_PKG_ASLR_PIE is selected; and
* PKG_ASLR_PIE (for the package) is not set to 0

Go 1.13 supports PIE for x86 and arm targets; mips support is in
progress[1].

[1]: https://github.com/golang/go/issues/21222#issuecomment-542064462

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-01-14 22:17:21 +08:00
Jeffery To 232634fb9a golang: Strip whitespace when using Go package variables
This adds calls to the strip function in golang-package.mk when using
variables expected to be set by Go packages.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2020-01-08 19:29:54 +08:00
Jeffery To dbd6f224c3 golang: Format TARGET_LDFLAGS for gcc
go invokes the external linker by calling gcc, so -zxxx options in
TARGET_LDFLAGS (in golang-package.mk) need to be formatted as -Wl,z,xxx.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-12-29 18:49:06 +08:00
Jeffery To 4827bc7509 golang: Fix ldflags when GO_PKG_LDFLAGS is set
go build/install supports multiple -ldflags arguments, but they are not
combined; for each package, the latest match on the command line is
used.[1]

Previously, the main executable would not be affected by the default
ldflags if GO_PKG_LDFLAGS or GO_PKG_LDFLAGS_X were set. (The default
ldflags instructs go to use the external linker.)

This fixes golang-package.mk so that the default ldflags take effect in
all cases.

[1]: https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-12-26 20:53:40 +08:00
Jeffery To 22ee6e86a0 golang: Use new -trimpath option when compiling Go packages
Go 1.13 added a new -trimpath option to the "go build" command[1] that
removes system paths from compiled executables. This replaces the
previous -trimpath flags.

There are still system paths in the compiled executable (for crti.o and
crtn.o, when cross-compiling); these appear to be stripped during the
packaging process.

[1]: https://golang.org/doc/go1.13#trimpath

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-09-13 17:48:40 +08:00
Xingwang Liao f072cd6adf
golang: Add the ability to custom build environment
by overwrite the GoPackage/Environment definition

Signed-off-by: Xingwang Liao <kuoruan@gmail.com>
2019-06-10 10:42:52 +08:00
Jeffery To 0d3ec704b0 golang: Add support for setting gcflags/ldflags from package Makefile
This adds several variables for Go package Makefiles:
* GO_PKG_GCFLAGS - go tool compile arguments
* GO_PKG_LDFLAGS - go tool link arguments
* GO_PKG_LDFLAGS_X - go tool link -X definitions

Settings these will add the corresponding flags to the go install
command line. (Other command line arguments can still be added by
passing them as the first argument to GoPackage/Build/Compile.)

This also adds Go's runtime environment variables (GOGC, GOMAXPROCS,
GOTRACEBACK) to the unexport list.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-03-21 10:10:21 +08:00
Jeffery To 7dc1f3e029 golang: Install go.mod/go.sum by default
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-02-11 20:33:45 +08:00
Jeffery To a80d54fc49 golang: Install files with .cpp/.hpp suffixes by default
This also updates the URL for dh-golang.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-02-11 20:33:44 +08:00
Jeffery To 081808ce69 golang: Fix handling of filenames with spaces
Closes #7127.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-02-11 20:33:44 +08:00
Jeffery To 0fa7f3c882 golang: fix package clean / autoremove, add output whitespace
go 1.11 added modules, which are cached locally. The go developers have
decided to make this cache read-only (golang/go#27455), which causes
problems with package clean / autoremove (#7635).

This adds a call to clear this cache right after building, as currently
there is no easy way to hook into autoremove (it may be possible to hook
into package clean).

This also adds whitespace (blank lines) to certain places in make
output, to aid debugging.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2018-12-12 04:23:47 +08:00
Jeffery To 453749f12b golang: Update to 1.11.1, add mips64 / mips64el builds
Go 1.11 added softfloat support for 64-bit MIPS systems[1], so this also
adds builds for mips64 and mips64el.

[1] https://golang.org/doc/go1.11#mips

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2018-10-13 02:30:03 +08:00
Jeffery To e8adf63001 golang: Allow additional arguments when compiling Go packages
This updates GoPackage/Build/Compile in golang-package.mk to accept
additional arguments that are passed to the go command line.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2018-06-28 02:51:09 +08:00
Jeffery To c137c38257 golang: new packages
From golang.org:
The Go programming language is an open source project to make
programmers more productive.

This commit consists of two "parts":

* golang/host: Main Go compiler for host (installed to
  STAGING_DIR_HOST/lib/go-cross), used to cross-compile Go programs to
  be packaged.

* golang (and golang-src/golang-doc): Main Go compiler for on-target
  development. These packages are quite large, but I would expect only
  developers to install these.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2018-03-21 09:21:57 +08:00