Enable link-time dead code elimination.

Change-Id: I53139b5f875487eb471c97ba4e77c8805dad9e8b
diff --git a/config/BUILD.gn b/config/BUILD.gn
index da6c0ac..68bad4c 100644
--- a/config/BUILD.gn
+++ b/config/BUILD.gn
@@ -63,8 +63,18 @@
 }
 
 config("release") {
-  cflags = [ "-O2" ]
   defines = [ "NDEBUG=1" ]
+  cflags = [
+    "-O2",
+    "-fdata-sections",
+    "-ffunction-sections",
+  ]
+
+  if (current_os == "mac") {
+    ldflags = [ "-Wl,-dead_strip" ]
+  } else {
+    ldflags = [ "-Wl,--gc-sections" ]
+  }
 }
 
 config("no_exceptions") {