shithub: orca

Download patch

ref: f123920b53eaf1bb7a9f41c2f9ea813cb127c31c
parent: 1bc8d428df2e6819e5ea387f3a647c5b947fea22
author: cancel <cancel@cancel.fm>
date: Sat Dec 1 12:31:49 EST 2018

Add build tool option for static linking

--- a/tool
+++ b/tool
@@ -21,7 +21,9 @@
     -d            Enable compiler safeguards like -fstack-protector.
                   You should probably do this if you plan to give the
                   compiled binary to other people.
-    -p            Enable PIE (ASLR)
+    --static      Build static binary.
+    --pie         Enable PIE (ASLR).
+                  Note: --pie and --static cannot be mixed.
     -s            Print statistics about compile time and binary size.
     -h or --help  Print this message and exit.
 EOF
@@ -42,12 +44,15 @@
 protections_enabled=0
 stats_enabled=0
 pie_enabled=0
+static_enabled=0
 
-while getopts c:dhpsv-: opt_val; do
+while getopts c:dhsv-: opt_val; do
   case "$opt_val" in
     -)
       case "$OPTARG" in
         help) print_usage; exit 0;;
+        static) static_enabled=1;;
+        pie) pie_enabled=1;;
         *)
           echo "Unknown long option --$OPTARG" >&2
           print_usage >&2
@@ -58,7 +63,6 @@
     c) cc_exe="$OPTARG";;
     d) protections_enabled=1;;
     h) print_usage; exit 0;;
-    p) pie_enabled=1;;
     s) stats_enabled=1;;
     v) verbose=1;;
     \?) print_usage >&2; exit 1;;
@@ -176,6 +180,9 @@
     add cc_flags -pie -fpie -Wl,-pie
   elif [[ $os != mac ]]; then
     add cc_flags -no-pie -fno-pie
+  fi
+  if [[ $static_enabled = 1 ]]; then
+    add cc_flags -static
   fi
   case "$1" in
     debug)