Skip to content

Conversation

HaohaiWen
Copy link
Contributor

The -fprofile-sample-use implies codegenoptions::LocTrackingOnly. No need
to explicitly specify -g if debug info is not required in final binary.

Also fix -fuse-ld=lld.

The -fprofile-sample-use implies codegenoptions::LocTrackingOnly. No need
to explicitly specify -g if debug info is not required in final binary.

Also fix -fuse-ld=lld.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2025

@llvm/pr-subscribers-clang

Author: Haohai Wen (HaohaiWen)

Changes

The -fprofile-sample-use implies codegenoptions::LocTrackingOnly. No need
to explicitly specify -g if debug info is not required in final binary.

Also fix -fuse-ld=lld.


Full diff: https://github.com/llvm/llvm-project/pull/162588.diff

1 Files Affected:

  • (modified) clang/docs/UsersManual.rst (+5-5)
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 12c2ada062625..94f517829fc24 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -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::
 
@@ -2867,7 +2867,7 @@ usual build cycle when using sample profilers for optimization:
 
    .. 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
 
@@ -2875,7 +2875,7 @@ usual build cycle when using sample profilers for optimization:
 
    .. 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
 
@@ -2886,7 +2886,7 @@ 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
 
@@ -2894,7 +2894,7 @@ usual build cycle when using sample profilers for optimization:
 
    .. 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
 

> 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.

Copy link
Contributor

@tcreech-intel tcreech-intel left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. LGTM!

@HaohaiWen HaohaiWen merged commit 0f3d0cf into llvm:main Oct 10, 2025
11 checks passed
@HaohaiWen HaohaiWen deleted the doc branch October 10, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants