[llvm] r349679 - [gn build] Add build file for clang/lib/Basic and dependencies, 2nd try
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 19 12:21:49 PST 2018
Author: nico
Date: Wed Dec 19 12:21:49 2018
New Revision: 349679
URL: http://llvm.org/viewvc/llvm-project?rev=349679&view=rev
Log:
[gn build] Add build file for clang/lib/Basic and dependencies, 2nd try
Adds a build file for clang-tblgen and an action for running it, and uses that
to process all the .td files in include/clang/Basic.
Also adds an action to write include/clang/Config/config.h and
include/clang/Basic/Version.inc.
Differential Revision: https://reviews.llvm.org/D55847
(The previous commit of this contained unrelated changes, so I reverted the
whole previous commit and I'm now landing only what I intended to land.)
Added:
llvm/trunk/utils/gn/secondary/clang/
llvm/trunk/utils/gn/secondary/clang/include/
llvm/trunk/utils/gn/secondary/clang/include/clang/
llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/
llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/include/clang/Config/
llvm/trunk/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/lib/
llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/
llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni
llvm/trunk/utils/gn/secondary/clang/lib/Basic/
llvm/trunk/utils/gn/secondary/clang/lib/Basic/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/
llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/
llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/enable.gni
llvm/trunk/utils/gn/secondary/clang/utils/
llvm/trunk/utils/gn/secondary/clang/utils/TableGen/
llvm/trunk/utils/gn/secondary/clang/utils/TableGen/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni
Modified:
llvm/trunk/utils/gn/secondary/BUILD.gn
llvm/trunk/utils/gn/secondary/lld/include/lld/Common/BUILD.gn
llvm/trunk/utils/gn/secondary/llvm/utils/TableGen/tablegen.gni
Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=349679&r1=349678&r2=349679&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -1,6 +1,7 @@
group("default") {
deps = [
":lld",
+ "//clang/lib/Basic",
"//llvm/tools/llc",
"//llvm/tools/llvm-ar:symlinks",
"//llvm/tools/llvm-as",
Added: llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/BUILD.gn?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/include/clang/Basic/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -0,0 +1,109 @@
+import("//clang/utils/TableGen/clang_tablegen.gni")
+import("//llvm/version.gni")
+
+# Version header.
+
+action("version") {
+ script = "//llvm/utils/gn/build/write_cmake_config.py"
+
+ sources = [
+ "Version.inc.in",
+ ]
+ outputs = [
+ "$root_gen_dir/clang/include/clang/Basic/Version.inc",
+ ]
+ args = [
+ "-o",
+ rebase_path(outputs[0], root_out_dir),
+ rebase_path(sources[0], root_out_dir),
+
+ "CLANG_VERSION=$llvm_version",
+ "CLANG_VERSION_MAJOR=$llvm_version_major",
+ "CLANG_VERSION_MINOR=$llvm_version_minor",
+ "CLANG_VERSION_PATCHLEVEL=$llvm_version_patch",
+ ]
+}
+
+# Diagnostics.
+
+diag_groups = [
+ "Analysis",
+ "AST",
+ "Comment",
+ "Common",
+ "CrossTU",
+ "Driver",
+ "Frontend",
+ "Lex",
+ "Parse",
+ "Refactoring",
+ "Sema",
+ "Serialization",
+]
+foreach(diag_group, diag_groups) {
+ clang_tablegen("Diagnostic${diag_group}Kinds") {
+ args = [
+ "-gen-clang-diags-defs",
+ "-clang-component=${diag_group}",
+ ]
+ td_file = "Diagnostic.td"
+ }
+}
+group("diags_tablegen") {
+ # DiagnosticGroups and DiagnosticIndexName are intentionally not part of this
+ # group. Much of clang depends on the DiagKinds.inc files transitively,
+ # but almost nothing needs DiagnosticGroups.inc or DiagnosticIndexName.inc.
+ public_deps = []
+ foreach(diag_group, diag_groups) {
+ public_deps += [ ":Diagnostic${diag_group}Kinds" ]
+ }
+}
+
+clang_tablegen("DiagnosticGroups") {
+ args = [ "-gen-clang-diag-groups" ]
+ td_file = "Diagnostic.td"
+}
+
+clang_tablegen("DiagnosticIndexName") {
+ args = [ "-gen-clang-diags-index-name" ]
+ td_file = "Diagnostic.td"
+}
+
+# Attributes
+
+clang_tablegen("AttrList") {
+ args = [
+ "-gen-clang-attr-list",
+ "-I",
+ rebase_path("../..", root_out_dir),
+ ]
+ td_file = "Attr.td"
+}
+
+clang_tablegen("AttrSubMatchRulesList") {
+ args = [
+ "-gen-clang-attr-subject-match-rule-list",
+ "-I",
+ rebase_path("../..", root_out_dir),
+ ]
+ td_file = "Attr.td"
+}
+
+clang_tablegen("AttrHasAttributeImpl") {
+ args = [
+ "-gen-clang-attr-has-attribute-impl",
+ "-I",
+ rebase_path("../..", root_out_dir),
+ ]
+ td_file = "Attr.td"
+}
+
+# Misc
+
+clang_tablegen("arm_neon") {
+ args = [ "-gen-arm-neon-sema" ]
+}
+
+clang_tablegen("arm_fp16") {
+ args = [ "-gen-arm-neon-sema" ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/include/clang/Config/BUILD.gn?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/include/clang/Config/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/include/clang/Config/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -0,0 +1,84 @@
+import("//clang/lib/ARCMigrate/enable.gni")
+import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
+import("//llvm/utils/gn/build/libs/xml/enable.gni")
+import("//llvm/version.gni")
+
+config("Config_config") {
+ visibility = [ ":Config" ]
+ include_dirs = [ "$target_gen_dir/clang/include" ]
+}
+
+action("Config") {
+ script = "//llvm/utils/gn/build/write_cmake_config.py"
+
+ sources = [
+ "config.h.cmake",
+ ]
+ outputs = [
+ "$target_gen_dir/config.h",
+ ]
+ args = [
+ "-o",
+ rebase_path(outputs[0], root_out_dir),
+ rebase_path(sources[0], root_out_dir),
+
+ "BUG_REPORT_URL=https://bugs.llvm.org/",
+ "CLANG_DEFAULT_LINKER=",
+ "CLANG_DEFAULT_STD_C=",
+ "CLANG_DEFAULT_STD_CXX=",
+ "CLANG_DEFAULT_CXX_STDLIB=",
+ "CLANG_DEFAULT_RTLIB=",
+ "CLANG_DEFAULT_OBJCOPY=objcopy",
+ "CLANG_DEFAULT_OPENMP_RUNTIME=libomp",
+ "CLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_35",
+ "CLANG_LIBDIR_SUFFIX=",
+ "CLANG_RESOURCE_DIR=",
+ "C_INCLUDE_DIRS=",
+ "CLANG_CONFIG_FILE_SYSTEM_DIR=",
+ "CLANG_CONFIG_FILE_USER_DIR=",
+ "DEFAULT_SYSROOT=",
+ "GCC_INSTALL_PREFIX=",
+ "CLANG_ANALYZER_WITH_Z3=",
+ "BACKEND_PACKAGE_STRING=LLVM ${llvm_version}svn",
+ "ENABLE_LINKER_BUILD_ID=",
+ "ENABLE_X86_RELAX_RELOCATIONS=",
+ "ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=",
+ "CLANG_ENABLE_OBJC_REWRITER=1", # FIXME: flag?
+ ]
+
+ if (clang_enable_arcmt) {
+ args += [ "CLANG_ENABLE_ARCMT=1" ]
+ } else {
+ args += [ "CLANG_ENABLE_ARCMT=" ]
+ }
+
+ if (clang_enable_static_analyzer) {
+ args += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
+ } else {
+ args += [ "CLANG_ENABLE_STATIC_ANALYZER=" ]
+ }
+
+ if (host_os != "win") {
+ args += [ "CLANG_HAVE_RLIMITS=1" ]
+ } else {
+ args += [ "CLANG_HAVE_RLIMITS=" ]
+ }
+
+ if (llvm_enable_libxml2) {
+ args += [ "CLANG_HAVE_LIBXML=1" ]
+ } else {
+ args += [ "CLANG_HAVE_LIBXML=" ]
+ }
+
+ if (host_os == "mac") {
+ # FIXME: Hardcoding this isn't great, but assuming that the host ld version
+ # has anything to do with the ld version where the built clang will run
+ # isn't either. Probably want to make this a declare_args.
+ args += [ "HOST_LINK_VERSION=305" ]
+ } else {
+ args += [ "HOST_LINK_VERSION=" ]
+ }
+
+ # Let targets depending on this find the generated file.
+ public_configs = [ ":Config_config" ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni (added)
+++ llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/enable.gni Wed Dec 19 12:21:49 2018
@@ -0,0 +1,4 @@
+declare_args() {
+ # Whether to include the arc migrate tool in the clang binary.
+ clang_enable_arcmt = true
+}
Added: llvm/trunk/utils/gn/secondary/clang/lib/Basic/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/lib/Basic/BUILD.gn?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/lib/Basic/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/lib/Basic/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -0,0 +1,82 @@
+static_library("Basic") {
+ output_name = "clangBasic"
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ public_deps = [
+ # public_dep because public header Version.h includes generated Version.inc.
+ "//clang/include/clang/Basic:AttrList",
+ "//clang/include/clang/Basic:AttrSubMatchRulesList",
+ "//clang/include/clang/Basic:DiagnosticGroups",
+ "//clang/include/clang/Basic:diags_tablegen",
+ "//clang/include/clang/Basic:version",
+ ]
+ deps = [
+ "//clang/include/clang/Basic:AttrHasAttributeImpl",
+ "//clang/include/clang/Basic:arm_fp16",
+ "//clang/include/clang/Basic:arm_neon",
+ "//clang/include/clang/Config",
+ "//llvm/include/llvm/Config:llvm-config",
+ "//llvm/lib/IR",
+ "//llvm/lib/MC",
+ "//llvm/lib/Support",
+ ]
+ include_dirs = [ "." ]
+ sources = [
+ "Attributes.cpp",
+ "Builtins.cpp",
+ "CharInfo.cpp",
+ "CodeGenOptions.cpp",
+ "Cuda.cpp",
+ "Diagnostic.cpp",
+ "DiagnosticIDs.cpp",
+ "DiagnosticOptions.cpp",
+ "FileManager.cpp",
+ "FileSystemStatCache.cpp",
+ "FixedPoint.cpp",
+ "IdentifierTable.cpp",
+ "LangOptions.cpp",
+ "MemoryBufferCache.cpp",
+ "Module.cpp",
+ "ObjCRuntime.cpp",
+ "OpenMPKinds.cpp",
+ "OperatorPrecedence.cpp",
+ "SanitizerBlacklist.cpp",
+ "SanitizerSpecialCaseList.cpp",
+ "Sanitizers.cpp",
+ "SourceLocation.cpp",
+ "SourceManager.cpp",
+ "TargetInfo.cpp",
+ "Targets.cpp",
+ "Targets/AArch64.cpp",
+ "Targets/AMDGPU.cpp",
+ "Targets/ARC.cpp",
+ "Targets/ARM.cpp",
+ "Targets/AVR.cpp",
+ "Targets/BPF.cpp",
+ "Targets/Hexagon.cpp",
+ "Targets/Lanai.cpp",
+ "Targets/Le64.cpp",
+ "Targets/MSP430.cpp",
+ "Targets/Mips.cpp",
+ "Targets/NVPTX.cpp",
+ "Targets/Nios2.cpp",
+ "Targets/OSTargets.cpp",
+ "Targets/PNaCl.cpp",
+ "Targets/PPC.cpp",
+ "Targets/RISCV.cpp",
+ "Targets/SPIR.cpp",
+ "Targets/Sparc.cpp",
+ "Targets/SystemZ.cpp",
+ "Targets/TCE.cpp",
+ "Targets/WebAssembly.cpp",
+ "Targets/X86.cpp",
+ "Targets/XCore.cpp",
+ "TokenKinds.cpp",
+
+ # FIXME: This should be in its own target that passes -DHAVE_SVN_VERSION_INC
+ # and that also depends on a target generating SVNVersion.inc.
+ "Version.cpp",
+ "Warnings.cpp",
+ "XRayInstr.cpp",
+ "XRayLists.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/enable.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/enable.gni?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/enable.gni (added)
+++ llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/enable.gni Wed Dec 19 12:21:49 2018
@@ -0,0 +1,4 @@
+declare_args() {
+ # Whether to include the static analyzer in the clang binary.
+ clang_enable_static_analyzer = true
+}
Added: llvm/trunk/utils/gn/secondary/clang/utils/TableGen/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/utils/TableGen/BUILD.gn?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/utils/TableGen/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/utils/TableGen/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -0,0 +1,19 @@
+executable("clang-tblgen") {
+ deps = [
+ "//llvm/lib/Support",
+ "//llvm/lib/TableGen",
+ ]
+ sources = [
+ "ClangASTNodesEmitter.cpp",
+ "ClangAttrEmitter.cpp",
+ "ClangCommentCommandInfoEmitter.cpp",
+ "ClangCommentHTMLNamedCharacterReferenceEmitter.cpp",
+ "ClangCommentHTMLTagsEmitter.cpp",
+ "ClangDataCollectorsEmitter.cpp",
+ "ClangDiagnosticsEmitter.cpp",
+ "ClangOptionDocEmitter.cpp",
+ "ClangSACheckersEmitter.cpp",
+ "NeonEmitter.cpp",
+ "TableGen.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni?rev=349679&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni (added)
+++ llvm/trunk/utils/gn/secondary/clang/utils/TableGen/clang_tablegen.gni Wed Dec 19 12:21:49 2018
@@ -0,0 +1,41 @@
+# This file introduces a templates for running clang-tblgen.
+#
+# Parameters:
+#
+# args (required)
+# [list of strings] Flags to pass to llvm-tblgen.
+#
+# output_name (optional)
+# Basename of the generated output file.
+# Defaults to target name with ".inc" appended.
+#
+# td_file (optional)
+# The .td file to pass to llvm-tblgen.
+# Defaults to target name with ".td" appended.
+#
+# visibility (optional)
+# GN's regular visibility attribute, see `gn help visibility`.
+#
+# Example of usage:
+#
+# clang_tablegen("DiagnosticGroups") {
+# args = [ "-gen-clang-diag-groups" ]
+# td_file = "Diagnostic.td"
+# }
+
+import("//llvm/utils/TableGen/tablegen.gni")
+
+template("clang_tablegen") {
+ tablegen(target_name) {
+ forward_variables_from(invoker,
+ [
+ "args",
+ "output_name",
+ "td_file",
+ "visibility",
+ ])
+
+ # FIXME: In cross builds, this should depend on the host binary.
+ tblgen_target = "//clang/utils/TableGen:clang-tblgen"
+ }
+}
Modified: llvm/trunk/utils/gn/secondary/lld/include/lld/Common/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/include/lld/Common/BUILD.gn?rev=349679&r1=349678&r2=349679&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/include/lld/Common/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/lld/include/lld/Common/BUILD.gn Wed Dec 19 12:21:49 2018
@@ -12,7 +12,6 @@ action("version") {
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
-
rebase_path(sources[0], root_out_dir),
"LLD_VERSION=$llvm_version",
Modified: llvm/trunk/utils/gn/secondary/llvm/utils/TableGen/tablegen.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/utils/TableGen/tablegen.gni?rev=349679&r1=349678&r2=349679&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/utils/TableGen/tablegen.gni (original)
+++ llvm/trunk/utils/gn/secondary/llvm/utils/TableGen/tablegen.gni Wed Dec 19 12:21:49 2018
@@ -36,8 +36,12 @@ template("tablegen") {
action(target_name) {
forward_variables_from(invoker, [ "visibility" ])
- # FIXME: In cross builds, this should depend on the host binary.
- tblgen_target = "//llvm/utils/TableGen:llvm-tblgen"
+ if (defined(invoker.tblgen_target)) {
+ tblgen_target = invoker.tblgen_target
+ } else {
+ # FIXME: In cross builds, this should depend on the host binary.
+ tblgen_target = "//llvm/utils/TableGen:llvm-tblgen"
+ }
tblgen_executable = get_label_info(tblgen_target, "root_out_dir") +
"/bin/" + get_label_info(tblgen_target, "name")
deps = [
More information about the llvm-commits
mailing list