Skip to content

Commit

Permalink
[tools] Add option to install binutils symlinks
Browse files Browse the repository at this point in the history
The LLVM tools can be used as a replacement for binutils, in which case
it's convenient to create symlinks with the binutils names. Add support
for these symlinks in the build system. As with any other llvm tool
symlinks, the user can limit the installed symlinks by only adding the
desired ones to `LLVM_TOOLCHAIN_TOOLS`.

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

llvm-svn: 317272
  • Loading branch information
smeenai committed Nov 2, 2017
1 parent 07eaa9b commit 08bb38f
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/CMakeLists.txt
Expand Up @@ -179,6 +179,9 @@ set(CMAKE_MODULE_PATH
# for use by clang_complete, YouCompleteMe, etc.
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

option(LLVM_INSTALL_BINUTILS_SYMLINKS
"Install symlinks from the binutils tool names to the corresponding LLVM tools." OFF)

option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)

option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
Expand Down
4 changes: 4 additions & 0 deletions llvm/docs/CMake.rst
Expand Up @@ -224,6 +224,10 @@ LLVM-specific variables
Generate build targets for the LLVM tools. Defaults to ON. You can use this
option to disable the generation of build targets for the LLVM tools.

**LLVM_INSTALL_BINUTILS_SYMLINKS**:BOOL
Install symlinks from the binutils tool names to the corresponding LLVM tools.
For example, ar will be symlinked to llvm-ar.

**LLVM_BUILD_EXAMPLES**:BOOL
Build LLVM examples. Defaults to OFF. Targets for building each example are
generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for more
Expand Down
6 changes: 6 additions & 0 deletions llvm/tools/llvm-ar/CMakeLists.txt
Expand Up @@ -17,3 +17,9 @@ add_llvm_tool(llvm-ar
add_llvm_tool_symlink(llvm-ranlib llvm-ar)
add_llvm_tool_symlink(llvm-lib llvm-ar)
add_llvm_tool_symlink(llvm-dlltool llvm-ar)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(ar llvm-ar)
add_llvm_tool_symlink(dlltool llvm-ar)
add_llvm_tool_symlink(ranlib llvm-ar)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-cxxfilt/CMakeLists.txt
Expand Up @@ -6,3 +6,7 @@ set(LLVM_LINK_COMPONENTS
add_llvm_tool(llvm-cxxfilt
llvm-cxxfilt.cpp
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(c++filt llvm-cxxfilt)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-dwp/CMakeLists.txt
Expand Up @@ -15,3 +15,7 @@ add_llvm_tool(llvm-dwp
DEPENDS
intrinsics_gen
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(dwp llvm-dwp)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-nm/CMakeLists.txt
Expand Up @@ -14,3 +14,7 @@ add_llvm_tool(llvm-nm
DEPENDS
intrinsics_gen
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(nm llvm-nm)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-objcopy/CMakeLists.txt
Expand Up @@ -7,3 +7,7 @@ add_llvm_tool(llvm-objcopy
llvm-objcopy.cpp
Object.cpp
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(objcopy llvm-objcopy)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-objdump/CMakeLists.txt
Expand Up @@ -25,3 +25,7 @@ add_llvm_tool(llvm-objdump
if(HAVE_LIBXAR)
target_link_libraries(llvm-objdump ${XAR_LIB})
endif()

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(objdump llvm-objdump)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-readobj/CMakeLists.txt
Expand Up @@ -23,3 +23,7 @@ add_llvm_tool(llvm-readobj
)

add_llvm_tool_symlink(llvm-readelf llvm-readobj)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(readelf llvm-readobj)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-size/CMakeLists.txt
Expand Up @@ -6,3 +6,7 @@ set(LLVM_LINK_COMPONENTS
add_llvm_tool(llvm-size
llvm-size.cpp
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(size llvm-size)
endif()
3 changes: 3 additions & 0 deletions llvm/tools/llvm-strings/CMakeLists.txt
Expand Up @@ -8,3 +8,6 @@ add_llvm_tool(llvm-strings
llvm-strings.cpp
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(strings llvm-strings)
endif()
4 changes: 4 additions & 0 deletions llvm/tools/llvm-symbolizer/CMakeLists.txt
Expand Up @@ -14,3 +14,7 @@ set(LLVM_LINK_COMPONENTS
add_llvm_tool(llvm-symbolizer
llvm-symbolizer.cpp
)

if(LLVM_INSTALL_BINUTILS_SYMLINKS)
add_llvm_tool_symlink(addr2line llvm-symbolizer)
endif()

0 comments on commit 08bb38f

Please sign in to comment.