Backed out 7 changesets (bug 1326486) for causing bpgo failures.

CLOSED TREE

Backed out changeset 810a84a18948 (bug 1326486)
Backed out changeset e04c57ed0c04 (bug 1326486)
Backed out changeset 493c338ad705 (bug 1326486)
Backed out changeset 96701b9815c2 (bug 1326486)
Backed out changeset 8adfc59eb3c5 (bug 1326486)
Backed out changeset 441282fd1fea (bug 1326486)
Backed out changeset a64593d4c645 (bug 1326486)
This commit is contained in:
Mihai Alexandru Michis 2020-04-07 17:08:08 +03:00
parent 2e69b21372
commit 964773e27c
9 changed files with 19 additions and 194 deletions

View File

@ -28,7 +28,7 @@ Config file format
build-clang.py accepts a JSON config format with the following fields:
* stages: Use 1, 2, 3 or 4 to select different compiler stages. The default is 3.
* stages: Use 1, 2, or 3 to select different compiler stages. The default is 3.
* python_path: Path to the Python 2.7 installation on the machine building clang.
* gcc_dir: Path to the gcc toolchain installation, only required on Linux.
* cc: Path to the bootsraping C Compiler.
@ -44,7 +44,6 @@ build-clang.py accepts a JSON config format with the following fields:
* build_clang_tidy: Whether to build clang-tidy with the Mozilla checks imported. The default is false.
* osx_cross_compile: Whether to invoke CMake for OS X cross compile builds.
* assertions: Whether to enable LLVM assertions. The default is false.
* pgo: Whether to build with PGO (requires stages == 4). The default is false.
The revisions are defined in taskcluster/ci/fetch/toolchains.yml. They are usually commit sha1s corresponding to upstream tags.

View File

