Skip to content
Permalink
Browse files
Allow build-and-collect-pgo-profiles to write files
https://bugs.webkit.org/show_bug.cgi?id=241692
<rdar://95311491>

Patch by Brianna Fan <briannaf@berkeley.edu> on 2022-06-21
Reviewed by Dewei Zhu.

Ran into a missing profiles issue as required permissions to write were missing.
Fixed this issue by moving a code block in GenerateProfiles.h.

* Source/WTF/wtf/GenerateProfiles.h:
(WTF::registerProfileGenerationCallback):

Canonical link: https://commits.webkit.org/251703@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
briannafan authored and webkit-commit-queue committed Jun 21, 2022
1 parent 43784de commit b91d6ad
Showing 1 changed file with 9 additions and 8 deletions.
@@ -59,18 +59,19 @@ ALWAYS_INLINE void registerProfileGenerationCallback(const char* name)
"`.");
WTFLogAlways("<WEBKIT_LLVM_PROFILE> To sanity-check the output: `for f in ./profiles/*; do echo $f; xcrun -sdk macosx.internal llvm-profdata show $f; done;`.");

{
// Maybe we could use %t instead here, but this folder is permitted through the sandbox because of ANGLE.
FileSystem::PlatformFileHandle fileHandle;
auto filePath = FileSystem::openTemporaryFile(makeString(name, "-", getpid()), fileHandle, ".profraw"_s);
profileFileBase.get() = String::fromUTF8(filePath.utf8().data());
FileSystem::closeFile(fileHandle);
}

WTFLogAlways("<WEBKIT_LLVM_PROFILE><%s><%d>: We will dump the resulting profile to %s.", name, pid, profileFileBase->utf8().data());

int token;
notify_register_dispatch("com.apple.WebKit.profiledata", &token, dispatch_get_main_queue(), ^(int) {

{
// Maybe we could use %t instead here, but this folder is permitted through the sandbox because of ANGLE.
FileSystem::PlatformFileHandle fileHandle;
auto filePath = FileSystem::openTemporaryFile(makeString(name, "-", getpid()), fileHandle, ".profraw"_s);
profileFileBase.get() = String::fromUTF8(filePath.utf8().data());
FileSystem::closeFile(fileHandle);
}

profileFileName.get() = makeString(profileFileBase.get(), ".", profileCount++, ".profraw");
__llvm_profile_set_filename(profileFileName->utf8().data()); // Must stay alive while it is used by llvm.

0 comments on commit b91d6ad

Please sign in to comment.