Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ usual build cycle when using sample profilers for optimization:

> clang-cl /O2 -gdwarf -gline-tables-only ^
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf
code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf

.. note::

Expand Down Expand Up @@ -2861,21 +2861,23 @@ usual build cycle when using sample profilers for optimization:
that executes faster than the original one. Note that you are not
required to build the code with the exact same arguments that you
used in the first step. The only requirement is that you build the code
with the same debug info options and ``-fprofile-sample-use``.
with the same debug info options and ``-fprofile-sample-use``. ``-gdwarf``
and ``-gline-tables-only`` can be omitted if you do not need debug info
in the final binary.

On Linux:

.. code-block:: console

$ clang++ -O2 -gline-tables-only \
$ clang++ -O2 \
-fdebug-info-for-profiling -funique-internal-linkage-names \
-fprofile-sample-use=code.prof code.cc -o code

On Windows:

.. code-block:: winbatch

> clang-cl /O2 -gdwarf -gline-tables-only ^
> clang-cl /O2 ^
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't want DWARF in the binary can we also emit some of the link options like -fuse-ld=lld and /link /debug:dwarf?

Copy link
Contributor Author

@HaohaiWen HaohaiWen Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.


Expand All @@ -2886,15 +2888,15 @@ usual build cycle when using sample profilers for optimization:

.. code-block:: console

$ clang++ -fsample-profile-use-profi -O2 -gline-tables-only \
$ clang++ -fsample-profile-use-profi -O2 \
-fdebug-info-for-profiling -funique-internal-linkage-names \
-fprofile-sample-use=code.prof code.cc -o code

On Windows:

.. code-block:: winbatch

> clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf -gline-tables-only ^
> clang-cl /clang:-fsample-profile-use-profi /O2 ^
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf

Expand Down
Loading