<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72586>72586</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Unable to Run `compiler-rt` Tests With `runtimes/` Builds on Trunk
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ajordanr-google
</td>
</tr>
</table>
<pre>
This is potentially a `runtimes/` build issue, or a documentation issue. At the very least, it's unergonomic currently. In this particular example, I wanted to run `scudo_standalone` unittests, but many other compiler-rt tests hit this issue too.
# Reproduction
We can try to run `compiler-rt` unittests with `runtimes/` with the following cmake configuration:
```bash
# LLVM_ENABLE_PROJECTS may be optional? It fails in both cases.
cmake \
-G Ninja \
-S runtimes \
-B build \
-DLLVM_ENABLE_RUNTIMES='compiler-rt' \
-DCOMPILER_RT_SANITIZERS_TO_BUILD='scudo_standalone;gwp_asan;asan;cfi;hwasan' \
-DCOMPILER_RT_INCLUDE_TESTS=ON \
-DLLVM_ENABLE_PROJECTS='compiler-rt'
ninja -C build # Successfully builds! Works fine.
ninja -C build scudo_standalone # Also works fine!
ninja -C build check-scudo_standalone # Fails. You can try other 'check-' targets too.
```
We get something like:
```
FAILED: compiler-rt/test/scudo/standalone/CMakeFiles/check-scudo_standalone $HOME/llvm-project/build/compiler-rt/test/scudo/standalone/CMakeFiles/check-scudo_standalone
cd $HOME/llvm-project/build/compiler-rt/test/scudo/standalone && $HOME/bin/python $HOME/llvm-project/build/compiler-rt/bin/llvm-lit -sv --show-xfail --show-unsupported $HOME/llvm-project/build/compiler-rt/test/scudo/standalone/unit $HOME/llvm-project/build/compiler-rt/test/scudo/standalone/unit/gwp_asan
ninja: build stopped: subcommand failed.
```
# Expected Behaviour
We expect to run unittests, and have an identical or similar result to running the non-runtimes build:
```bash
cmake -DLLVM_ENABLE_PROJECTS='clang;compiler-rt' \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-G Ninja \
-B build \
-S llvm
ninja -C build
ninja -C build check-clang
ninja -C build check-scudo_standalone # Works and runs tests!
```
# Notes
First and foremost, while building the scudo_standalone unittests, we encountered an issue with a test failing to get past some directives. I believe this to be unrelated to this bug filing. I'm including the error in for completeness, as running the above you will first encounter this error.
```
[2/31] Generating ScudoUnitTestsObjects.wrappers_c_test.cpp.x86_64.o
FAILED: compiler-rt/lib/scudo/standalone/tests/ScudoUnitTestsObjects.wrappers_c_test.cpp.x86_64.o $HOME/llvm-project/build/compiler-rt/lib/scudo/standalone/tests/ScudoUnitTestsObjects.wrappers_c_test.cpp.x86_64.o
cd $HOME/llvm-project/build/compiler-rt/lib/scudo/standalone/tests && /usr/bin/cc -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -W
no-missing-field-initializers -Wimplicit-fallthrough -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wct
ad-maybe-unsupported -fdiagnostics-color -fdata-sections -Wall -Wno-unused-parameter -Wno-unknown-warning-option -g -Wno-suggest-override -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I$HOME/llvm-project/runtimes
/../third-party/unittest/googletest/include -I$HOME/llvm-project/runtimes/../third-party/unittest/googletest -I$HOME/llvm-project/compiler-rt/include -I$HOME/ll
vm-project/compiler-rt/lib -I$HOME/llvm-project/compiler-rt/lib/scudo/standalone -I$HOME/llvm-project/compiler-rt/lib/scudo/standalone/include -DGTEST_HAS_RTTI=0 -g -Wconversion -Wno-mis
matched-new-delete -DGWP_ASAN_HOOKS -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -c -o ScudoUnitTestsObjects.wrappers_c_test.cpp.x86_64.o $HOME/llvm-project/compiler-rt/lib/scudo/standalone/tests/wra
ppers_c_test.cpp
$HOME/llvm-project/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp:127:44: error: missing binary operator before token "("
127 | #if defined(__has_warning) && __has_warning("-Wfree-nonheap-object")
| ^
$HOME/llvm-project/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp:133:44: error: missing binary operator before token "("
133 | #if defined(__has_warning) && __has_warning("-Wfree-nonheap-object")
```
Patching it so `__has_warning("-Wfree-nonheap-object")` is within the `#if` directive works fine, and reveals the above deeper error with `llvm-lit`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WFtz4joS_jXOS5cosAMkDzyQADPsya0CWersCyXbbayJLHklGcL59VstGwIJk7mcnJ2aCuW2-979dUvcWrFSiIOgexV0R2e8crk2A_5Nm5Qrw1ZarySexTrdDua5sCAslNqhcoJLuQUOQa9tKuVEgTYIJ0GvDXElZArC2gqD8Bq0AQ6pTqoCleNOaFW_a8HQgcsR1mi2IJFbR58LF4R9C5VCs9JKFyKBpDIGlZPbFkwVODKj5MaJpJLcAL7wopRe1RQ2XDlMwWkwlSLbbFKlemkdVymXWiEZWCnhHFpniSeuHBRcbUG7HA0kuiiFRMOMA_8N5MLVOr3V4LRuBe1R0B42f8MIHrE0Oq0Scu7w3QIh4Qqc2R5YdKDhyBjYCJefCKcnU5wyLaXeCLWCpODPCIlWmVhVxsc0iIZHVvXa9f-Y2_zV0Jubf98ux3fDq5vx8uHx_l_j6_kMCr6FGEGXJIfLIJrA1EHGhbQgFMTa5ZBwi7bxu9YedK_rR2Bf4E6ob_yABGwGOzeOyFdNdRxwjw6Neny6m09vx7MgGgVh_zBUYf-I6fr-9mF6M35cPs6Xs-HddD79z_hxtpzfL6-epjejmv9d8qOr1aZccstVEF01P0kmgugq3_jHIy1v1Ezvrm-eRuPlfDybk4H3d991Yxfb0254DuVDxq6bgAClZ1YlCVqbVdRanm6DsAMLbZ4tZEJh6yTvWze9rKG0GjZ7ziDsnORNckye2TsJXsSESqAFf-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