[llvm] r349486 - [gn build] Add build files for llvm-ar, llvm-nm, llvm-objdump, llvm-readelf

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 05:52:22 PST 2018


Author: nico
Date: Tue Dec 18 05:52:21 2018
New Revision: 349486

URL: http://llvm.org/viewvc/llvm-project?rev=349486&view=rev
Log:
[gn build] Add build files for llvm-ar, llvm-nm, llvm-objdump, llvm-readelf

Also add build files for deps DebugInfo/Symbolize, ToolDrivers/dll-tool.
Also add gn/build/libs/xar (needed by llvm-objdump).

Also delete an incorrect part of the symlink description in //BUILD.gn (it used
to be true before I made the symlink step write a stamp file; now it's no
longer true).

These are all binaries needed by check-lld that need symlinks.

Differential Revision: https://reviews.llvm.org/D55743

Added:
    llvm/trunk/utils/gn/build/libs/xar/
    llvm/trunk/utils/gn/build/libs/xar/BUILD.gn
    llvm/trunk/utils/gn/build/libs/xar/enable.gni
    llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/
    llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/
    llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/
    llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn
Modified:
    llvm/trunk/utils/gn/secondary/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Added: llvm/trunk/utils/gn/build/libs/xar/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/libs/xar/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/build/libs/xar/BUILD.gn (added)
+++ llvm/trunk/utils/gn/build/libs/xar/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,12 @@
+import("//llvm/utils/gn/build/libs/xar/enable.gni")
+
+config("xar_config") {
+  visibility = [ ":xar" ]
+  libs = [ "xar" ]
+}
+
+group("xar") {
+  if (llvm_enable_libxar) {
+    public_configs = [ ":xar_config" ]
+  }
+}

