[LLD] Fix probing a MSYS based 'tar' in a Windows Container

Don't run the 'tar' tool in a cleared environment with only the
LANG variable set, just set LANG on top of the existing environment.

If the 'tar' tool is an MSYS based tool, running it in a Windows
Container hangs if all environment variables are cleared - in
particular, the USERPROFILE variable needs to be kept intact.

This is the same issue fixed as was fixed in other places in
9de63b2e05, but contrary to running
the actual tests, running with an as-cleared-as-possible environment
here is less important.

Differential Revision: https://reviews.llvm.org/D99304
This commit is contained in:
Martin Storsjö 2021-03-24 23:58:54 +02:00
parent 32f6a15dfd
commit a88556733a
1 changed files with 3 additions and 1 deletions

View File

@ -101,11 +101,13 @@ if config.sizeof_void_p == 8:
tar_executable = lit.util.which('tar', config.environment['PATH'])
if tar_executable:
env = os.environ
env['LANG'] = 'C'
tar_version = subprocess.Popen(
[tar_executable, '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env={'LANG': 'C'})
env=env)
sout, _ = tar_version.communicate()
if 'GNU tar' in sout.decode():
config.available_features.add('gnutar')