[llvm] aaf6608 - [docs] [tools] Document and alphabetize all llvm-config command-line options

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 00:44:35 PDT 2022


Author: Frances Wingerter
Date: 2022-03-31T08:44:10+01:00
New Revision: aaf6608441d7ec084e2c05447aeab8cb357cab9a

URL: https://github.com/llvm/llvm-project/commit/aaf6608441d7ec084e2c05447aeab8cb357cab9a
DIFF: https://github.com/llvm/llvm-project/commit/aaf6608441d7ec084e2c05447aeab8cb357cab9a.diff

LOG: [docs] [tools] Document and alphabetize all llvm-config command-line options

Also implements explicit handling for the already-documented --help
flag.

Added: 
    

Modified: 
    llvm/docs/CommandGuide/llvm-config.rst
    llvm/tools/llvm-config/llvm-config.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CommandGuide/llvm-config.rst b/llvm/docs/CommandGuide/llvm-config.rst
index 1590066855919..2dddbcc53dc6a 100644
--- a/llvm/docs/CommandGuide/llvm-config.rst
+++ b/llvm/docs/CommandGuide/llvm-config.rst
@@ -29,50 +29,75 @@ To link against the JIT:
 OPTIONS
 -------
 
-**--version**
+**--assertion-mode**
 
- Print the version number of LLVM.
+ Print the assertion mode used when LLVM was built (ON or OFF).
 
-**-help**
+**--bindir**
 
- Print a summary of **llvm-config** arguments.
+ Print the installation directory for LLVM binaries.
 
-**--prefix**
+**--build-mode**
 
- Print the installation prefix for LLVM.
+ Print the build mode used when LLVM was built (e.g. Debug or Release).
 
-**--src-root**
+**--build-system**
 
- Print the source root from which LLVM was built.
+ Print the build system used to build LLVM (e.g. `cmake` or `gn`).
 
-**--obj-root**
+**--cflags**
 
- Print the object root used to build LLVM.
+ Print the C compiler flags needed to use LLVM headers.
 
-**--bindir**
+**--cmakedir**
 
- Print the installation directory for LLVM binaries.
+ Print the installation directory for LLVM CMake modules.
 
-**--includedir**
+**--components**
 
- Print the installation directory for LLVM headers.
+ Print all valid component names.
 
-**--libdir**
+**--cppflags**
 
- Print the installation directory for LLVM libraries.
+ Print the C preprocessor flags needed to use LLVM headers.
 
 **--cxxflags**
 
  Print the C++ compiler flags needed to use LLVM headers.
 
+**--has-rtti**
+
+ Print whether or not LLVM was built with rtti (YES or NO).
+
+**--help**
+
+ Print a summary of **llvm-config** arguments.
+
+**--host-target**
+
+ Print the target triple used to configure LLVM.
+
+**--ignore-libllvm**
+
+ Ignore libLLVM and link component libraries instead.
+
+**--includedir**
+
+ Print the installation directory for LLVM headers.
+
 **--ldflags**
 
  Print the flags needed to link against LLVM libraries.
 
-**--libs**
+**--libdir**
 
- Print all the libraries needed to link against the specified LLVM
- *components*, including any dependencies.
+ Print the installation directory for LLVM libraries.
+
+**--libfiles**
+
+ Similar to **--libs**, but print the full path to each library file.  This is
+ useful when creating makefile dependencies, to ensure that a tool is relinked if
+ any library it uses changes.
 
 **--libnames**
 
@@ -80,23 +105,47 @@ OPTIONS
  without **-l** or pathnames.  Useful for linking against a not-yet-installed
  copy of LLVM.
 
-**--libfiles**
+**--libs**
 
- Similar to **--libs**, but print the full path to each library file.  This is
- useful when creating makefile dependencies, to ensure that a tool is relinked if
- any library it uses changes.
+ Print all the libraries needed to link against the specified LLVM
+ *components*, including any dependencies.
 
-**--components**
+**--link-shared**
 
- Print all valid component names.
+ Link the components as shared libraries.
+
+**--link-static**
+
+ Link the component libraries statically.
+
+**--obj-root**
+
+ Print the object root used to build LLVM.
+
+**--prefix**
+
+ Print the installation prefix for LLVM.
+
+**--shared-mode**
+
+ Print how the provided components can be collectively linked (`shared` or `static`).
+
+**--src-root**
+
+ Print the source root from which LLVM was built.
+
+**--system-libs**
+
+ Print all the system libraries needed to link against the specified LLVM
+ *components*, including any dependencies.
 
 **--targets-built**
 
  Print the component names for all targets supported by this copy of LLVM.
 
-**--build-mode**
+**--version**
 
