exporting Go functions make the Android build 4x larger
I just noticed that the snowflakeclient.aar that I've been building has ballooned in size from ~5mb to ~25mb by exporting a single function. Perhaps gomobile bind
stops stripping the binary then? This is the diff that made it happen:
diff --git a/client/snowflake.go b/client/snowflake.go
index 02bbf1e..c024cd2 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -93,14 +93,14 @@ func parseIceServers(s string) []webrtc.ICEServer {
return servers
}
-func main() {
- iceServersCommas := flag.String("ice", "", "comma-separated list of ICE servers")
- brokerURL := flag.String("url", "", "URL of signaling broker")
- frontDomain := flag.String("front", "", "front domain")
- logFilename := flag.String("log", "", "name of log file")
- logToStateDir := flag.Bool("log-to-state-dir", false, "resolve the log file relative to tor's pt state dir")
+func Load() {
+ iceServersCommas := flag.String("ice", "stun:stun.l.google.com:19302", "comma-separated list of ICE servers")
+ brokerURL := flag.String("url", "https://snowflake-broker.azureedge.net/", "URL of signaling broker")
+ frontDomain := flag.String("front", "ajax.aspnetcdn.com", "front domain")
+ logFilename := flag.String("log", "snowflakeclient.log", "name of log file")
+ logToStateDir := flag.Bool("log-to-state-dir", true, "resolve the log file relative to tor's pt state dir")
keepLocalAddresses := flag.Bool("keep-local-addresses", false, "keep local LAN address ICE candidates")
- unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
+ unsafeLogging := flag.Bool("unsafe-logging", true, "prevent logs from being scrubbed")
max := flag.Int("max", DefaultSnowflakeCapacity,
"capacity for number of multiplexed WebRTC peers")
Here are two builds with binary artifacts to compare: