Repository: facebookresearch/CompilerGym

Issue:
CI test failure: test_running_environment_in_background_process
## 🐛 Bug

Test failure in [test-llvm-env-macos](https://github.com/facebookresearch/CompilerGym/runs/3650623731?check_suite_focus=true) job of CI workflow:

```
________________ test_running_environment_in_background_process ________________
[gw2] darwin -- Python 3.9.7 /Users/runner/hostedtoolcache/Python/3.9.7/x64/bin/python

    def test_running_environment_in_background_process():
        """Test launching and running an LLVM environment in a background process."""
        queue = mp.Queue(maxsize=3)
        process = mp.Process(
            target=process_worker,
            args=("llvm-autophase-ic-v0", "cbench-v1/crc32", [0, 0, 0], queue),
        )
        process.start()
        try:
            process.join(timeout=10)
>           result = queue.get(timeout=10)

tests/llvm/multiprocessing_test.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <multiprocessing.queues.Queue object at 0x114640250>, block = True
timeout = 9.999959355999977

    def get(self, block=True, timeout=None):
        if self._closed:
            raise ValueError(f"Queue {self!r} is closed")
        if block and timeout is None:
            with self._rlock:
                res = self._recv_bytes()
            self._sem.release()
        else:
            if block:
                deadline = time.monotonic() + timeout
            if not self._rlock.acquire(block, timeout):
                raise Empty
            try:
                if block:
                    timeout = deadline - time.monotonic()
                    if not self._poll(timeout):
>                       raise Empty
E                       _queue.Empty

/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/multiprocessing/queues.py:114: Empty
----------------------------- Captured stderr call -----------------------------
WARNING:root:Failed to parse '#include <...>' search paths from echo:

Process Process-1:
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/private/tmp/compiler_gym_runner/install_tests/tests/llvm/multiprocessing_test.py", line 20, in process_worker
    with gym.make(env_name) as env:
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/gym/envs/registration.py", line 200, in make
    return registry.make(id, **kwargs)
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/gym/envs/registration.py", line 105, in make
    env = spec.make(**kwargs)
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/gym/envs/registration.py", line 75, in make
    env = cls(**_kwargs)
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/compiler_gym/envs/llvm/llvm_env.py", line 103, in __init__
    datasets=_get_llvm_datasets(site_data_base=datasets_site_path),
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/compiler_gym/envs/llvm/llvm_env.py", line 70, in _get_llvm_datasets
    _LLVM_DATASETS = list(get_llvm_datasets(site_data_base=site_data_base))
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/compiler_gym/envs/llvm/datasets/__init__.py", line 257, in get_llvm_datasets
    yield CsmithDataset(site_data_base=site_data_base, sort_order=0)
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/compiler_gym/envs/llvm/datasets/csmith.py", line 129, in __init__
    self.clang_compile_command: List[str] = ClangInvocation.from_c_file(
  File "/Users/runner/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/compiler_gym/envs/llvm/llvm_benchmark.py", line 143, in command
    for directory in get_system_includes():
TypeError: 'NoneType' object is not iterable
```

## Environment

Please fill in this checklist:

- CompilerGym: v0.1.10
- How you installed CompilerGym (conda, pip, source): source
- OS: macOS
- Python version: 3.9



Discussion:

Resolving patch:
diff --git a/compiler_gym/envs/llvm/llvm_benchmark.py b/compiler_gym/envs/llvm/llvm_benchmark.py
--- a/compiler_gym/envs/llvm/llvm_benchmark.py
+++ b/compiler_gym/envs/llvm/llvm_benchmark.py
@@ -86,10 +86,11 @@ def get_compiler_includes(compiler: str) -> Iterable[Path]:
         elif line.startswith("#include <...> search starts here:"):
             in_search_list = True
     else:
-        raise OSError(
-            f"Failed to parse '#include <...>' search paths from {compiler}:\n"
-            f"{stderr.strip()}"
-        )
+        msg = f"Failed to parse '#include <...>' search paths from {compiler}"
+        stderr = stderr.strip()
+        if stderr:
+            msg += f":\n{stderr}"
+        raise OSError(msg)
 
 
 # Memoized search paths. Call get_system_includes() to access them.
@@ -115,6 +116,7 @@ def get_system_includes() -> List[Path]:
             _SYSTEM_INCLUDES = list(get_compiler_includes(system_compiler))
         except OSError as e:
             logging.warning("%s", e)
+            _SYSTEM_INCLUDES = []
     return _SYSTEM_INCLUDES
 
 


Test patch: