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

    <tr>
        <th>Summary</th>
        <td>
            libomp_check_linker_flag false positives
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            cmake,
            openmp
      </td>
    </tr>

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

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

<pre>
    libomp_check_linker_flag from https://github.com/llvm/llvm-project/blob/main/openmp/runtime/cmake/LibompCheckLinkerFlag.cmake for some reason checks linker flags by performing a nested cmake build (!!!) and checking the output of that build. This means that the output is not output of the linker command, but that of cmake/ninja, for example:
```
Change Dir:
 /builddir/build/BUILD/openmp-16.0.1.src/redhat-linux-build/CMakeFiles/CMakeTmp/link_flag_check_LIBOMP_HAVE_VERSION_SCRIPT_FLAG/build
 Run Build Command(s):/usr/bin/ninja-build -v && [1/2] /usr/bin/clang
 -Dfoo_EXPORTS -O2 -flto=thin -fexceptions -g -grecord-gcc-switches -pipe
 -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3
 -Wp,-D_GLIBCXX_ASSERTIONS --config
 /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -m64
  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection
  -fcf-protection -fPIC -MD -MT CMakeFiles/foo.dir/src_to_link.c.o -MF
 CMakeFiles/foo.dir/src_to_link.c.o.d -o CMakeFiles/foo.dir/src_to_link.c.o
  -c
 /builddir/build/BUILD/openmp-16.0.1.src/redhat-linux-build/CMakeFiles/CMakeTmp/link_flag_check_LIBOMP_HAVE_VERSION_SCRIPT_FLAG/src_to_link.c
 [2/2] : && /usr/bin/clang -fPIC -O2 -flto=thin -fexceptions -g
 -grecord-gcc-switches -pipe -Wall -Werror=format-security
 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
 --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
 -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables
 -fstack-clash-protection -fcf-protection
 -Wl,--version-script=/builddir/build/BUILD/openmp-16.0.1.src/runtime/src/exports_test_so.txt
 -shared -Wl,-soname,libfoo.so -o libfoo.so
 CMakeFiles/foo.dir/src_to_link.c.o && :
```
This has lots of opportunities for false positives: This particular case fails because it contains `error` as part of `-Werror=format-security`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVl1vo7wS_jXOzcgITJJuLnLRJuU9kdpNlWQ_zhUyZgBvjY1s023__ZEhZLfV2c-rV0IiNp5nHs88kxnunKw14posbshiO-O9b4xda_koxaww5ctaycK0XS4aFI-5kvoRbV4pXkNlTQuN950j6TVhGWFZLX3TF5EwLWGZUk_Ti3bWfEHhCcsKZQrCspZLTVhmOtRtR1hme-1li4RlouWP4X03-N0Et3eD10zxOhq-QmUsONMiWOTOaBjIORjZQWDnoHiBDm1lbCt1DRw0Oo8ljABFL1UJhL0jLJmeFXBdjlDBwjcIpvdd78FU4BvuR6sITo100CLXbtz-7qR0oI1_ZYcTLWHaluuSsA0UvR9NTQXTfbXUX3j4GC6Hz7ztFIbAxlsSX5NlfH6G5abhukbYSns5ASG2gV8p7fSTsOzmw-5uewk0TZZRHCWRsyLEHMuGe6qk7p_pZLC554-YSYVuWpyGBIVLDHk_K-Fud7O_f8j_c_3xNv94ezju9u_z4-awezjl2d31PxcKI7lDr-FmiPlmisI7R9hqVE7vBsqDIoYwjGyAPgFhS8KWQBY3CWEZI4stvDEQiuv67IZuK2Py288P-8PpCHTPgFbKG5JufSM10AqfBXZeGu2A1kBri8LYktZCUPdVetGgA9rJDifAT1wpoJ_QWmNJug1y4p46FL2V_gXop46wDf2QZ_vDaZf9Nz_uPxw2t2Fv-3Yv3aYX1G488c_d7mbz-XN-fTzeHk67_fsjU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