Index: llvm/trunk/utils/gn/build/libs/xar/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/build/libs/xar/BUILD.gn +++ llvm/trunk/utils/gn/build/libs/xar/BUILD.gn @@ -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" ] + } +} Index: llvm/trunk/utils/gn/build/libs/xar/enable.gni =================================================================== --- llvm/trunk/utils/gn/build/libs/xar/enable.gni +++ llvm/trunk/utils/gn/build/libs/xar/enable.gni @@ -0,0 +1,3 @@ +declare_args() { + llvm_enable_libxar = host_os == "mac" +} Index: llvm/trunk/utils/gn/secondary/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/BUILD.gn +++ llvm/trunk/utils/gn/secondary/BUILD.gn @@ -2,10 +2,14 @@ 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 @@ # 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.) Index: llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn @@ -3,6 +3,7 @@ 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 @@ "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 @@ "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 @@ 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 { Index: llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/DebugInfo/Symbolize/BUILD.gn @@ -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", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/ToolDrivers/llvm-dlltool/BUILD.gn @@ -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", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni +++ llvm/trunk/utils/gn/secondary/llvm/tools/binutils_symlinks.gni @@ -0,0 +1,5 @@ +declare_args() { + # If set, creates symlinks for nm, objdump, readelf in the build + # directory. + llvm_install_binutils_symlinks = false +} Index: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-ar/BUILD.gn @@ -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", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-nm/BUILD.gn @@ -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", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-objdump/BUILD.gn @@ -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", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/tools/llvm-readobj/BUILD.gn @@ -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", + ] +}