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

    <tr>
        <th>Summary</th>
        <td>
            Confusion regarding ThinLTO for CFI checks
        </td>
    </tr>

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

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

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

<pre>
    Hi, I am enabling CFI for our project. I was testing it over the last few days, by passing the relevant CFI schemes along with the LTO flags `-flto=thin -fsplit-lto-unit` directly at the compiler level (`clang-15`). The project compiled fine, and I could see a bump in the link time, expectedly so due to the linker running its optimization pipeline. 

But now I suddenly realise, that we have a separate linker flag set in the CMake file. We use `ld.lld-*` for linking, and I am now wondering if I should also pass  `-flto=thin -fsplit-lto-unit` to the linker to enable CFI accurately. 

**Note**- We statically link all our libraries except for the obvious ones (e.g. `libstdc++`) 

I checked your [latest](https://clang.llvm.org/docs/ThinLTO.html#linkers) doc. and there was no mention about this, so I am really confused now whether CFI is actually enabled or not?

Nevertheless, I tested by passing the LTO flags to linker, and ran into an expected error due to using `objcopy` in a child CMake for renaming some symbol conflicts in static library file. I updated that to `llvm-objcopy-15` hoping it'd work,  but surprisingly, it does not work on LLVM IR bitcode files (compiled with LTO). 

Please help me to understand how to approach here with proper CFI enablement.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVU1v4zgP_jXKhYjhKHXSHnLoB4I3QGfmxaLYPcsSE2tKi4ZEJ-P99QvJSTvd0wJFW9gUyedLNin5U0DcqeZJNS8LM0rHcWfazicM20XLbtr9zyv9DAcwPWAwLflwguf9AY4cgccIQ-SfaKWCA1xMAsEkucQL8BkjSIdAJgkc8QLOTCl3aycY8vBwKu8jEp5NkNI32Q57TGCIwwkuXrpS8_r2A45kTgnUpl4eSVitX6TzAZbHNJCXJQkvx-BFbWpwPqI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