[clang] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 23 12:45:14 PDT 2023
================
@@ -153,6 +153,67 @@ Please run this, then file a bug with the instructions and reduced .bc file
that bugpoint emits. If something goes wrong with bugpoint, please submit
the "foo.bc" file and the option that llc crashes with.
+LTO bugs
+---------------------------
+
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
+
+.. code-block:: bash
+
+ export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+These flags enable LTO and save temporary files generated during compilation
+for later analysis.
+
+On Windows, you should use lld-link as the linker. Adjust your compilation
+flags as follows:
+
+.. code-block:: bash
+
+ export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" LDFLAGS="-Wl,-plugin-opt=save-temps"
----------------
mizvekov wrote:
Well, I never mind the bash syntax, as that could be justified as exposition only.
And really all combinations are possible here, as bash is available on windows, powershell is available on linux, and clang-cl can be used from a linux host as well.
Roughly, however you choose to expose this, these are the options the user needs to pass:
* The user needs to be using lld-link obviously.
* On simple cases where the linker is being called from the compiler driver, as is the norm on GCC-based compiler drivers, we would already be expecting the user to be passing `-fuse-ld=lld-link`, the flag is spelled the same there.
* However, unlike on GCC world, on MSVC it's normal / expected that the user will be calling the linker directly.
* The linker flag that performs save-temps is `/lldsavetemps` as I explained earlier.
* Forwarding linker options from the clang-cl driver needs `/link`, like so: `/link /lldsavetemps`.
https://github.com/llvm/llvm-project/pull/68389
More information about the cfe-commits
mailing list