Skip to content
Permalink
Browse files
[Xcode] Compute PGO profdata paths instead of searching for them at b…
…uild time

https://bugs.webkit.org/show_bug.cgi?id=239681

Reviewed by Alexey Proskuryakov.

Production builds should always use profdata from the SDK, internal
release builds should use profdata from the local WebKitAdditions, and
everyone else should use the stub profdata. Add a PROFILE_DATA_PATH
build setting which implements these rules and replace the script
phases that checked those paths dynamically.

This fixes XCBuild validation issues in the open-source build, and
should prevent production builders from using stale profdata in
BUILT_PRODUCTS_DIR. Additionally, engineers can now build with custom
profile data by overriding PROFILE_DATA_PATH.

If PROFILE_DATA_PATH does not appear to be raw LLVM profiling data, it
is decoded using compression_tool(1).

* Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/WebKit/Configurations/BaseTarget.xcconfig:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebCore/Configurations/WebCore.xcconfig:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/249997@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293442 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
emw-apple committed Apr 26, 2022
1 parent 36cd10b commit 433f73bc052d7c978c619e28b2574df8faf6cb72
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 12 deletions.
@@ -1,3 +1,27 @@
2022-04-22 Elliott Williams <emw@apple.com>

[Xcode] Compute PGO profdata paths instead of searching for them at build time
https://bugs.webkit.org/show_bug.cgi?id=239681

Reviewed by Alexey Proskuryakov.

Production builds should always use profdata from the SDK, internal
release builds should use profdata from the local WebKitAdditions, and
everyone else should use the stub profdata. Add a PROFILE_DATA_PATH
build setting which implements these rules and replace the script
phases that checked those paths dynamically.

This fixes XCBuild validation issues in the open-source build, and
should prevent production builders from using stale profdata in
BUILT_PRODUCTS_DIR. Additionally, engineers can now build with custom
profile data by overriding PROFILE_DATA_PATH.

If PROFILE_DATA_PATH does not appear to be raw LLVM profiling data, it
is decoded using compression_tool(1).

* Configurations/JavaScriptCore.xcconfig:
* JavaScriptCore.xcodeproj/project.pbxproj:

2022-04-25 Keith Miller <keith_miller@apple.com>

structureIDToStructureWithScratch should only do things if ADDRESS64
@@ -40,6 +40,12 @@ SECTORDER_FLAGS = $(SECTORDER_FLAGS_$(CONFIGURATION));
SECTORDER_FLAGS_Production[sdk=iphoneos*] = -Wl,-order_file,$(SDKROOT)/AppleInternal/OrderFiles/JavaScriptCore.order;
SECTORDER_FLAGS_Production[sdk=macosx*] = -Wl,-order_file,JavaScriptCore.order;