@ -231,7 +231,7 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
compiler_rt_source_dir=None, runtimes_source_link=None,
compiler_rt_source_link=None,
is_final_stage=False, android_targets=None,
extra_targets=None, pgo_phase=None):
extra_targets=None):
if is_final_stage and (android_targets or extra_targets):
# Linking compiler-rt under "runtimes" activates LLVM_RUNTIME_TARGETS
# and related arguments.
@ -252,7 +252,6 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
return path.replace('\\', '/')
def cmake_base_args(cc, cxx, asm, ld, ar, ranlib, libtool, inst_dir):
machine_targets = "X86;ARM;AArch64" if is_final_stage else "X86"
cmake_args = [
"-GNinja",
"-DCMAKE_C_COMPILER=%s" % slashify_path(cc[0]),
@ -267,14 +266,12 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
"-DCMAKE_SHARED_LINKER_FLAGS=%s" % ' '.join(ld[1:]),
"-DCMAKE_BUILD_TYPE=%s" % build_type,
"-DCMAKE_INSTALL_PREFIX=%s" % inst_dir,
"-DLLVM_TARGETS_TO_BUILD=%s" % machine_targets,
"-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64",
"-DLLVM_ENABLE_ASSERTIONS=%s" % ("ON" if assertions else "OFF"),
"-DPYTHON_EXECUTABLE=%s" % slashify_path(python_path),
"-DLLVM_TOOL_LIBCXX_BUILD=%s" % ("ON" if build_libcxx else "OFF"),
"-DLLVM_ENABLE_BINDINGS=OFF",
]
if not is_final_stage:
cmake_args += ["-DLLVM_ENABLE_PROJECTS=clang;compiler-rt"]
if build_wasm:
cmake_args += ["-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"]
if is_linux():
@ -309,16 +306,6 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
"-DDARWIN_osx_SYSROOT=%s" % slashify_path(os.getenv("CROSS_SYSROOT")),
"-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin"
]
if pgo_phase == "gen":
# Per https://releases.llvm.org/10.0.0/docs/HowToBuildWithPGO.html
cmake_args += [
"-DLLVM_BUILD_INSTRUMENTED=IR",
"-DLLVM_BUILD_RUNTIME=No",
]
if pgo_phase == "use":
cmake_args += [
"-DLLVM_PROFDATA_FILE=%s/merged.profdata" % stage_dir,
]
return cmake_args
cmake_args = []
@ -438,9 +425,8 @@ def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
]
build_package(compiler_rt_build_dir, cmake_args)
os.environ['LIB'] = old_lib
if is_final_stage:
install_import_library(build_dir, inst_dir)
install_asan_symbols(build_dir, inst_dir)
install_import_library(build_dir, inst_dir)
install_asan_symbols(build_dir, inst_dir)
# Return the absolute path of a build tool. We first look to see if the
@ -514,8 +500,7 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
# Remove the target-specific files.
if is_linux():
if os.path.exists(os.path.join(final_dir, "x86_64-unknown-linux-gnu")):
shutil.rmtree(os.path.join(final_dir, "x86_64-unknown-linux-gnu"))
shutil.rmtree(os.path.join(final_dir, "x86_64-unknown-linux-gnu"))
# In lib/, only keep lib/clang/N.M.O/include and the LLVM shared library.
re_ver_num = re.compile(r"^\d+\.\d+\.\d+$", re.I)
@ -536,7 +521,7 @@ def prune_final_dir_for_clang_tidy(final_dir, osx_cross_compile):
if os.path.basename(f) != "include":
delete(f)
# Completely remove libexec/, msbuild-bin and tools, if it exists.
# Completely remove libexec/, msbuilld-bin and tools, if it exists.
shutil.rmtree(os.path.join(final_dir, "libexec"))
for d in ("msbuild-bin", "tools"):
d = os.path.join(final_dir, d)
@ -607,15 +592,8 @@ if __name__ == "__main__":
stages = 3
if "stages" in config:
stages = int(config["stages"])
if stages not in (1, 2, 3, 4):
raise ValueError("We only know how to build 1, 2, 3, or 4 stages.")
pgo = False
if "pgo" in config:
pgo = config["pgo"]
if pgo not in (True, False):
raise ValueError("Only boolean values are accepted for pgo.")
if pgo and stages != 4:
raise ValueError("PGO is only supported in 4-stage builds.")
if stages not in (1, 2, 3):
raise ValueError("We only know how to build 1, 2, or 3 stages")
build_type = "Release"
if "build_type" in config:
build_type = config["build_type"]
@ -802,17 +780,15 @@ if __name__ == "__main__":
[ld] + extra_ldflags,
ar, ranlib, libtool,
llvm_source_dir, stage1_dir, package_name, build_libcxx, osx_cross_compile,
build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm,
is_final_stage=(stages == 1))
build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm)
runtimes_source_link = llvm_source_dir + "/runtimes/compiler-rt"
if stages >= 2:
if stages > 1:
stage2_dir = build_dir + '/stage2'
stage2_inst_dir = stage2_dir + '/' + package_name
final_stage_dir = stage2_dir
final_inst_dir = stage2_inst_dir
pgo_phase = "gen" if pgo else None
build_one_stage(
[stage1_inst_dir + "/bin/%s%s" %
(cc_name, exe_ext)] + extra_cflags2,
@ -826,9 +802,9 @@ if __name__ == "__main__":
build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm,
compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link,
is_final_stage=(stages == 2), android_targets=android_targets,
extra_targets=extra_targets, pgo_phase=pgo_phase)
extra_targets=extra_targets)
if stages >= 3:
if stages > 2:
stage3_dir = build_dir + '/stage3'
stage3_inst_dir = stage3_dir + '/' + package_name
final_stage_dir = stage3_dir
@ -847,35 +823,6 @@ if __name__ == "__main__":
compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link,
(stages == 3), extra_targets=extra_targets)
if stages >= 4:
stage4_dir = build_dir + '/stage4'
stage4_inst_dir = stage4_dir + '/' + package_name
final_stage_dir = stage4_dir
final_inst_dir = stage4_inst_dir
pgo_phase = None
if pgo:
pgo_phase = "use"
llvm_profdata = stage3_inst_dir + "/bin/llvm-profdata%s" % exe_ext
merge_cmd = [llvm_profdata, 'merge', '-o', 'merged.profdata']
profraw_files = glob.glob(os.path.join(stage2_dir, 'build',
'profiles', '*.profraw'))
if not os.path.exists(stage4_dir):
os.mkdir(stage4_dir)
run_in(stage4_dir, merge_cmd + profraw_files)
build_one_stage(
[stage3_inst_dir + "/bin/%s%s" %
(cc_name, exe_ext)] + extra_cflags2,
[stage3_inst_dir + "/bin/%s%s" %
(cxx_name, exe_ext)] + extra_cxxflags2,
[stage3_inst_dir + "/bin/%s%s" %
(cc_name, exe_ext)] + extra_asmflags,
[ld] + extra_ldflags,
ar, ranlib, libtool,
llvm_source_dir, stage4_dir, package_name, build_libcxx, osx_cross_compile,
build_type, assertions, python_path, gcc_dir, libcxx_include_dir, build_wasm,
compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link,
(stages == 4), extra_targets=extra_targets, pgo_phase=pgo_phase)
if build_clang_tidy:
prune_final_dir_for_clang_tidy(os.path.join(final_stage_dir, package_name),
osx_cross_compile)

View File

