| |
@@ -20,22 +20,28 @@
|
| |
#
|
| |
# SPDX-License-Identifier: GPL-3.0-or-later
|
| |
|
| |
+ # This *must* be all on one line, as it will be used in shell
|
| |
+ # assignments. eg
|
| |
+ #
|
| |
+ # GOBUILDFLAGS="%gobuildflags" %configure
|
| |
+ #
|
| |
+ # Or
|
| |
+ #
|
| |
+ # %make GOBUILDFLAGS="%gobuildflags"
|
| |
+ #
|
| |
+ %gobuildflags() %{expand:%{gocompilerflags} -tags=\\"rpm_crashtraceback \\" -ldflags \\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'\\" -a -v -x}
|
| |
+
|
| |
# Define commands for building
|
| |
# BUILD_ID can be generated for golang build no matter of debuginfo
|
| |
%gobuild(o:) %{expand:
|
| |
# https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12
|
| |
%global _dwz_low_mem_die_limit 0
|
| |
- %ifnarch ppc64
|
| |
- %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} GO111MODULE=off \\
|
| |
- go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};
|
| |
- %else
|
| |
%{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} GO111MODULE=off \\
|
| |
- go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};
|
| |
- %endif
|
| |
+ go build %{?gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**};
|
| |
}
|
| |
${workroot}${GOPATH:+:${GOPATH}}
|
| |
|
| |
# Define commands for testing
|
| |
- %gotestflags -buildmode pie -compiler gc
|
| |
+ %gotestflags %{gocompilerflags}
|
| |
%gotestextldflags %__global_ldflags %{?__golang_extldflags}
|
| |
%gotest() GO111MODULE=off go test %{gotestflags} -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**};
|
| |
The commit message in the second patch has details of key rationale for this change. Essentially though in libvirt, we are integrating Go code for parts of our project and this code is built by our existing build system. It is not possible to have RPM directly run "go build", so we need to pass Go build flags to make.
Along with these patches, the Fedora rawhide go-rpm-macros spec file would need the following change
I've tested this with the trivial app using a specfile that does this:
which calls a makefile which does this