Skip to content

Conversation

@MaskRay
Copy link
Member

@MaskRay MaskRay commented Jan 1, 2025

GCC 9 changed the gcov format to set current_working_directory to be
used by gcov --json-format
(linux-test-project/lcov#38).

This change breaks local determinism, which we value more than strict
GCC compatibility. Just write "." to appease GCC's gcov.

Fix #121368

Created using spr 1.3.5-bogner
@MaskRay
Copy link
Member Author

MaskRay commented Jan 1, 2025

@PikachuHyA

@llvmbot
Copy link
Member

llvmbot commented Jan 1, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Fangrui Song (MaskRay)

Changes

GCC 9 changed the gcov format to set current_working_directory to be
used by gcov --json-format
(linux-test-project/lcov#38).

This change breaks local determinism, which we value more than strict
GCC compatibility. Just write "." to appease GCC's gcov.

Fix #121368


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+3-1)
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index f9be7f933d31e4..dc3307a212817a 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -973,8 +973,10 @@ bool GCOVProfiler::emitProfileNotes(
         out.write(Tmp, 4);
       }
       write(Stamp);
+      // getcwd() breaks local determinism and is not easy to adjust with
+      // -ffile-prefix-map. Just write "." to appease GCC's gcov.
       if (Version >= 90)
-        writeString(""); // unuseful current_working_directory
+        writeString(".");
       if (Version >= 80)
         write(0); // unuseful has_unexecuted_blocks
 

@MaskRay
Copy link
Member Author

MaskRay commented Jan 3, 2025

Abandoned. It has been almost 5 years that llvm-cov supports the gcov format used b GCC 9~11. Just bumped Clang's producer format from 4.8 to 11 (9) and folded this change.

@MaskRay MaskRay closed this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gcov] source file location error due to miss current_working_directory in gcno file

3 participants