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

    <tr>
        <th>Summary</th>
        <td>
            [sanitizer] tests fail to bootstrap on musl with: in function `__sanitizer::NanoTime()': undefined reference to `clock_gettime'
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    hey, I played around with llvm tools on a linux amd64-musl (gentoo), and wanted to run the tests to see if they are broken. It seems the compile never makes it to testing, as this sort of bootstrap process fails to compille: 

```
[31/138] cd /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/sanitizer_common/tests && /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/llvm/15/bin/clang++ sanitizer_nolibc_test_main.x86_64.o -Wl,-whole-archive libRTSanitizerCommon.test.nolibc.x86_64.a -Wl,-no-whole-archive -o /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/sanitizer_common/tests/./Sanitizer-x86_64-Test-Nolibc -Wl,-O1 -Wl,--as-needed -static -nostdlib -m64 -m64
FAILED: lib/sanitizer_common/tests/Sanitizer-x86_64-Test-Nolibc /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/sanitizer_common/tests/Sanitizer-x86_64-Test-Nolibc 
cd /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/sanitizer_common/tests && /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/llvm/15/bin/clang++ sanitizer_nolibc_test_main.x86_64.o -Wl,-whole-archive libRTSanitizerCommon.test.nolibc.x86_64.a -Wl,-no-whole-archive -o /var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt_build/lib/sanitizer_common/tests/./Sanitizer-x86_64-Test-Nolibc -Wl,-O1 -Wl,--as-needed -static -nostdlib -m64 -m64
/usr/bin/x86_64-gentoo-linux-musl-ld: libRTSanitizerCommon.test.nolibc.x86_64.a(sanitizer_linux.cpp.o): in function `__sanitizer::NanoTime()':
/var/tmp/portage/sys-libs/compiler-rt-sanitizers-15.0.7/work/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:592: undefined reference to `clock_gettime'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

the problem seems to be this line: https://github.com/llvm/llvm-project/blob/release/16.x/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp#L592

@MaskRay maybe your patch from last year (https://reviews.llvm.org/D98121) is incomplete? 

full build log is attached: [sanitizers.log.gz](https://github.com/llvm/llvm-project/files/10892865/sanitizers.log.gz)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk-P27YT_TT0ZSBBoixZOvjgjX8CFsgvBdIFejQoaSyxpjgCSXnX-fQF6X_ZNtgmLZpcAhi0TXGGb97MaJ6wVvYacc3yB5ZvF2J2A5m1dbi3pBcNdaf1gCfG38EjTEqcsANhaNYdPEs3gFLHERyRskAaBCip5xcQY1cso3G2Chgve9SOiPHKexHeUmiHHTgCM2twA4JD66zfsIgg937vBMIgNIYOqGN4dP7RaMPplsZJKgSNRzQwigNakM6bez9S9-Eif1ZasGQc0B4aImedERNMhlq0FvZCqnDp2Z9Clm2AJVuWbC5rkVw-57_5Q5YyXqdZyfIttB0wXh-FYbx248R4PZFxokfGa3uykZKNZby-gDWRcZEVWjr5CY2N0jxO4hXj9TOZw-tju2aWqmO8VrLxvq5Gu5bGkbS_LtDFeMF48X1A-Dz70HPG60Z6DK0SnugHxh_gDlGTkk278wB3o5A6fimLXbGMCaLfFOPvoueBFEbCtIM8IijZfHz69Wr9LsQXe-P47OhqLq7mmv7kIaIfmwXG65jx-hZDdE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