Skip to content

Commit 4876ee1

Browse files
committed
Initial commit.
0 parents  commit 4876ee1

File tree

4,798 files changed

+1923144
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,798 files changed

+1923144
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

CMakeLists.txt

+217
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
##
2+
## CMake build script for LLVM.
3+
##
4+
5+
cmake_minimum_required(VERSION 3.6)
6+
7+
project(LLVM CXX C)
8+
9+
if(TARGET llvm-project)
10+
return()
11+
endif()
12+
13+
find_package(Threads REQUIRED)
14+
if(UNIX)
15+
find_package(ZLIB REQUIRED)
16+
endif()
17+
18+
# Set the default build type to 'Release'
19+
if (NOT CMAKE_BUILD_TYPE)
20+
set(default_build_type "Release")
21+
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
22+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
23+
endif()
24+
25+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
26+
set(IS_DEBUG_BUILD "YES")
27+
else()
28+
set(IS_DEBUG_BUILD "NO")
29+
endif()
30+
31+
# Use the ExternalProject module instead of just CMake because we want to build and
32+
# install only some tools from LLVM, not all the libraries and tools.
33+
include(ExternalProject)
34+
35+
# LLVM requires python3, so we first check whether python3 is installed as
36+
# "python3", and if not, we suppose that `python` runs python3.
37+
find_program(PYTHON_EXECUTABLE "python3")
38+
if(NOT PYTHON_EXECUTABLE)
39+
find_program(PYTHON_EXECUTABLE "python")
40+
endif()
41+
42+
# The LLVM project properties differ between MSVC and Linux builds.
43+
if(MSVC)
44+
# See the comments below for Linux rules for an explanation of the passed
45+
# options.
46+
ExternalProject_Add(llvm-project
47+
SOURCE_DIR "${PROJECT_SOURCE_DIR}/src"
48+
CMAKE_ARGS
49+
-DCMAKE_BUILD_TYPE=Release
50+
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
51+
-DLLVM_TARGETS_TO_BUILD=X86
52+
-DLLVM_INCLUDE_TESTS=NO
53+
-DLLVM_REQUIRES_RTTI=YES
54+
-DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD}
55+
-DLLVM_ENABLE_WARNINGS=NO
56+
-DLLVM_ENABLE_TERMINFO=YES
57+
INSTALL_COMMAND ""
58+
)
59+
else() # Linux
60+
ExternalProject_Add(llvm-project
61+
SOURCE_DIR "${PROJECT_SOURCE_DIR}/src"
62+
CMAKE_ARGS
63+
# Force a release build (we don't need to debug LLVM).
64+
-DCMAKE_BUILD_TYPE=Release
65+
66+
# Force Python3 (see the comment above when setting
67+
# PYTHON_EXECUTABLE).
68+
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
69+
70+
# Targets to be build.
71+
-DLLVM_TARGETS_TO_BUILD=X86
72+
73+
# Disable the generation of targets for tests (we don't need them).
74+
-DLLVM_INCLUDE_TESTS=NO
75+
76+
# Our tools depending on LLVM require RTTI, so build LLVM with it.
77+
-DLLVM_REQUIRES_RTTI=YES
78+
79+
# When building in the debug mode (=> assertions are enabled), we
80+
# have to build LLVM with assertions. This prevents link errors
81+
# when building the middle-end and back-end (see
82+
# https://github.com/oclint/oclint/issues/129).
83+
-DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD}
84+
85+
# Disable the emission of warnings, which are useless since we do
86+
# not modify the LLVM sources (of course, except for a few
87+
# exceptions).
88+
-DLLVM_ENABLE_WARNINGS=NO
89+
90+
# Enable the use of terminfo because in the back-end, we use the
91+
# coloring system from LLVM so we do not have to deal with issues
92+
# due to multi-platform support of coloring by ourselves.
93+
# Note to developers: On Linux, programs that link LLVM libraries
94+
# need to also link the tinfo library.
95+
-DLLVM_ENABLE_TERMINFO=YES
96+
97+
# Disable the automatic build of tools and build them manually. In
98+
# this way, we can only select the tools we are actually going to
99+
# use instead of building them all.
100+
#
101+
# This does not work on MSVC when using a project/solution.
102+
-DLLVM_BUILD_TOOLS=NO
103+
104+
# Build LLVM libraries and only the needed tools.
105+
# Use the literal "$(MAKE)" instead of just "make" so that "$(MAKE)"
106+
# appears in the generated Makefiles. That tells the top level make to
107+
# spawn sub-makes with the job controller from the top level make.
108+
# Then, we don't need to specify any -j flags anywhere except at the
109+
# top level (see
110+
# http://www.cmake.org/pipermail/cmake/2010-October/040109.html)
111+
#
112+
# This does not work on MSVC when using a project/solution.
113+
BUILD_COMMAND "$(MAKE)"
114+
COMMAND "$(MAKE)" llvm-as
115+
COMMAND "$(MAKE)" llvm-dis
116+
117+
# Disable the installation right after build (we want to install the needed
118+
# tools manually when calling `make.sh install`).
119+
INSTALL_COMMAND ""
120+
)
121+
endif()
122+
123+
# Forces a configure step for the given external project.
124+
# The configure step for external projects is needed to (1) detect source-file
125+
# changes and (2) fix infinite recursion of 'make' after a terminated build.
126+
macro(force_configure_step target)
127+
# This solution is based on
128+
# http://comments.gmane.org/gmane.comp.programming.tools.cmake.user/43024
129+
ExternalProject_Add_Step(${target} force-configure
130+
COMMAND ${CMAKE_COMMAND} -E echo "Force configure of ${target}"
131+
DEPENDEES update
132+
DEPENDERS configure
133+
ALWAYS 1
134+
)
135+
endmacro()
136+
137+
# We need to force the configuration step for LLVM. Otherwise, if we changed
138+
# LLVM sources, they would not be rebuilt. This also fixes infinite recursion
139+
# when running make after an interrupted LLVM build.
140+
if(NOT SKIP_DEPENDENCIES)
141+
force_configure_step(llvm-project)
142+
endif()
143+
144+
# Add libraries.
145+
ExternalProject_Get_Property(llvm-project binary_dir)
146+
147+
add_library(llvm INTERFACE)
148+
add_dependencies(llvm llvm-project)
149+
150+
set(LLVM_LIB_LIST
151+
LLVMInterpreter
152+
LLVMMCJIT
153+
LLVMRuntimeDyld
154+
LLVMOrcJIT
155+
LLVMExecutionEngine
156+
LLVMRuntimeDyld
157+
LLVMX86CodeGen
158+
LLVMX86AsmParser
159+
LLVMX86Disassembler
160+
LLVMBitWriter
161+
LLVMIRReader
162+
LLVMInstrumentation
163+
LLVMObject
164+
LLVMSupport
165+
LLVMipo
166+
LLVMAsmPrinter
167+
LLVMSelectionDAG
168+
LLVMX86Desc
169+
LLVMAsmParser
170+
LLVMBitReader
171+
LLVMVectorize
172+
LLVMMCParser
173+
LLVMCodeGen
174+
LLVMX86AsmPrinter
175+
LLVMX86Info
176+
LLVMObjCARCOpts
177+
LLVMScalarOpts
178+
LLVMX86Utils
179+
LLVMTransformUtils
180+
LLVMAnalysis
181+
LLVMTarget
182+
LLVMCore
183+
LLVMMC
184+
LLVMObject
185+
LLVMMCDisassembler
186+
LLVMProfileData
187+
LLVMDebugInfoCodeView
188+
LLVMPasses
189+
LLVMLinker
190+
LLVMInstCombine
191+
LLVMSupport
192+
)
193+
194+
if(MSVC)
195+
set(DEBUG_DIR "Debug/")
196+
set(RELEASE_DIR "Release/")
197+
endif()
198+
199+
foreach(LLVM_LIB ${LLVM_LIB_LIST})
200+
target_link_libraries(llvm INTERFACE debug ${binary_dir}/${DEBUG_DIR}lib/${CMAKE_FIND_LIBRARY_PREFIXES}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
201+
target_link_libraries(llvm INTERFACE optimized ${binary_dir}/${RELEASE_DIR}lib/${CMAKE_FIND_LIBRARY_PREFIXES}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
202+
endforeach(LLVM_LIB)
203+
204+
if(CMAKE_THREAD_LIBS_INIT)
205+
target_link_libraries(llvm INTERFACE debug ${CMAKE_THREAD_LIBS_INIT})
206+
target_link_libraries(llvm INTERFACE optimized ${CMAKE_THREAD_LIBS_INIT})
207+
endif()
208+
209+
if(UNIX)
210+
target_link_libraries(llvm INTERFACE debug ${ZLIB_LIBRARIES} rt dl tinfo)
211+
target_link_libraries(llvm INTERFACE optimized ${ZLIB_LIBRARIES} rt dl tinfo)
212+
endif()
213+
214+
# Set include directories.
215+
ExternalProject_Get_Property(llvm-project source_dir)
216+
target_include_directories(llvm SYSTEM INTERFACE ${source_dir}/include)
217+
target_include_directories(llvm SYSTEM INTERFACE ${binary_dir}/include)

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# LLVM
2+
3+
A clone of [LLVM](https://llvm.org/) 3.9.1 modified for use in [RetDec](https://github.com/avast-tl/retdec) and associated tools.
4+
5+
**Warning: LLVM in this repository was modified and does not behave the same as the vanilla version!**
6+
7+
## Use
8+
9+
A single target named `llvm` is exposed. It can be used as follows:
10+
```cmake
11+
target_link_libraries(project-that-needs-llvm llvm)
12+
```
13+
14+
## Requirements
15+
16+
* A compiler supporting C++14
17+
* On Windows, only Microsoft Visual C++ is supported (version >= Visual Studio 2015).
18+
* CMake (version >= 3.6)
19+
20+
## License
21+
22+
Copyright (c) 2003-2016 University of Illinois at Urbana-Champaign. Licensed under the University of Illinois/NCSA Open Source License. See the `src/LICENSE.txt` file for more details.
23+
24+
## Contributing
25+
26+
In order to improve the decompilation quality, it is sometimes needed to modify LLVM libraries used by the RetDec decompiler. Any such modification must be consulted with RetDec developers. All modifications must be delimited and marked with keywords `RetDec` or `decompiler` so that it is possible to migrate them to new LLVM sources when the LLVM version is upgraded. When modifying LLVM source code, use the same coding conventions as LLVM uses.

src/.arcconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"project_id" : "llvm",
3+
"conduit_uri" : "https://reviews.llvm.org/"
4+
}

src/.clang-format

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: LLVM
2+

src/.clang-tidy

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming'
2+
CheckOptions:
3+
- key: readability-identifier-naming.ClassCase
4+
value: CamelCase
5+
- key: readability-identifier-naming.EnumCase
6+
value: CamelCase
7+
- key: readability-identifier-naming.FunctionCase
8+
value: lowerCase
9+
- key: readability-identifier-naming.UnionCase
10+
value: CamelCase
11+
- key: readability-identifier-naming.VariableCase
12+
value: CamelCase
13+

src/.gitignore

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#==============================================================================#
2+
# This file specifies intentionally untracked files that git should ignore.
3+
# See: http://www.kernel.org/pub/software/scm/git/docs/gitignore.html
4+
#
5+
# This file is intentionally different from the output of `git svn show-ignore`,
6+
# as most of those are useless.
7+
#==============================================================================#
8+
9+
#==============================================================================#
10+
# File extensions to be ignored anywhere in the tree.
11+
#==============================================================================#
12+
# Temp files created by most text editors.
13+
*~
14+
# Merge files created by git.
15+
*.orig
16+
# Byte compiled python modules.
17+
*.pyc
18+
# vim swap files
19+
.*.sw?
20+
.sw?
21+
#OS X specific files.
22+
.DS_store
23+
24+
#==============================================================================#
25+
# Explicit files to ignore (only matches one).
26+
#==============================================================================#
27+
# Various tag programs
28+
/tags
29+
/TAGS
30+
/GPATH
31+
/GRTAGS
32+
/GSYMS
33+
/GTAGS
34+
.gitusers
35+
autom4te.cache
36+
cscope.files
37+
cscope.out
38+
autoconf/aclocal.m4
39+
autoconf/autom4te.cache
40+
/compile_commands.json
41+
42+
#==============================================================================#
43+
# Directories to ignore (do not add trailing '/'s, they skip symlinks).
44+
#==============================================================================#
45+
# External projects that are tracked independently.
46+
projects/*
47+
!projects/*.*
48+
!projects/Makefile
49+
runtimes/*
50+
!runtimes/*.*
51+
# Clang, which is tracked independently.
52+
tools/clang
53+
# LLDB, which is tracked independently.
54+
tools/lldb
55+
# lld, which is tracked independently.
56+
tools/lld
57+
# llgo, which is tracked independently.
58+
tools/llgo
59+
# Polly, which is tracked independently.
60+
tools/polly
61+
# Sphinx build tree, if building in-source dir.
62+
docs/_build
63+
64+
#==============================================================================#
65+
# Files created in tree by the Go bindings.
66+
#==============================================================================#
67+
bindings/go/llvm/llvm_config.go
68+
bindings/go/llvm/workdir

0 commit comments

Comments
 (0)