Added: llvm/trunk/utils/gn/build/libs/xar/enable.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/libs/xar/enable.gni?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/build/libs/xar/enable.gni (added)
+++ llvm/trunk/utils/gn/build/libs/xar/enable.gni Tue Dec 18 05:52:21 2018
@@ -0,0 +1,3 @@
+declare_args() {
+  llvm_enable_libxar = host_os == "mac"
+}

Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=349486&r1=349485&r2=349486&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -2,10 +2,14 @@ group("default") {
   deps = [
     ":lld",
     "//llvm/tools/llc",
+    "//llvm/tools/llvm-ar:symlinks",
     "//llvm/tools/llvm-as",
     "//llvm/tools/llvm-dis",
     "//llvm/tools/llvm-dwarfdump",
     "//llvm/tools/llvm-mc",
+    "//llvm/tools/llvm-nm:symlinks",
+    "//llvm/tools/llvm-objdump:symlinks",
+    "//llvm/tools/llvm-readobj:symlinks",
     "//llvm/tools/llvm-undname",
     "//llvm/tools/obj2yaml",
     "//llvm/tools/opt",
@@ -36,14 +40,33 @@ group("default") {
 # executable.  This has the effect that `ninja lld` builds lld and then creates
 # symlinks (via this target), while `ninja bin/lld` only builds lld and doesn't
 # update symlinks (in particular, on Windows it doesn't copy the new lld to its
-# new locations); also `ninja lld-link` will build lld and copy it (on Windows)
-# to lld-link, but it won't copy it to ld.lld.
+# new locations).
 # That seems simpler, more explicit, and good enough.
 group("lld") {
   deps = [
     "//lld/tools/lld:symlinks",
   ]
 }
+group("llvm-ar") {
+  deps = [
+    "//llvm/tools/llvm-ar:symlinks",
+  ]
+}
+group("llvm-nm") {
+  deps = [
+    "//llvm/tools/llvm-nm:symlinks",
+  ]
+}
+group("llvm-objdump") {
+  deps = [
+    "//llvm/tools/llvm-objdump:symlinks",
+  ]
+}
+group("llvm-readobj") {
+  deps = [
+    "//llvm/tools/llvm-readobj:symlinks",
+  ]
+}
 
 # A pool called "console" in the root BUILD.gn is magic and represents ninja's
 # built-in console pool. (Requires a GN with `gn --version` >= 552353.)

Modified: llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn?rev=349486&r1=349485&r2=349486&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -3,6 +3,7 @@ import("//llvm/triples.gni")
 import("//llvm/utils/gn/build/buildflags.gni")
 import("//llvm/utils/gn/build/libs/pthread/enable.gni")
 import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
+import("//llvm/utils/gn/build/libs/xar/enable.gni")
 import("//llvm/utils/gn/build/libs/xml/enable.gni")
 import("//llvm/utils/gn/build/libs/zlib/enable.gni")
 import("//llvm/version.gni")
@@ -182,7 +183,6 @@ action("config") {
       "HAVE_MACH_MACH_H=1",
       "HAVE_MALLOC_MALLOC_H=1",
       "HAVE_MALLOC_ZONE_STATISTICS=1",
-      "HAVE_LIBXAR=1",
       "HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=1",
     ]
   } else {
@@ -195,7 +195,6 @@ action("config") {
       "HAVE_MALLOC_H=1",
       "HAVE_MALLOC_MALLOC_H=",
       "HAVE_MALLOC_ZONE_STATISTICS=",
-      "HAVE_LIBXAR=",
       "HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=",
     ]
   }
@@ -293,6 +292,12 @@ action("config") {
     args += [ "LTDL_SHLIB_EXT=.dll" ]
   }
 
+  if (llvm_enable_libxar) {
+    args += [ "HAVE_LIBXAR=1" ]
+  } else {
+    args += [ "HAVE_LIBXAR=" ]
+  }
+
   if (llvm_enable_terminfo) {
     args += [ "HAVE_TERMINFO=1" ]
   } else {

Added: llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,16 @@
+static_library("Symbolize") {
+  output_name = "LLVMSymbolize"
+  deps = [
+    "//llvm/include/llvm/Config:config",
+    "//llvm/lib/DebugInfo/DWARF",
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/Demangle",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "DIPrinter.cpp",
+    "SymbolizableObjectFile.cpp",
+    "Symbolize.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,19 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("Options") {
+  visibility = [ ":DlltoolDriver" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
+static_library("DlltoolDriver") {
+  output_name = "LLVMDlltoolDriver"
+  deps = [
+    ":Options",
+    "//llvm/lib/Object",
+    "//llvm/lib/Option",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "DlltoolDriver.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni Tue Dec 18 05:52:21 2018
@@ -0,0 +1,5 @@
+declare_args() {
+  # If set, creates symlinks for nm, objdump, readelf in the build
+  # directory.
+  llvm_install_binutils_symlinks = false
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,46 @@
+import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+symlinks = [
+  "llvm-dlltool",
+  "llvm-lib",
+  "llvm-ranlib",
+]
+if (llvm_install_binutils_symlinks) {
+  symlinks += [
+    "ar",
+    "dlltool",
+    "ranlib",
+  ]
+}
+foreach(target, symlinks) {
+  symlink_or_copy(target) {
+    deps = [
+      ":llvm-ar",
+    ]
+    source = "llvm-ar"
+    output = "$root_out_dir/bin/$target"
+  }
+}
+
+# //:llvm-ar depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  deps = []
+  foreach(target, symlinks) {
+    deps += [ ":$target" ]
+  }
+}
+
+executable("llvm-ar") {
+  deps = [
+    "//llvm/lib/IR",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target:TargetsToBuild",
+    "//llvm/lib/ToolDrivers/llvm-dlltool:DlltoolDriver",
+    "//llvm/lib/ToolDrivers/llvm-lib:LibDriver",
+  ]
+  sources = [
+    "llvm-ar.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,37 @@
+import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+if (llvm_install_binutils_symlinks) {
+  symlink_or_copy("nm") {
+    deps = [
+      ":llvm-nm",
+    ]
+    source = "llvm-nm"
+    output = "$root_out_dir/bin/nm"
+  }
+}
+
+# //:llvm-nm depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  if (llvm_install_binutils_symlinks) {
+    deps = [
+      ":nm",
+    ]
+  }
+}
+
+executable("llvm-nm") {
+  deps = [
+    "//llvm/lib/Bitcode/Reader",
+    "//llvm/lib/Demangle",
+    "//llvm/lib/IR",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target:AllTargetsAsmParsers",
+    "//llvm/lib/Target:AllTargetsDescs",
+    "//llvm/lib/Target:AllTargetsInfos",
+  ]
+  sources = [
+    "llvm-nm.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,48 @@
+import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+if (llvm_install_binutils_symlinks) {
+  symlink_or_copy("objdump") {
+    deps = [
+      ":llvm-objdump",
+    ]
+    source = "llvm-objdump"
+    output = "$root_out_dir/bin/objdump"
+  }
+}
+
+# //:llvm-nm depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  if (llvm_install_binutils_symlinks) {
+    deps = [
+      ":objdump",
+    ]
+  }
+}
+
+executable("llvm-objdump") {
+  deps = [
+    "//llvm/include/llvm/Config:config",
+    "//llvm/lib/CodeGen",
+    "//llvm/lib/DebugInfo/DWARF",
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/DebugInfo/Symbolize",
+    "//llvm/lib/Demangle",
+    "//llvm/lib/MC",
+    "//llvm/lib/MC/MCDisassembler",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target:AllTargetsAsmPrinters",
+    "//llvm/lib/Target:AllTargetsDescs",
+    "//llvm/lib/Target:AllTargetsDisassemblers",
+    "//llvm/lib/Target:AllTargetsInfos",
+    "//llvm/utils/gn/build/libs/xar",
+  ]
+  sources = [
+    "COFFDump.cpp",
+    "ELFDump.cpp",
+    "MachODump.cpp",
+    "WasmDump.cpp",
+    "llvm-objdump.cpp",
+  ]
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn?rev=349486&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn Tue Dec 18 05:52:21 2018
@@ -0,0 +1,49 @@
+import("//llvm/tools/binutils_symlinks.gni")
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+symlinks = [ "llvm-readelf" ]
+if (llvm_install_binutils_symlinks) {
+  symlinks += [ "readelf" ]
+}
+foreach(target, symlinks) {
+  symlink_or_copy(target) {
+    deps = [
+      ":llvm-readobj",
+    ]
+    source = "llvm-readobj"
+    output = "$root_out_dir/bin/$target"
+  }
+}
+
+# //:llvm-readobj depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  deps = []
+  foreach(target, symlinks) {
+    deps += [ ":$target" ]
+  }
+}
+
+executable("llvm-readobj") {
+  deps = [
+    "//llvm/lib/BinaryFormat",
+    "//llvm/lib/DebugInfo/CodeView",
+    "//llvm/lib/DebugInfo/DWARF",
+    "//llvm/lib/DebugInfo/MSF",
+    "//llvm/lib/DebugInfo/PDB",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+  ]
+  sources = [
+    "ARMWinEHPrinter.cpp",
+    "COFFDumper.cpp",
+    "COFFImportDumper.cpp",
+    "ELFDumper.cpp",
+    "Error.cpp",
+    "MachODumper.cpp",
+    "ObjDumper.cpp",
+    "WasmDumper.cpp",
+    "Win64EHDumper.cpp",
+    "WindowsResourceDumper.cpp",
+    "llvm-readobj.cpp",
+  ]
+}




More information about the llvm-commits mailing list