"""Returns full-path of gomacc if goma is available or None."""
# Start goma support from os/arch/toolname that have been tested.
# Set NO_NACL_GOMA=true to force to avoid using goma.
- if (osname not in ['linux', 'mac'] or arch not in ['x86-32', 'x86-64']
+ if (osname not in ['linux', 'mac']
+ or arch not in ['x86-32', 'x86-64', 'pnacl']
or toolname not in ['newlib', 'glibc']
or IsEnvFlagTrue('NO_NACL_GOMA', default=False)):
return {}
- # TODO(yyanagisawa): should fix ambiguous executable selection on pnacl-clang.
- if is_pnacl_toolchain:
- return {}
goma_config = {}
- try:
- gomacc_base = 'gomacc.exe' if os.name == 'nt' else 'gomacc'
- # Search order of gomacc:
- # --gomadir command argument -> GOMA_DIR env. -> PATH env.
- search_path = []
- # 1. --gomadir in the command argument.
- if gomadir:
- search_path.append(gomadir)
- # 2. Use GOMA_DIR environment variable if exist.
- goma_dir_env = os.environ.get('GOMA_DIR')
- if goma_dir_env:
- search_path.append(gomadir_env)
- # 3. Append PATH env.
- path_env = os.environ.get('PATH')
- if path_env:
- search_path.extend(path_env.split(os.path.pathsep))
-
- for directory in search_path:
- gomacc = os.path.join(directory, gomacc_base)
- if os.path.isfile(gomacc):
- port = subprocess.Popen(
- [gomacc, 'port'], stdout=subprocess.PIPE).communicate()[0].strip()
- if port:
- status = urllib2.urlopen(
- 'http://127.0.0.1:%s/healthz' % port).read().strip()
- if status == 'ok':
- goma_config['gomacc'] = gomacc
- break
- except Exception:
- # Anyway, fallbacks to non-goma mode.
- pass
+ gomacc_base = 'gomacc.exe' if osname == 'win' else 'gomacc'
+ # Search order of gomacc:
+ # --gomadir command argument -> GOMA_DIR env. -> PATH env.
+ search_path = []
+ # 1. --gomadir in the command argument.
+ if gomadir:
+ search_path.append(gomadir)
+ # 2. Use GOMA_DIR environment variable if exist.
+ goma_dir_env = os.environ.get('GOMA_DIR')
+ if goma_dir_env:
+ search_path.append(goma_dir_env)
+ # 3. Append PATH env.
+ path_env = os.environ.get('PATH')
+ if path_env:
+ search_path.extend(path_env.split(os.path.pathsep))
+
+ for directory in search_path:
+ gomacc = os.path.join(directory, gomacc_base)
+ if os.path.isfile(gomacc):
+ try:
+ port = int(subprocess.Popen(
+ [gomacc, 'port'], stdout=subprocess.PIPE).communicate()[0].strip())
+ status = urllib2.urlopen(
+ 'http://127.0.0.1:%d/healthz' % port).read().strip()
+ if status == 'ok':
+ goma_config['gomacc'] = gomacc
+ break
+ except (OSError, ValueError, urllib2.URLError) as e:
+ # Try another gomacc in the search path.
+ self.Log('Strange gomacc %s found, try another one: %s' % (gomacc, e))
if goma_config:
default_value = False
# pexe targets.
# 2. by specifying --build=newlib_translate to generated
# nexe via translation
- # 3. by specifying --build=newlib_nexe_pnacl use pnacl
- # toolchain in arm-native mode (e.g. the arm IRT)
+ # 3. by specifying --build=newlib_{nexe,nlib}_pnacl use pnacl
+ # toolchain in native mode (e.g. the IRT shim)
self.is_pnacl_toolchain = False
if self.outtype == 'translate':
self.is_pnacl_toolchain = True
self.empty = options.empty
self.strip_all = options.strip_all
self.strip_debug = options.strip_debug
+ self.tls_edit = options.tls_edit
self.finalize_pexe = options.finalize_pexe and arch == 'pnacl'
goma_config = GetGomaConfig(options.gomadir, self.osname, arch, toolname,
self.is_pnacl_toolchain)
out = self.LinkOutputName()
self.Log('\nLink %s' % out)
bin_name = self.GetCXXCompiler()
- MakeDir(os.path.dirname(out))
- self.CleanOutput(out)
- cmd_line = [bin_name, '-o', out, '-Wl,--as-needed']
+ link_out = out
+ if self.tls_edit is not None:
+ link_out = out + '.raw'
+
+ MakeDir(os.path.dirname(link_out))
+ self.CleanOutput(link_out)
+
+ cmd_line = [bin_name, '-o', link_out, '-Wl,--as-needed']
if not self.empty:
cmd_line += srcs
cmd_line += self.link_options
- err = self.Run(cmd_line, out)
+ err = self.Run(cmd_line, link_out)
if err:
raise Error('FAILED with %d: %s' % (err, ' '.join(cmd_line)))
+
+ if self.tls_edit is not None:
+ tls_edit_cmd = [FixPath(self.tls_edit), link_out, out]
+ tls_edit_err = self.Run(tls_edit_cmd, out)
+ if tls_edit_err:
+ raise Error('FAILED with %d: %s' % (err, ' '.join(tls_edit_cmd)))
+
return out
# For now, only support translating a pexe, and not .o file(s)
action='store_false')
parser.add_option('--source-list', dest='source_list',
help='Filename to load a source list from')
+ parser.add_option('--tls-edit', dest='tls_edit', default=None,
+ help='tls_edit location if TLS should be modified for IRT')
parser.add_option('-a', '--arch', dest='arch',
help='Set target architecture')
parser.add_option('-c', '--compile', dest='compile_only', default=False,