shithub: orca

Download patch

ref: 8514233eaed06f20f395b958db597b5aa5f5c794
parent: 978d241c356e31670b8923e863615ec5b831d8ae
author: cancel <cancel@cancel.fm>
date: Mon Dec 17 15:09:41 EST 2018

Change build tool to only specify no-pie for clang >= 6.0.0

--- a/tool
+++ b/tool
@@ -111,6 +111,10 @@
   fi
 }
 
+version_string_normalized() {
+  echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
+}
+
 if [[ ($os == bsd) || ($os == unknown) ]]; then
   warn "Build script not tested on this platform"
 fi
@@ -143,6 +147,14 @@
   warn "Failed to detect compiler version"
 fi
 
+cc_vers_is_gte() {
+  if [[ $(version_string_normalized "$cc_vers") -ge $(version_string_normalized "$1") ]]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
 add() {
   if [[ -z "${1:-}" ]]; then
     script_error "At least one argument required for array add"
@@ -179,7 +191,10 @@
   if [[ $pie_enabled = 1 ]]; then
     add cc_flags -pie -fpie -Wl,-pie
   elif [[ $os != mac ]]; then
-    add cc_flags -no-pie -fno-pie
+    # Only explicitly specify no-pie for clang if version >= 6.0.0
+    if [[ $cc_id == gcc ]] || cc_vers_is_gte "6.0.0"; then
+      add cc_flags -no-pie -fno-pie
+    fi
   fi
   if [[ $static_enabled = 1 ]]; then
     add cc_flags -static