Skip to content

Commit

Permalink
[gn build] Add build files for //bolt
Browse files Browse the repository at this point in the history
Adds build files for libraries, tools, and tests -- everything except
the runtime.

Doesn't hook up bolt in the main BUILD.gn file yet -- I want to verify
that it builds on Linux, macOS, Windows before doing that. (I've only
checked on macOS so far.)

`ninja check-bolt` passes on macOS with this.
(I locally bumped the deployment target to macOS 10.12 for that. bolt/ uses
std::mutex quite a bit, which requires 10.12.)

Differential Revision: https://reviews.llvm.org/D138355
  • Loading branch information
nico committed Nov 22, 2022
1 parent 1c5ad6d commit 6bb781f
Show file tree
Hide file tree
Showing 22 changed files with 514 additions and 1 deletion.
7 changes: 7 additions & 0 deletions llvm/utils/gn/build/BUILD.gn
Expand Up @@ -488,6 +488,13 @@ config("clang_code") {
]
}

config("bolt_code") {
include_dirs = [
"//bolt/include",
"$root_gen_dir/bolt/include",
]
}

config("crt_code") {
include_dirs = [ "//compiler-rt/lib" ]
cflags = [
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/gn/build/sync_source_lists_from_cmake.py
Expand Up @@ -133,7 +133,7 @@ def sync_unittests():
# Matches e.g. |add_llvm_unittest_with_input_files|.
unittest_re = re.compile(r'^add_\S+_unittest', re.MULTILINE)

checked = [ 'clang', 'clang-tools-extra', 'lld', 'llvm' ]
checked = [ 'bolt', 'clang', 'clang-tools-extra', 'lld', 'llvm' ]
changed = False
for c in checked:
for root, _, _ in os.walk(os.path.join(c, 'unittests')):
Expand Down
10 changes: 10 additions & 0 deletions llvm/utils/gn/secondary/BUILD.gn
Expand Up @@ -32,6 +32,11 @@ group("default") {
deps += [ "//libunwind" ]
}

# FIXME: Add this on linux/win after testing that it builds.
if (current_os == "mac") {
deps += [ "//bolt/test" ]
}

testonly = true
}

Expand Down Expand Up @@ -66,6 +71,11 @@ group("lld") {
group("llvm-ar") {
deps = [ "//llvm/tools/llvm-ar:symlinks" ]
}
if (current_os == "mac") {
group("llvm-bolt") {
deps = [ "//bolt/tools/driver:symlinks" ]
}
}
group("llvm-dwp") {
deps = [ "//llvm/tools/llvm-dwp:symlinks" ]
}
Expand Down
@@ -0,0 +1,7 @@
import("//llvm/utils/gn/build/write_cmake_config.gni")

write_cmake_config("RuntimeLibraryVariables") {
input = "//bolt/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in"
output = "$target_gen_dir/RuntimeLibraryVariables.inc"
values = [ "LLVM_LIBDIR_SUFFIX=" ]
}
31 changes: 31 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Core/BUILD.gn
@@ -0,0 +1,31 @@
static_library("Core") {
output_name = "LLVMBOLTCore"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Utils",
"//llvm/lib/DebugInfo/DWARF",
"//llvm/lib/Demangle",
"//llvm/lib/MC",
"//llvm/lib/MC/MCDisassembler",
"//llvm/lib/Object",
"//llvm/lib/Support",
"//llvm/utils/gn/build/libs/pthread",
]
sources = [
"BinaryBasicBlock.cpp",
"BinaryContext.cpp",
"BinaryData.cpp",
"BinaryEmitter.cpp",
"BinaryFunction.cpp",
"BinaryFunctionProfile.cpp",
"BinarySection.cpp",
"DebugData.cpp",
"DynoStats.cpp",
"Exceptions.cpp",
"FunctionLayout.cpp",
"JumpTable.cpp",
"MCPlusBuilder.cpp",
"ParallelUtilities.cpp",
"Relocation.cpp",
]
}
62 changes: 62 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Passes/BUILD.gn
@@ -0,0 +1,62 @@
static_library("Passes") {
output_name = "LLVMBOLTPasses"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Core",
"//bolt/lib/Utils",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Transforms/Utils",
"//llvm/utils/gn/build/libs/pthread",
]
sources = [
"ADRRelaxationPass.cpp",
"Aligner.cpp",
"AllocCombiner.cpp",
"AsmDump.cpp",
"BinaryFunctionCallGraph.cpp",
"BinaryPasses.cpp",
"CMOVConversion.cpp",
"CacheMetrics.cpp",
"CallGraph.cpp",
"CallGraphWalker.cpp",
"DataflowAnalysis.cpp",
"DataflowInfoManager.cpp",
"FrameAnalysis.cpp",
"FrameOptimizer.cpp",
"HFSort.cpp",
"HFSortPlus.cpp",
"Hugify.cpp",
"IdenticalCodeFolding.cpp",
"IndirectCallPromotion.cpp",
"Inliner.cpp",
"Instrumentation.cpp",
"JTFootprintReduction.cpp",
"LivenessAnalysis.cpp",
"LongJmp.cpp",
"LoopInversionPass.cpp",
"MCF.cpp",
"PLTCall.cpp",
"PatchEntries.cpp",
"PettisAndHansen.cpp",
"RegAnalysis.cpp",
"RegReAssign.cpp",
"ReorderAlgorithm.cpp",
"ReorderData.cpp",
"ReorderFunctions.cpp",
"RetpolineInsertion.cpp",
"ShrinkWrapping.cpp",
"SplitFunctions.cpp",
"StackAllocationAnalysis.cpp",
"StackAvailableExpressions.cpp",
"StackPointerTracking.cpp",
"StackReachingUses.cpp",
"StokeInfo.cpp",
"TailDuplication.cpp",
"ThreeWayBranch.cpp",
"ValidateInternalCalls.cpp",
"ValidateMemRefs.cpp",
"VeneerElimination.cpp",
]
}
19 changes: 19 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Profile/BUILD.gn
@@ -0,0 +1,19 @@
static_library("Profile") {
output_name = "LLVMBOLTProfile"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Core",
"//bolt/lib/Passes",
"//bolt/lib/Utils",
"//llvm/lib/Support",
]
sources = [
"BoltAddressTranslation.cpp",
"DataAggregator.cpp",
"DataReader.cpp",
"Heatmap.cpp",
"ProfileReaderBase.cpp",
"YAMLProfileReader.cpp",
"YAMLProfileWriter.cpp",
]
}
38 changes: 38 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Rewrite/BUILD.gn
@@ -0,0 +1,38 @@
import("//llvm/lib/Target/targets.gni")

