cros_sdk: increase max open files to 32768

ThinLTO opens lots of files at the same time.

BUG=chromium:707803
TEST=enter and leave SDK
    ulimit -a shows 'open files (-n) 32768'

Change-Id: Ie7de79620b6f39e761cbe4ebdc2bb1e93d9aec0b
Reviewed-on: https://chromium-review.googlesource.com/540675
Commit-Ready: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 7558d19..b8d1f79 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -18,6 +18,7 @@
 import os
 import pwd
 import re
+import resource
 import sys
 import urlparse
 
@@ -240,6 +241,8 @@
     cmd.append('--')
     cmd.extend(additional_args)
 
+  # ThinLTO opens lots of files at the same time.
+  resource.setrlimit(resource.RLIMIT_NOFILE, (32768, 32768))
   ret = cros_build_lib.RunCommand(cmd, print_cmd=False, error_code_ok=True,
                                   mute_output=False)
   # If we were in interactive mode, ignore the exit code; it'll be whatever