@ -1,6 +1,5 @@
{
"stages": "4",
"pgo" : true,
"stages": "3",
"build_libcxx": true,
"build_type": "Release",
"assertions": false,

View File

@ -1,6 +1,5 @@
{
"stages": "4",
"pgo" : true,
"stages": "3",
"build_libcxx": true,
"build_type": "Release",
"assertions": false,

View File

@ -1,6 +1,5 @@
{
"stages": "4",
"pgo" : true,
"stages": "3",
"build_libcxx": true,
"build_wasm": true,
"build_type": "Release",

View File

@ -1,6 +1,5 @@
{
"stages": "4",
"pgo" : true,
"stages": "3",
"build_libcxx": true,
"build_wasm": true,
"build_type": "Release",

View File

@ -1,6 +1,5 @@
{
"stages": "4",
"pgo" : true,
"stages": "3",
"build_libcxx": false,
"build_type": "Release",
"assertions": false,
@ -12,7 +11,6 @@
"unpoison-thread-stacks.patch",
"downgrade-mangling-error.patch",
"rG7e18aeba5062.patch",
"llvmorg-10-init-5191-ga84b200e604-windows-pgo.patch",
"loosen-msvc-detection.patch"
]
}

View File

@ -1,115 +0,0 @@
[cmake] Changes to get Windows self-host working with PGO
Fixes quoting of profile arguments to work on Windows
Suppresses adding profile arguments to linker flags when using lld-link
Avoids -fprofile-instr-use being added to rc.exe flags
Removes duplicated adding of -fprofile-instr-use to linker flags (since
r355541)
Move handling LLVM_PROFDATA_FILE to HandleLLVMOptions.cmake
Differential Revision: https://reviews.llvm.org/D62063
llvm-svn: 372209
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index b9a10685b99..73f8664cdcf 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -612,6 +612,9 @@ mark_as_advanced(LLVM_TARGET_TRIPLE_ENV)
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR OFF CACHE BOOL
"Enable per-target runtimes directory")
+set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
+ "Profiling data file to use when compiling in order to improve runtime performance.")
+
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
@@ -873,17 +876,6 @@ endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# use export_executable_symbols(target).
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
-set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
- "Profiling data file to use when compiling in order to improve runtime performance.")
-
-if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
- if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
- add_definitions("-fprofile-instr-use=${LLVM_PROFDATA_FILE}")
- else()
- message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang")
- endif()
-endif()
-
include(AddLLVM)
include(TableGen)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 4425eb91a5f..2e780d56254 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -846,32 +846,48 @@ string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
if (LLVM_BUILD_INSTRUMENTED)
if (LLVM_ENABLE_IR_PGO OR uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR")
- append("-fprofile-generate='${LLVM_PROFILE_DATA_DIR}'"
+ append("-fprofile-generate=\"${LLVM_PROFILE_DATA_DIR}\""
CMAKE_CXX_FLAGS
- CMAKE_C_FLAGS
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fprofile-generate=\"${LLVM_PROFILE_DATA_DIR}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSIR")
- append("-fcs-profile-generate='${LLVM_CSPROFILE_DATA_DIR}'"
+ append("-fcs-profile-generate=\"${LLVM_CSPROFILE_DATA_DIR}\""
CMAKE_CXX_FLAGS
- CMAKE_C_FLAGS
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fcs-profile-generate=\"${LLVM_CSPROFILE_DATA_DIR}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
else()
- append("-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"
+ append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
CMAKE_CXX_FLAGS
- CMAKE_C_FLAGS
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
endif()
endif()
-# Need to pass -fprofile-instr-use to linker for context-sensitive PGO
-# compilation.
if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
- append("-fprofile-instr-use='${LLVM_PROFDATA_FILE}'"
- CMAKE_EXE_LINKER_FLAGS
- CMAKE_SHARED_LINKER_FLAGS)
+ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+ append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
+ CMAKE_CXX_FLAGS
+ CMAKE_C_FLAGS)
+ if(NOT LINKER_IS_LLD_LINK)
+ append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
+ CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS)
+ endif()
+ else()
+ message(FATAL_ERROR "LLVM_PROFDATA_FILE can only be specified when compiling with clang")
+ endif()
endif()
option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)

View File

@ -22,7 +22,7 @@ else
fi
TOOLCHAIN_DIR=$MOZ_FETCHES_DIR/llvm-project
INSTALL_DIR=$TOOLCHAIN_DIR/build/stage4/clang
INSTALL_DIR=$TOOLCHAIN_DIR/build/stage3/clang
CROSS_PREFIX_DIR=$INSTALL_DIR/$machine-w64-mingw32
make_flags="-j$(nproc)"