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

    <tr>
        <th>Summary</th>
        <td>
            MicroBenchmarks/XRay tests FAIL to link
        </td>
    </tr>

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

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

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

<pre>
    While building LLVM 17.0.0 rc1 on Solaris/amd64, two `test-suite` tests `FAIL`ed to link, breaking the `test-suite` build:
```
FAILED: MicroBenchmarks/XRay/ReturnReference/retref-bench
[...]
Undefined first referenced
 symbol                             in file
__xray_set_handler MicroBenchmarks/XRay/ReturnReference/CMakeFiles/retref-bench.dir/retref-bench.cc.o
__xray_patch MicroBenchmarks/XRay/ReturnReference/CMakeFiles/retref-bench.dir/retref-bench.cc.o
__xray_remove_handler MicroBenchmarks/XRay/ReturnReference/CMakeFiles/retref-bench.dir/retref-bench.cc.o
__xray_unpatch MicroBenchmarks/XRay/ReturnReference/CMakeFiles/retref-bench.dir/retref-bench.cc.o
ld: fatal: symbol referencing errors

FAILED: MicroBenchmarks/XRay/FDRMode/fdrmode-bench 
[...]
Undefined first referenced
 symbol                             in file
__xray_log_flushLog MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_log_init_mode MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_patch MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_remove_customevent_handler MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_unpatch MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_log_finalize MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
__xray_log_select_mode MicroBenchmarks/XRay/FDRMode/CMakeFiles/fdrmode-bench.dir/fdrmode-bench.cc.o
ld: fatal: symbol referencing errors
```
This is a regression from LLVM 16 and caused by problems of the `MicroBenchmarks/XRay/CMakeLists.txt` XRay checks.  The build log shows
```
-- Performing Test COMPILER_HAS_FXRAY_INSTRUMENT
-- Performing Test COMPILER_HAS_FXRAY_INSTRUMENT - Success
-- Looking for include file xray/xray_interface.h
-- Looking for include file xray/xray_interface.h - found
-- XRay tests enabled
```
- The first test obviously passed for a `test-release.sh` build: the just-built `clang` always supports the `-fxray-instrument` flag.
- The test for `xray/xray_interface.h` always passes as well: the XRay headers are always installed, irrespective whether XRay is supported on a particular target.  I believe this is something that should be fixed, thus avoiding the problem in the first place.
- The cmake tests are thus at least incomplete, wrong in the worst case.  They **should** check if an executable using XRay can be compiled **and** linked.  This way, the hack in `CMakeLists.txt` to check for `x86 && !darwin` (which is practically guaranteed to become stale) can be avoided.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8V1tv2zoS_jX0y8CCTDuy_eAHN6mxAexu4aS73SeDIkcSG4o0SMqO99cfjC45TS-nFxQOAlgXznzfzDcjDkUIurSIK3bzhnG-Q23Rh7zxjHN2czcSTaycX3nnYzXKnbqs_ltpg5A32ihtS9hu_7ODyTxJkxS8nICz8OCM8DowvhG1ymaM30I8O2BZGjHEcWh0RJalQHeBHm_W91uWpaggOjDaPpFJ7lE8EUKs8GvbFp9N1yy9Y-maZWn_396Sv7d3bLqGnZbevUErq1r4J6L0cS8ujG_2GBtv91igRyuR8Y3H6LEY57S493rzJkkSdnPX3X6wCgttUUGhfYjgB2PVvYdwqXNn4J_-tIVCG-wMDodnLy6HgPFQCasM-l_he7sTT7jRBsMX5BOl_ZePpEzcK9CjiLK6HpzH2p3w-mE29lqBttUIhYjC0EVfC0ONUB2j986HvrR-tk43d_udU8SrUL52C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