Skip to content

Commit 08bb38f

Browse files
committed
[tools] Add option to install binutils symlinks
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
1 parent 07eaa9b commit 08bb38f

File tree

12 files changed

+48
-0
lines changed

12 files changed

+48
-0
lines changed

llvm/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ set(CMAKE_MODULE_PATH
179179
# for use by clang_complete, YouCompleteMe, etc.
180180
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
181181

182+
option(LLVM_INSTALL_BINUTILS_SYMLINKS
183+
"Install symlinks from the binutils tool names to the corresponding LLVM tools." OFF)
184+
182185
option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
183186

184187
option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)

llvm/docs/CMake.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ LLVM-specific variables
224224
Generate build targets for the LLVM tools. Defaults to ON. You can use this
225225
option to disable the generation of build targets for the LLVM tools.
226226

227+
**LLVM_INSTALL_BINUTILS_SYMLINKS**:BOOL
228+
Install symlinks from the binutils tool names to the corresponding LLVM tools.
229+
For example, ar will be symlinked to llvm-ar.
230+
227231
**LLVM_BUILD_EXAMPLES**:BOOL
228232
Build LLVM examples. Defaults to OFF. Targets for building each example are
229233
generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for more

llvm/tools/llvm-ar/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ add_llvm_tool(llvm-ar
1717
add_llvm_tool_symlink(llvm-ranlib llvm-ar)
1818
add_llvm_tool_symlink(llvm-lib llvm-ar)
1919
add_llvm_tool_symlink(llvm-dlltool llvm-ar)
20+
21+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
22+
add_llvm_tool_symlink(ar llvm-ar)
23+
add_llvm_tool_symlink(dlltool llvm-ar)
24+
add_llvm_tool_symlink(ranlib llvm-ar)
25+
endif()

llvm/tools/llvm-cxxfilt/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
add_llvm_tool(llvm-cxxfilt
77
llvm-cxxfilt.cpp
88
)
9+
10+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
11+
add_llvm_tool_symlink(c++filt llvm-cxxfilt)
12+
endif()

llvm/tools/llvm-dwp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ add_llvm_tool(llvm-dwp
1515
DEPENDS
1616
intrinsics_gen
1717
)
18+
19+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
20+
add_llvm_tool_symlink(dwp llvm-dwp)
21+
endif()

llvm/tools/llvm-nm/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ add_llvm_tool(llvm-nm
1414
DEPENDS
1515
intrinsics_gen
1616
)
17+
18+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
19+
add_llvm_tool_symlink(nm llvm-nm)
20+
endif()

llvm/tools/llvm-objcopy/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ add_llvm_tool(llvm-objcopy
77
llvm-objcopy.cpp
88
Object.cpp
99
)
10+
11+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
12+
add_llvm_tool_symlink(objcopy llvm-objcopy)
13+
endif()

llvm/tools/llvm-objdump/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ add_llvm_tool(llvm-objdump
2525
if(HAVE_LIBXAR)
2626
target_link_libraries(llvm-objdump ${XAR_LIB})
2727
endif()
28+
29+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
30+
add_llvm_tool_symlink(objdump llvm-objdump)
31+
endif()

llvm/tools/llvm-readobj/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ add_llvm_tool(llvm-readobj
2323
)
2424

2525
add_llvm_tool_symlink(llvm-readelf llvm-readobj)
26+
27+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
28+
add_llvm_tool_symlink(readelf llvm-readobj)
29+
endif()

llvm/tools/llvm-size/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
add_llvm_tool(llvm-size
77
llvm-size.cpp
88
)
9+
10+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
11+
add_llvm_tool_symlink(size llvm-size)
12+
endif()

llvm/tools/llvm-strings/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ add_llvm_tool(llvm-strings
88
llvm-strings.cpp
99
)
1010

11+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
12+
add_llvm_tool_symlink(strings llvm-strings)
13+
endif()

llvm/tools/llvm-symbolizer/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ set(LLVM_LINK_COMPONENTS
1414
add_llvm_tool(llvm-symbolizer
1515
llvm-symbolizer.cpp
1616
)
17+
18+
if(LLVM_INSTALL_BINUTILS_SYMLINKS)
19+
add_llvm_tool_symlink(addr2line llvm-symbolizer)
20+
endif()

0 commit comments

Comments
 (0)