|
|
92f5a5 |
diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang
|
|
|
92f5a5 |
index b0ab4c4..942549f 100644
|
|
|
92f5a5 |
--- a/rpm/macros.d/macros.go-compilers-golang
|
|
|
92f5a5 |
+++ b/rpm/macros.d/macros.go-compilers-golang
|
|
|
92f5a5 |
@@ -20,6 +20,8 @@
|
|
|
92f5a5 |
#
|
|
|
92f5a5 |
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
92f5a5 |
|
|
|
92f5a5 |
+%gocompilerflags -buildmode pie -compiler gc
|
|
|
92f5a5 |
+
|
|
|
92f5a5 |
# This *must* be all on one line, as it will be used in shell
|
|
|
92f5a5 |
# assignments. eg
|
|
|
92f5a5 |
#
|
|
|
92f5a5 |
@@ -29,22 +31,33 @@
|
|
|
92f5a5 |
#
|
|
|
92f5a5 |
# %make GOBUILDFLAGS="%gobuildflags"
|
|
|
92f5a5 |
#
|
|
|
92f5a5 |
-%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}
|
|
|
92f5a5 |
+%gobuildflags() %{expand:%{gocompilerflags} -tags=\\"rpm_crashtraceback ${BUILDTAGS:-} libtrust_openssl\\" -ldflags \\"-linkmode=external -compressdwarf=false ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'\\" -a -v -x}
|
|
|
92f5a5 |
+%_gobuildflags_internal() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-} libtrust_openssl" -ldflags "-linkmode=external -compressdwarf=false ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x}
|
|
|
92f5a5 |
|
|
|
92f5a5 |
# Turn off Go modules
|
|
|
92f5a5 |
%gomodulesmode GO111MODULE=off
|
|
|
92f5a5 |
|
|
|
92f5a5 |
# Define commands for building
|
|
|
92f5a5 |
# BUILD_ID can be generated for golang build no matter of debuginfo
|
|
|
92f5a5 |
+
|
|
|
92f5a5 |
+%_gobuild_cmd CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" go build %{_gobuildflags_internal}
|
|
|
92f5a5 |
+%gobuild_compat_el8(o:) %{expand:%{_gobuild_cmd} %{?**};}
|
|
|
92f5a5 |
%gobuild(o:) %{expand:
|
|
|
92f5a5 |
# https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12
|
|
|
92f5a5 |
%global _dwz_low_mem_die_limit 0
|
|
|
92f5a5 |
%{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\
|
|
|
92f5a5 |
- 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 %{?**};
|
|
|
92f5a5 |
+ %{_gobuild_cmd} %{?**};
|
|
|
92f5a5 |
}
|
|
|
92f5a5 |
${workroot}${GOPATH:+:${GOPATH}}
|
|
|
92f5a5 |
|
|
|
92f5a5 |
# Define commands for testing
|
|
|
92f5a5 |
%gotestflags %{gocompilerflags}
|
|
|
92f5a5 |
%gotestextldflags %__global_ldflags %{?__golang_extldflags}
|
|
|
92f5a5 |
-%gotest() %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**};
|
|
|
92f5a5 |
+
|
|
|
92f5a5 |
+%_gotest_cmd %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'"
|
|
|
92f5a5 |
+%gotest_compat_el8(o:) %{expand:%{_gotest_cmd} %{?**};}
|
|
|
92f5a5 |
+%gotest(o:) %{expand:
|
|
|
92f5a5 |
+ %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\
|
|
|
92f5a5 |
+ %{_gotest_cmd} %{?**};
|
|
|
92f5a5 |
+}
|
|
|
92f5a5 |
+
|