[build] Enable PIE on non-IA32 Linux.

(Gets ASLR working to hopefully make non-determinism surface more often.)
(Thought I enabled this back in 2015...)

Bug: b/22479195
Bug: https://github.com/dart-lang/sdk/issues/31427
Change-Id: I02381e364ccb8bccbf5aa561959bceb7be067128
Reviewed-on: https://dart-review.googlesource.com/59281
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index e9129e3..3ad0c96 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -292,11 +292,16 @@
     "//build/config/mac:mac_dynamic_flags",
     "//build/config/mac:mac_executable_flags",
   ]
-} else if (is_linux || is_android) {
-  _executable_configs += [ "//build/config/gcc:executable_ldconfig" ]
-  if (is_android) {
-    _executable_configs += [ "//build/config/android:executable_config" ]
-  }
+} else if (is_linux) {
+  _executable_configs += [
+    "//build/config/gcc:executable_ldconfig",
+    "//build/config/linux:executable_config",
+  ]
+} else if (is_android) {
+  _executable_configs += [
+    "//build/config/gcc:executable_ldconfig",
+    "//build/config/android:executable_config",
+  ]
 }
 set_defaults("executable") {
   configs = _executable_configs
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index eeece1c..8154e4e 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -234,7 +234,7 @@
   # 3. When using the sanitizers.
   # Otherwise there is a performance hit, in particular on ia32.
   if (is_android || is_asan || is_lsan || is_msan || is_tsan ||
-      (is_linux && current_cpu == "arm")) {
+      (is_linux && current_cpu != "x86")) {
     cflags += [ "-fPIC" ]
     ldflags += [ "-fPIC" ]
   }
diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn
index 051809a..215025b 100644
--- a/build/config/linux/BUILD.gn
+++ b/build/config/linux/BUILD.gn
@@ -28,3 +28,10 @@
     }
   }
 }
+
+config("executable_config") {
+  if (current_cpu != "x86") {
+    cflags = [ "-fPIE" ]
+    ldflags = [ "-pie" ]
+  }
+}