-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fuchsia] Support PGO #128680
Open
petrhosek
wants to merge
2
commits into
llvm:main
Choose a base branch
from
petrhosek:fuchsia-pgo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Fuchsia] Support PGO #128680
+120
−31
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enable 2-stage builds with PGO.
@llvm/pr-subscribers-clang Author: Petr Hosek (petrhosek) ChangesEnable 2-stage builds with PGO. Full diff: https://github.com/llvm/llvm-project/pull/128680.diff 2 Files Affected:
diff --git a/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake
new file mode 100644
index 0000000000000..b3c3b63066363
--- /dev/null
+++ b/clang/cmake/caches/Fuchsia-stage2-instrumented.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build.
+
+include(${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake)
+
+if(NOT APPLE)
+ set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+ check-all
+ check-clang
+ check-lld
+ check-llvm
+ clang
+ clang-test-depends
+ toolchain-distribution
+ install-toolchain-distribution
+ install-toolchain-distribution-stripped
+ install-toolchain-distribution-toolchain
+ lld-test-depends
+ llvm-config
+ llvm-test-depends
+ test-depends
+ test-suite CACHE STRING "")
+
+get_cmake_property(variableNames VARIABLES)
+foreach(variableName ${variableNames})
+ if(variableName MATCHES "^STAGE2_")
+ string(REPLACE "STAGE2_" "" new_name ${variableName})
+ list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
+ endif()
+endforeach()
+
+set(CLANG_PGO_TRAINING_DEPS
+ builtins
+ runtimes
+ CACHE STRING "")
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+ ${EXTRA_ARGS}
+ -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+ CACHE STRING "")
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 83336589da305..4a46157d050a0 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -126,6 +126,16 @@ else()
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
set(LIBCXX_HARDENING_MODE "none" CACHE STRING "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+ set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+ set(COMPILER_RT_BUILD_PROFILE ON CACHE BOOL "")
+ set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+ set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
+ set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+ set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+ set(SANITIZER_CXX_ABI "libc++" CACHE STRING "")
+ set(SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
+ set(SANITIZER_TEST_CXX "libc++" CACHE STRING "")
+ set(SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
endif()
@@ -165,33 +175,57 @@ endif()
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-set(_FUCHSIA_BOOTSTRAP_TARGETS
- check-all
- check-clang
- check-lld
- check-llvm
- check-polly
- llvm-config
- clang-test-depends
- lld-test-depends
- llvm-test-depends
- test-suite
- test-depends
- toolchain-distribution
- install-toolchain-distribution
- install-toolchain-distribution-stripped
- install-toolchain-distribution-toolchain
- clang)
-
-if(FUCHSIA_ENABLE_LLDB)
- list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
- list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
- check-lldb
- lldb-test-depends
- debugger-distribution
- install-debugger-distribution
- install-debugger-distribution-stripped
- install-debugger-distribution-toolchain)
+if(FUCHSIA_ENABLE_PGO)
+ set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
+
+ set(_FUCHSIA_BOOTSTRAP_TARGETS
+ generate-profdata
+ stage2
+ stage2-toolchain-distribution
+ stage2-install-toolchain-distribution
+ stage2-install-toolchain-distribution-stripped
+ stage2-install-toolchain-distribution-toolchain
+ stage2-check-all
+ stage2-check-lld
+ stage2-check-llvm
+ stage2-check-clang
+ stage2-test-suite)
+ if(FUCHSIA_ENABLE_LLDB)
+ list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
+ list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
+ stage2-check-lldb
+ stage2-debugger-distribution
+ stage2-install-debugger-distribution
+ stage2-install-debugger-distribution-stripped
+ stage2-install-debugger-distribution-toolchain)
+ endif()
+else()
+ set(_FUCHSIA_BOOTSTRAP_TARGETS
+ check-all
+ check-clang
+ check-lld
+ check-llvm
+ llvm-config
+ clang
+ clang-test-depends
+ lld-test-depends
+ llvm-test-depends
+ test-suite
+ test-depends
+ toolchain-distribution
+ install-toolchain-distribution
+ install-toolchain-distribution-stripped
+ install-toolchain-distribution-toolchain)
+ if(FUCHSIA_ENABLE_LLDB)
+ list(APPEND _FUCHSIA_ENABLE_PROJECTS lldb)
+ list(APPEND _FUCHSIA_BOOTSTRAP_TARGETS
+ check-lldb
+ lldb-test-depends
+ debugger-distribution
+ install-debugger-distribution
+ install-debugger-distribution-stripped
+ install-debugger-distribution-toolchain)
+ endif()
endif()
set(LLVM_ENABLE_PROJECTS ${_FUCHSIA_ENABLE_PROJECTS} CACHE STRING "")
@@ -200,6 +234,7 @@ set(CLANG_BOOTSTRAP_TARGETS ${_FUCHSIA_BOOTSTRAP_TARGETS} CACHE STRING "")
get_cmake_property(variableNames VARIABLES)
foreach(variableName ${variableNames})
if(variableName MATCHES "^STAGE2_")
+ list(APPEND EXTRA_ARGS "-D${variableName}=${${variableName}}")
string(REPLACE "STAGE2_" "" new_name ${variableName})
string(REPLACE ";" "|" value "${${variableName}}")
list(APPEND EXTRA_ARGS "-D${new_name}=${value}")
@@ -209,13 +244,23 @@ endforeach()
# TODO: This is a temporary workaround until we figure out the right solution.
set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "default" CACHE STRING "")
+set(LLVM_RUNTIME_TARGETS "default" CACHE STRING "")
+
# Setup the bootstrap build.
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
set(CLANG_BOOTSTRAP_EXTRA_DEPS
builtins
runtimes
CACHE STRING "")
-set(CLANG_BOOTSTRAP_CMAKE_ARGS
- ${EXTRA_ARGS}
- -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
- CACHE STRING "")
+if(FUCHSIA_ENABLE_PGO)
+ set(CLANG_BOOTSTRAP_CMAKE_ARGS
+ ${EXTRA_ARGS}
+ -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2-instrumented.cmake
+ CACHE STRING "")
+else()
+ set(CLANG_BOOTSTRAP_CMAKE_ARGS
+ ${EXTRA_ARGS}
+ -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+ CACHE STRING "")
+endif()
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enable 2-stage builds with PGO.