- Print the build mode used when LLVM was built (e.g. Debug or Release)
+ Print the version number of LLVM.
 
 
 COMPONENTS

diff  --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
index 8ed88f33ead46..e9fa7bd2c3889 100644
--- a/llvm/tools/llvm-config/llvm-config.cpp
+++ b/llvm/tools/llvm-config/llvm-config.cpp
@@ -201,7 +201,7 @@ static std::vector<std::string> ComputeLibsForComponents(
 
 /* *** */
 
-static void usage() {
+static void usage(bool ExitWithFailure = true) {
   errs() << "\
 usage: llvm-config <OPTION>... [<COMPONENT>...]\n\
 \n\
@@ -212,37 +212,39 @@ LLVM.  Typically called from 'configure' scripts.  Examples:\n\
   llvm-config --libs engine bcreader scalaropts\n\
 \n\
 Options:\n\
-  --version         Print LLVM version.\n\
-  --prefix          Print the installation prefix.\n\
-  --src-root        Print the source root LLVM was built from.\n\
-  --obj-root        Print the object root used to build LLVM.\n\
+  --assertion-mode  Print assertion mode of LLVM tree (ON or OFF).\n\
   --bindir          Directory containing LLVM executables.\n\
-  --includedir      Directory containing LLVM headers.\n\
-  --libdir          Directory containing LLVM libraries.\n\
-  --cmakedir        Directory containing LLVM cmake modules.\n\
-  --cppflags        C preprocessor flags for files that include LLVM headers.\n\
+  --build-mode      Print build mode of LLVM tree (e.g. Debug or Release).\n\
+  --build-system    Print the build system used to build LLVM (e.g. `cmake` or `gn`).\n\
   --cflags          C compiler flags for files that include LLVM headers.\n\
+  --cmakedir        Directory containing LLVM CMake modules.\n\
+  --components      List of all possible components.\n\
+  --cppflags        C preprocessor flags for files that include LLVM headers.\n\
   --cxxflags        C++ compiler flags for files that include LLVM headers.\n\
+  --has-rtti        Print whether or not LLVM was built with rtti (YES or NO).\n\
+  --help            Print a summary of llvm-config arguments.\n\
+  --host-target     Target triple used to configure LLVM.\n\
+  --ignore-libllvm  Ignore libLLVM and link component libraries instead.\n\
+  --includedir      Directory containing LLVM headers.\n\
   --ldflags         Print Linker flags.\n\
-  --system-libs     System Libraries needed to link against LLVM components.\n\
-  --libs            Libraries needed to link against LLVM components.\n\
-  --libnames        Bare library names for in-tree builds.\n\
+  --libdir          Directory containing LLVM libraries.\n\
   --libfiles        Fully qualified library filenames for makefile depends.\n\
-  --components      List of all possible components.\n\
-  --targets-built   List of all targets currently built.\n\
-  --host-target     Target triple used to configure LLVM.\n\
-  --build-mode      Print build mode of LLVM tree (e.g. Debug or Release).\n\
-  --assertion-mode  Print assertion mode of LLVM tree (ON or OFF).\n\
-  --build-system    Print the build system used to build LLVM (always cmake).\n\
-  --has-rtti        Print whether or not LLVM was built with rtti (YES or NO).\n\
-  --shared-mode     Print how the provided components can be collectively linked (`shared` or `static`).\n\
+  --libnames        Bare library names for in-tree builds.\n\
+  --libs            Libraries needed to link against LLVM components.\n\
   --link-shared     Link the components as shared libraries.\n\
   --link-static     Link the component libraries statically.\n\
-  --ignore-libllvm  Ignore libLLVM and link component libraries instead.\n\
+  --obj-root        Print the object root used to build LLVM.\n\
+  --prefix          Print the installation prefix.\n\
+  --shared-mode     Print how the provided components can be collectively linked (`shared` or `static`).\n\
+  --src-root        Print the source root LLVM was built from.\n\
+  --system-libs     System Libraries needed to link against LLVM components.\n\
+  --targets-built   List of all targets currently built.\n\
+  --version         Print LLVM version.\n\
 Typical components:\n\
   all               All LLVM libraries (default).\n\
   engine            Either a native JIT or a bitcode interpreter.\n";
-  exit(1);
+  if (ExitWithFailure)
+    exit(1);
 }
 
 /// Compute the path to the main executable.
@@ -598,6 +600,8 @@ int main(int argc, char **argv) {
         LinkMode = LinkModeShared;
       } else if (Arg == "--link-static") {
         LinkMode = LinkModeStatic;
+      } else if (Arg == "--help") {
+        usage(false);
       } else {
         usage();
       }


        


More information about the llvm-commits mailing list