Blob Blame History Raw
From 24ad876eaf3574add7465d3274b08382e6f05c1c Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Mon, 16 Jul 2018 11:41:25 -0400
Subject: [PATCH 2/5] Use Fedora compiler settings

Make sure we are using the same compiler flags as teh rest of the
distro.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
 script/build | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/script/build b/script/build
index 09d1a7cbecd6a5642faec8a6e99b7f911cd3fa2c..55782a74502e30b015e4321524a9694810c5fede 100755
--- a/script/build
+++ b/script/build
@@ -1,24 +1,35 @@
 #!/usr/bin/env bash
 # Usage: script/build [-o <BIN>]
 #        script/build files
 
 set -e
+set -x
 
 windows=
 [[ $OS == Windows* ]] && windows=1
 
+ARCH=`uname -m`
+if [ "$ARCH" == "ppc64" ]; then
+COMPILEPIE=
+else
+COMPILEPIE="-buildmode pie"
+fi
+
 find_source_files() {
   find . -maxdepth 2 -name '*.go' '!' -name '*_test.go' "$@"
 }
 
 build_hub() {
   mkdir -p "$(dirname "$1")"
   go build \
-	  -ldflags "-X github.com/github/hub/version.Version=`./script/version` $LDFLAGS" \
+	  $COMPILEPIE \
+	  -compiler gc \
+	  -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X github.com/github/hub/version.Version=`./script/version` $LDFLAGS" \
 	  -gcflags "$GCFLAGS" \
 	  -asmflags "$ASMFLAGS" \
+	  -a -v -x \
 	  -o "$1"
 }
 
 [ $# -gt 0 ] || set -- -o "bin/hub${windows:+.exe}"
 
-- 
2.21.0