<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57580>57580</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            compiler-rt: lit crashes if ld.gold is not found
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mgorny
      </td>
    </tr>
</table>

<pre>
    If there is no `ld.gold` installed, compiler-rt's test suite crashes with the following exception:

```
ninja -v -j12 -l0 check-builtins
[0/1] cd /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins && /usr/bin/python3.11 /usr/bin/lit -vv -j 12 /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/TestCases /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/Unit/I386LinuxConfig /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/Unit/X86_64LinuxConfig
lit: /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py:146: warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir:     "/usr/lib/clang/15.0.0/lib/linux"
compiler-rt libdir:  "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/lib/linux"
lit: /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py:156: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
lit: /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py:167: note: Testing using libraries in "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/lib/linux"
lit: /usr/lib/python3.11/site-packages/lit/TestingConfig.py:136: fatal: unable to parse config file '/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/lit/TestingConfig.py", line 125, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 561, in <module>
    if is_binutils_lto_supported():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt/test/lit.common.cfg.py", line 543, in is_binutils_lto_supported
    ld_cmd = subprocess.Popen([exe, '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1022, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1899, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'GOLD_EXECUTABLE-NOTFOUND'

FAILED: test/builtins/CMakeFiles/check-builtins /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/CMakeFiles/check-builtins 
cd /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins && /usr/bin/python3.11 /usr/bin/lit -vv -j 12 /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/TestCases /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/Unit/I386LinuxConfig /tmp/portage/sys-libs/compiler-rt-15.0.0/work/compiler-rt-15.0.0_build/test/builtins/Unit/X86_64LinuxConfig
ninja: build stopped: subcommand failed.
```

Filed https://reviews.llvm.org/D133358 with a proposed fix.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWMtu2zoQ_Rp7Q1iQLOvhhReJH0UA1ylaB-hOoCRKZkKRAkkl9d_fGT1s59EL9CJN76KGYFGkOHNmODwzVKry4-KmIPbANCPcEKnIKHRF7pRK5NAiXBpLhWD5aLokmapqLpieaDuaRoZYZiwxDbeMZJqaAzPkidsDiiOFEkI9cVkS9iNjteVKjvyrkbsaucN_6PZX-yi5vKdk8kgm996UTIRLsgPLHiZpw4UFGP2k4NodTTfeKFiRLCfQtFUN_7XSlpYMWuZoJoKnBpoXeCde4LgOTn1S-uHNsQQ15SgRzILboBiUhHChrsZoHOASNR7tQUnf8byXI4JbsAMNIWDJR0CE5h56ltQw81EK7yTHnhs_DrdcNj-WSha8_GDt3-MwCWcX-rsogRWAYHsfLGf1INWBgUpJJytKpz6CDm8WoqYnqiF-S2wu-6kE1JCca0DhjfzV5eYZhjqwlxOwE2TgbzSdnuIKRhCUoKACgn8A23ULtB7fbqW9UDMI7KS9_8q8BeEDvR-88v7t5y832_XX5Os-2a-_7ZNv-6vd6mp7u1sn13c321Wyvbn-Butxu0NGSxsLbMWfUVmuGBIhPtYIvR1DIkNau2-M7SiJ6EZaXjH0sqaaI_kdmGzfaqUNViCvZm1wNprlxCrSGNDCiwJIV74hxyFrjoxMKgVvHV8BBAknaKehQQNtmRZMU5oYZn_BIZsNSm6FoQ2vzeMyE00OJvDOyrOBkCQYzZ0PX_4wQk2wVgzv-36dGoP_l7j_UPhfbt5zukDFsIyTmmYPgMN0xvUUDsg7Iust9NsALygkYWw0kqaijYCaasP6VScFwAOF0W_3OapYEqtpxlKA33p9eAAAcaUgejTLMK4zqBuIoChpfkr9hGw6rC_J7b_4B4UsYaElg0QbYBuWWiiaJ4VWVVJTexi0EihDWAYIe0OhlYNTcU77GtzBuO6dCAFj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