diff --git a/llvm/docs/CommandGuide/index.rst b/llvm/docs/CommandGuide/index.rst
--- a/llvm/docs/CommandGuide/index.rst
+++ b/llvm/docs/CommandGuide/index.rst
@@ -14,25 +14,26 @@
.. toctree::
:maxdepth: 1
- llvm-as
- llvm-dis
- opt
+ dsymutil
llc
lli
- llvm-link
- llvm-lib
- llvm-lipo
+ llvm-as
llvm-config
+ llvm-cov
llvm-cxxmap
llvm-diff
- llvm-cov
- llvm-profdata
- llvm-stress
- llvm-symbolizer
+ llvm-dis
llvm-dwarfdump
- dsymutil
+ llvm-lib
+ llvm-libtool-darwin
+ llvm-link
+ llvm-lipo
llvm-mca
+ llvm-profdata
llvm-readobj
+ llvm-stress
+ llvm-symbolizer
+ opt
GNU binutils replacements
~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/llvm/docs/CommandGuide/llvm-libtool-darwin.rst b/llvm/docs/CommandGuide/llvm-libtool-darwin.rst
new file mode 100644
--- /dev/null
+++ b/llvm/docs/CommandGuide/llvm-libtool-darwin.rst
@@ -0,0 +1,59 @@
+llvm-libtool-darwin - LLVM tool for creating libraries for Darwin
+=================================================================
+
+.. program:: llvm-libtool-darwin
+
+SYNOPSIS
+--------
+
+:program:`llvm-libtool-darwin` [*options*] **
+
+DESCRIPTION
+-----------
+
+:program:`llvm-libtool-darwin` is a tool for creating static and dynamic
+libraries for Darwin.
+
+For most scenarios, it works as a drop-in replacement for cctools'
+:program:`libtool`.
+
+OPTIONS
+--------
+:program:`llvm-libtool-darwin` supports the following options:
+
+.. option:: -h, -help
+
+ Show help and usage for this command.
+
+.. option:: -help-list
+
+ Show help and usage for this command without grouping the options
+ into categories.
+
+.. option:: -color
+
+ Use colors in output.
+
+.. option:: -version
+
+ Display the version of this program.
+
+.. option:: -o
+
+ Specify the output file name. Must be specified exactly once.
+
+EXIT STATUS
+-----------
+
+:program:`llvm-libtool-darwin` exits with a non-zero exit code if there is an error.
+Otherwise, it exits with code 0.
+
+BUGS
+----
+
+To report bugs, please visit .
+
+SEE ALSO
+--------
+
+:manpage:`llvm-ar(1)`
diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -82,6 +82,7 @@
llvm-install-name-tool
llvm-jitlink
llvm-lib
+ llvm-libtool-darwin
llvm-link
llvm-lipo
llvm-locstats
diff --git a/llvm/test/tools/llvm-libtool-darwin/Inputs/input1.yaml b/llvm/test/tools/llvm-libtool-darwin/Inputs/input1.yaml
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-libtool-darwin/Inputs/input1.yaml
@@ -0,0 +1,56 @@
+# int symbol1() {
+# return 0;
+# }
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000001
+ ncmds: 2
+ sizeofcmds: 176
+ flags: 0x00002000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 152
+ segname: ''
+ vmaddr: 0
+ vmsize: 8
+ fileoff: 312
+ filesize: 8
+ maxprot: 7
+ initprot: 7
+ nsects: 1
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ size: 8
+ offset: 0x00000138
+ align: 4
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ content: 554889E531C05DC3
+ - cmd: LC_SYMTAB
+ cmdsize: 24
+ symoff: 320
+ nsyms: 1
+ stroff: 336
+ strsize: 8
+LinkEditData:
+ NameList:
+ - n_strx: 1
+ n_type: 0x0F
+ n_sect: 1
+ n_desc: 0
+ n_value: 0
+ StringTable:
+ - ''
+ - _symbol1
+...
diff --git a/llvm/test/tools/llvm-libtool-darwin/Inputs/input2.yaml b/llvm/test/tools/llvm-libtool-darwin/Inputs/input2.yaml
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-libtool-darwin/Inputs/input2.yaml
@@ -0,0 +1,57 @@
+# int symbol2() {
+# return 0;
+# }
+--- !mach-o
+FileHeader:
+ magic: 0xFEEDFACF
+ cputype: 0x01000007
+ cpusubtype: 0x00000003
+ filetype: 0x00000001
+ ncmds: 2
+ sizeofcmds: 176
+ flags: 0x00002000
+ reserved: 0x00000000
+LoadCommands:
+ - cmd: LC_SEGMENT_64
+ cmdsize: 152
+ segname: ''
+ vmaddr: 0
+ vmsize: 15
+ fileoff: 312
+ filesize: 15
+ maxprot: 7
+ initprot: 7
+ nsects: 1
+ flags: 0
+ Sections:
+ - sectname: __text
+ segname: __TEXT
+ addr: 0x0000000000000000
+ size: 15
+ offset: 0x00000138
+ align: 4
+ reloff: 0x00000000
+ nreloc: 0
+ flags: 0x80000400
+ reserved1: 0x00000000
+ reserved2: 0x00000000
+ reserved3: 0x00000000
+ content: 554889E531C0C745FC000000005DC3
+ - cmd: LC_SYMTAB
+ cmdsize: 24
+ symoff: 328
+ nsyms: 1
+ stroff: 344
+ strsize: 8
+LinkEditData:
+ NameList:
+ - n_strx: 1
+ n_type: 0x0F
+ n_sect: 1
+ n_desc: 0
+ n_value: 0
+ StringTable:
+ - ''
+ - _symbol2
+ - ''
+...
diff --git a/llvm/test/tools/llvm-libtool-darwin/basic.test b/llvm/test/tools/llvm-libtool-darwin/basic.test
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-libtool-darwin/basic.test
@@ -0,0 +1,10 @@
+## This test checks that main exits normally (error code 0) for correct input/output args.
+
+# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
+# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
+
+## Pass single input:
+# RUN: llvm-libtool-darwin -o %t.lib %t-input1.o
+
+## Pass multiple inputs:
+# RUN: llvm-libtool-darwin -o %t.lib %t-input1.o %t-input2.o
diff --git a/llvm/test/tools/llvm-libtool-darwin/help-message.test b/llvm/test/tools/llvm-libtool-darwin/help-message.test
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-libtool-darwin/help-message.test
@@ -0,0 +1,23 @@
+## This test checks that the help message is displayed correctly.
+
+# RUN: llvm-libtool-darwin -h | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
+# RUN: llvm-libtool-darwin -help | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
+# RUN: llvm-libtool-darwin --help | FileCheck --check-prefixes=LIBTOOL-USAGE,CATEG %s --match-full-lines
+# RUN: llvm-libtool-darwin --help-list | \
+# RUN: FileCheck -check-prefixes=LIBTOOL-USAGE,LIST %s --match-full-lines
+
+# RUN: not llvm-libtool-darwin -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
+# RUN: not llvm-libtool-darwin --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
+
+# LIBTOOL-USAGE: OVERVIEW: llvm-libtool-darwin
+# LIBTOOL-USAGE: USAGE: llvm-libtool-darwin{{(\.exe)?}} [options]
+# LIBTOOL-USAGE: OPTIONS:
+
+# CATEG: Color Options:
+# LIST-NOT: Color Options:
+# CATEG: Generic Options:
+# LIST-NOT: Generic Options:
+# CATEG: llvm-libtool-darwin Options:
+# LIST-NOT: llvm-libtool-darwin Options:
+
+# UNKNOWN-ARG: Unknown command line argument '{{-+}}abcabc'
diff --git a/llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test b/llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
new file mode 100644
--- /dev/null
+++ b/llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
@@ -0,0 +1,25 @@
+## This test checks that an error is thrown in case of invalid input/output args.
+
+## Missing input file:
+# RUN: not llvm-libtool-darwin -o %t.lib 2>&1 | \
+# RUN: FileCheck %s --check-prefix=NO-INPUT
+
+# NO-INPUT: Must specify at least 1 positional argument
+
+## Missing output file:
+# RUN: not llvm-libtool-darwin %t.input 2>&1 | \
+# RUN: FileCheck %s --check-prefix=NO-OUTPUT
+
+# NO-OUTPUT: for the -o option: must be specified at least once!
+
+## Missing argument to -o:
+# RUN: not llvm-libtool-darwin %t.input -o 2>&1 | \
+# RUN: FileCheck %s --check-prefix=MISSING
+
+# MISSING: for the -o option: requires a value!
+
+## Passing in two output files:
+# RUN: not llvm-libtool-darwin %t.input -o %t.lib1 -o %t.lib2 2>&1 | \
+# RUN: FileCheck %s --check-prefix=DOUBLE-OUTPUT
+
+# DOUBLE-OUTPUT: for the -o option: must occur exactly one time!
diff --git a/llvm/tools/llvm-libtool-darwin/CMakeLists.txt b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt
@@ -0,0 +1,7 @@
+set(LLVM_LINK_COMPONENTS
+ Support
+ )
+
+add_llvm_tool(llvm-libtool-darwin
+ llvm-libtool-darwin.cpp
+)
diff --git a/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt b/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt
new file mode 100644
--- /dev/null
+++ b/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt
@@ -0,0 +1,20 @@
+;===- ./tools/llvm-libtool-darwin/LVMBuild.txt -----------------*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+[component_0]
+type = Tool
+name = llvm-libtool-darwin
+parent = Tools
+required_libraries = Support
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
new file mode 100644
--- /dev/null
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -0,0 +1,34 @@
+//===-- llvm-libtool-darwin.cpp - a tool for creating libraries -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// A utility for creating static and dynamic libraries for Darwin.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+cl::OptionCategory LibtoolCategory("llvm-libtool-darwin Options");
+
+static cl::opt OutputFile("o", cl::desc("Specify output filename"),
+ cl::value_desc("filename"), cl::Required,
+ cl::cat(LibtoolCategory));
+
+static cl::list InputFiles(cl::Positional,
+ cl::desc(""),
+ cl::OneOrMore,
+ cl::cat(LibtoolCategory));
+
+int main(int Argc, char **Argv) {
+ InitLLVM X(Argc, Argv);
+ cl::HideUnrelatedOptions({&LibtoolCategory, &ColorCategory});
+ cl::ParseCommandLineOptions(Argc, Argv, "llvm-libtool-darwin\n");
+}