PROFILE_DATA_PATH = $(PROFILE_DATA_PATH_PRODUCTION_$(DEPLOYMENT_LOCATION));
PROFILE_DATA_PATH_PRODUCTION_YES = $(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/JavaScriptCore.profdata.compressed;
PROFILE_DATA_PATH_PRODUCTION_NO = $(PROFILE_DATA_PATH_INTERNAL_$(USE_INTERNAL_SDK));
PROFILE_DATA_PATH_INTERNAL_YES = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/JavaScriptCore.profdata.compressed;
PROFILE_DATA_PATH_INTERNAL_ = $(SRCROOT)/../../Tools/Profiling/Empty.profdata.compressed;

PROFILE_DATA_FLAGS_ENABLED = -fprofile-instr-use=$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/JavaScriptCore.profdata;

PROFILE_DATA_FLAGS = $(PROFILE_DATA_FLAGS_$(CONFIGURATION)_$(WK_PLATFORM_NAME));
@@ -12111,9 +12111,7 @@
inputFileListPaths = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/JavaScriptCore.profdata.compressed",
"$(SRCROOT)/../../Tools/Profiling/Empty.profdata",
"$(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/JavaScriptCore.profdata.compressed",
"$(PROFILE_DATA_PATH)",
);
name = "Copy Profiling Data";
outputFileListPaths = (
@@ -12123,7 +12121,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nRELATIVE_PROFILE_DATA_PATH=\"usr/local/include/WebKitAdditions/Profiling/JavaScriptCore.profdata.compressed\";\nABSOLUTE_PROFILE_DATA_PATH=\"${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ]; then\n ABSOLUTE_PROFILE_DATA_PATH=\"${SDK_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\nfi\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ] || [ $(wc -c <${ABSOLUTE_PROFILE_DATA_PATH}) -lt 4096 ]; then\n if [ \"${CONFIGURATION}\" = \"Production\" ]; then\n echo \"Error: production build missing profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n exit 1;\n fi\n echo \"Missing or invalid profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH} - falling back to empty file\";\n cp ${SRCROOT}/../../Tools/Profiling/Empty.profdata ${BUILT_PRODUCTS_DIR}/DerivedSources/JavaScriptCore/JavaScriptCore.profdata;\nelse\n echo \"Copying profiling data at ${ABSOLUTE_PROFILE_DATA_PATH}\";\n compression_tool -decode -i ${ABSOLUTE_PROFILE_DATA_PATH} -o ${BUILT_PRODUCTS_DIR}/DerivedSources/JavaScriptCore/JavaScriptCore.profdata -a lzfse;\nfi\n";
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nif [[ \"$(file -b \"${SCRIPT_INPUT_FILE_0}\")\" = \"lzfse compressed\"* ]]; then\n set -x; compression_tool -decode -i \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\" -a lzfse;\nelse\n set -x; cp \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

@@ -1,3 +1,13 @@
2022-04-22 Elliott Williams <emw@apple.com>

[Xcode] Compute PGO profdata paths instead of searching for them at build time
https://bugs.webkit.org/show_bug.cgi?id=239681

Reviewed by Alexey Proskuryakov.

* Configurations/WebCore.xcconfig:
* WebCore.xcodeproj/project.pbxproj:

2022-04-26 Xi Ruoyao <xry111@mengyan1223.wang>

[GTK] Initialize m_eglDisplay in PlatformDisplay::PlatformDisplay(GdkDisplay*)
@@ -29,6 +29,12 @@
GCC_PREFIX_HEADER = WebCorePrefix.h;
GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) BUILDING_WEBKIT GL_SILENCE_DEPRECATION=1 GLES_SILENCE_DEPRECATION=1 $(inherited);

PROFILE_DATA_PATH = $(PROFILE_DATA_PATH_PRODUCTION_$(DEPLOYMENT_LOCATION));
PROFILE_DATA_PATH_PRODUCTION_YES = $(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/WebCore.profdata.compressed;
PROFILE_DATA_PATH_PRODUCTION_NO = $(PROFILE_DATA_PATH_INTERNAL_$(USE_INTERNAL_SDK));
PROFILE_DATA_PATH_INTERNAL_YES = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/WebCore.profdata.compressed;
PROFILE_DATA_PATH_INTERNAL_ = $(SRCROOT)/../../Tools/Profiling/Empty.profdata.compressed;

PROFILE_DATA_FLAGS_ENABLED = -fprofile-instr-use=$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/WebCore.profdata;

PROFILE_DATA_FLAGS = $(PROFILE_DATA_FLAGS_$(CONFIGURATION)_$(WK_PLATFORM_NAME));
@@ -38881,9 +38881,7 @@
inputFileListPaths = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/WebCore.profdata.compressed",
"$(SRCROOT)/../../Tools/Profiling/Empty.profdata",
"$(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/WebCore.profdata.compressed",
"$(PROFILE_DATA_PATH)",
);
name = "Copy Profiling Data";
outputFileListPaths = (
@@ -38893,7 +38891,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nRELATIVE_PROFILE_DATA_PATH=\"usr/local/include/WebKitAdditions/Profiling/WebCore.profdata.compressed\";\nABSOLUTE_PROFILE_DATA_PATH=\"${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ]; then\n ABSOLUTE_PROFILE_DATA_PATH=\"${SDK_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\nfi\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ] || [ $(wc -c <${ABSOLUTE_PROFILE_DATA_PATH}) -lt 4096 ]; then\n if [ \"${CONFIGURATION}\" = \"Production\" ]; then\n echo \"Error: production build missing profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n exit 1;\n fi\n echo \"Missing or invalid profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH} - falling back to empty file\";\n cp ${SRCROOT}/../../Tools/Profiling/Empty.profdata ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore/WebCore.profdata;\nelse\n echo \"Copying profiling data at ${ABSOLUTE_PROFILE_DATA_PATH}\";\n compression_tool -decode -i ${ABSOLUTE_PROFILE_DATA_PATH} -o ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore/WebCore.profdata -a lzfse;\nfi\n";
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nif [[ \"$(file -b \"${SCRIPT_INPUT_FILE_0}\")\" = \"lzfse compressed\"* ]]; then\n set -x; compression_tool -decode -i \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\" -a lzfse;\nelse\n set -x; cp \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

@@ -1,3 +1,13 @@
2022-04-22 Elliott Williams <emw@apple.com>

[Xcode] Compute PGO profdata paths instead of searching for them at build time
https://bugs.webkit.org/show_bug.cgi?id=239681

Reviewed by Alexey Proskuryakov.

* Configurations/BaseTarget.xcconfig:
* WebKit.xcodeproj/project.pbxproj:

2022-04-26 Wenson Hsieh <wenson_hsieh@apple.com>

Adjust some image transcoding behaviors related to "Copy Cropped Image"
@@ -50,6 +50,12 @@ ALTERNATE_HEADER_SEARCH_PATHS_iosmac = $(BUILT_PRODUCTS_DIR)$(WK_ALTERNATE_FRAME

HEADER_SEARCH_PATHS = $(ALTERNATE_HEADER_SEARCH_PATHS) $(BUILT_PRODUCTS_DIR)/usr/local/include "$(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders" $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit $(WEBGPU_HEADER_SEARCH_PATHS) $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) $(LIBWEBRTC_HEADER_SEARCH_PATHS) $(SRCROOT) $(HEADER_SEARCH_PATHS);

PROFILE_DATA_PATH = $(PROFILE_DATA_PATH_PRODUCTION_$(DEPLOYMENT_LOCATION));
PROFILE_DATA_PATH_PRODUCTION_YES = $(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/WebKit.profdata.compressed;
PROFILE_DATA_PATH_PRODUCTION_NO = $(PROFILE_DATA_PATH_INTERNAL_$(USE_INTERNAL_SDK));
PROFILE_DATA_PATH_INTERNAL_YES = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/WebKit.profdata.compressed;
PROFILE_DATA_PATH_INTERNAL_ = $(SRCROOT)/../../Tools/Profiling/Empty.profdata.compressed;

PROFILE_DATA_FLAGS_ENABLED = -fprofile-instr-use=$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/WebKit.profdata;

PROFILE_DATA_FLAGS = $(PROFILE_DATA_FLAGS_$(CONFIGURATION)_$(WK_PLATFORM_NAME));
@@ -16833,9 +16833,7 @@
inputFileListPaths = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions/Profiling/WebKit.profdata.compressed",
"$(SRCROOT)/../../Tools/Profiling/Empty.profdata",
"$(SDK_DIR)/usr/local/include/WebKitAdditions/Profiling/WebKit.profdata.compressed",
"$(PROFILE_DATA_PATH)",
);
name = "Copy Profiling Data";
outputFileListPaths = (
@@ -16845,7 +16843,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nRELATIVE_PROFILE_DATA_PATH=\"usr/local/include/WebKitAdditions/Profiling/WebKit.profdata.compressed\";\nABSOLUTE_PROFILE_DATA_PATH=\"${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ]; then\n ABSOLUTE_PROFILE_DATA_PATH=\"${SDK_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\nfi\n\nif [ ! -f \"${ABSOLUTE_PROFILE_DATA_PATH}\" ] || [ $(wc -c <${ABSOLUTE_PROFILE_DATA_PATH}) -lt 4096 ]; then\n if [ \"${CONFIGURATION}\" = \"Production\" ]; then\n echo \"Error: production build missing profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH}\";\n exit 1;\n fi\n echo \"Missing or invalid profiling data at both ${ABSOLUTE_PROFILE_DATA_PATH} and ${BUILT_PRODUCTS_DIR}/${RELATIVE_PROFILE_DATA_PATH} - falling back to empty file\";\n cp ${SRCROOT}/../../Tools/Profiling/Empty.profdata ${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit/WebKit.profdata;\nelse\n echo \"Copying profiling data at ${ABSOLUTE_PROFILE_DATA_PATH}\";\n compression_tool -decode -i ${ABSOLUTE_PROFILE_DATA_PATH} -o ${BUILT_PRODUCTS_DIR}/DerivedSources/WebKit/WebKit.profdata -a lzfse;\nfi\n";
shellScript = "if [ \"${ACTION}\" = \"installhdrs\" -o \"${ACTION}\" = \"installapi\" ]; then\n exit 0;\nfi\n\nif [ -z \"${PROFILE_DATA_FLAGS}\" ]; then\n exit 0;\nfi\n\nif [[ \"$(file -b \"${SCRIPT_INPUT_FILE_0}\")\" = \"lzfse compressed\"* ]]; then\n set -x; compression_tool -decode -i \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\" -a lzfse;\nelse\n set -x; cp \"${SCRIPT_INPUT_FILE_0}\" -o \"${SCRIPT_OUTPUT_FILE_0}\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

0 comments on commit 433f73b

Please sign in to comment.