static_library("Rewrite") {
output_name = "LLVMBOLTRewrite"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Core",
"//bolt/lib/Passes",
"//bolt/lib/Profile",
"//bolt/lib/RuntimeLibs",
"//bolt/lib/Utils",
"//llvm/lib/DWP",
"//llvm/lib/DebugInfo/DWARF",
"//llvm/lib/ExecutionEngine",
"//llvm/lib/MC",
"//llvm/lib/Object",
"//llvm/lib/Support",
"//llvm/utils/gn/build/libs/pthread",
]
sources = [
"BinaryPassManager.cpp",
"BoltDiff.cpp",
"DWARFRewriter.cpp",
"ExecutableFileMemoryManager.cpp",
"MachORewriteInstance.cpp",
"RewriteInstance.cpp",
]

defines = []
if (llvm_build_AArch64) {
defines += [ "AARCH64_AVAILABLE" ]
deps += [ "//bolt/lib/Target/AArch64" ]
}
if (llvm_build_X86) {
defines += [ "X86_AVAILABLE" ]
deps += [ "//bolt/lib/Target/X86" ]
}
}
21 changes: 21 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/RuntimeLibs/BUILD.gn
@@ -0,0 +1,21 @@
static_library("RuntimeLibs") {
output_name = "LLVMBOLTRuntimeLibs"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/include/bolt/RuntimeLibs:RuntimeLibraryVariables",
"//bolt/lib/Core",
"//bolt/lib/Passes",
"//bolt/lib/Utils",
"//llvm/lib/BinaryFormat",
"//llvm/lib/ExecutionEngine/RuntimeDyld",
"//llvm/lib/MC",
"//llvm/lib/Object",
"//llvm/lib/Support",
]
include_dirs = [ target_gen_dir ]
sources = [
"HugifyRuntimeLibrary.cpp",
"InstrumentationRuntimeLibrary.cpp",
"RuntimeLibrary.cpp",
]
}
19 changes: 19 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Target/AArch64/BUILD.gn
@@ -0,0 +1,19 @@
static_library("AArch64") {
output_name = "LLVMBOLTTargetAArch64"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Core",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target/AArch64/MCTargetDesc",
]
sources = [ "AArch64MCPlusBuilder.cpp" ]

# This target reaches into the internal headers of LLVM's AArch64 library.
# That target doesn't expect that, so it doesn't use public_deps for
# tblgen-generated headers used only in internal headers (...which this
# target here questionably includes). So depend on the target that generates
# those headers here.
include_dirs = [ "//llvm/lib/Target/AArch64" ]
deps += [ "//llvm/lib/Target/AArch64/Utils" ]
}
19 changes: 19 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Target/X86/BUILD.gn
@@ -0,0 +1,19 @@
static_library("X86") {
output_name = "LLVMBOLTTargetX86"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//bolt/lib/Core",
"//bolt/lib/Utils",
"//llvm/lib/MC",
"//llvm/lib/MC/MCDisassembler",
"//llvm/lib/Support",
"//llvm/lib/Target/X86/MCTargetDesc",
]
sources = [
"X86MCPlusBuilder.cpp",
"X86MCSymbolizer.cpp",
]

# This target reaches into the internal headers of LLVM's X86 library.
include_dirs = [ "//llvm/lib/Target/X86" ]
}
12 changes: 12 additions & 0 deletions llvm/utils/gn/secondary/bolt/lib/Utils/BUILD.gn
@@ -0,0 +1,12 @@
static_library("Utils") {
output_name = "LLVMBOLTUtils"
configs += [ "//llvm/utils/gn/build:bolt_code" ]
deps = [
"//llvm/lib/Support",
"//llvm/utils/gn/build/libs/pthread",
]
sources = [
"CommandLineOpts.cpp",
"Utils.cpp",
]
}

0 comments on commit 6bb781f

Please sign in to comment.