Skip to content

Commit 8b85b3a

Browse files
committed
IMPR: adapt build for llvm project
1 parent bb0b5cd commit 8b85b3a

File tree

3 files changed

+62
-32
lines changed

3 files changed

+62
-32
lines changed

AddressInterceptPass/AddressIntercept.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ using namespace adin;
137137

138138
char AddressInterceptor::ID = 0;
139139

140+
#ifdef ADIN_LOAD_MODULE
141+
140142
static RegisterPass<AddressInterceptor> X("adin", "Hello World Pass",
141143
false /* Only looks at CFG */,
142144
false /* Analysis Pass */);
@@ -151,3 +153,6 @@ static RegisterStandardPasses
151153
RegisterMyPass(PassManagerBuilder::EP_EarlyAsPossible,
152154
registerAddressInterceptPass);
153155

156+
#else
157+
158+
#endif

AddressInterceptPass/CMakeLists.txt

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
1-
add_library(AddressInterceptPass MODULE
2-
# List your source files here.
3-
AddressIntercept.cpp
4-
AllocaRecognize
5-
MemoryOperationRecognize
6-
InlineInstrumentation
7-
Logger
8-
)
9-
10-
# Use C++11 to compile your pass (i.e., supply -std=c++11).
11-
target_compile_features(AddressInterceptPass PRIVATE cxx_range_for cxx_auto_type)
12-
13-
# LLVM is (typically) built with no C++ RTTI. We need to match that;
14-
# otherwise, we'll get linker errors about missing RTTI data.
15-
set_target_properties(AddressInterceptPass PROPERTIES
16-
COMPILE_FLAGS "-fno-rtti"
17-
)
18-
19-
# Get proper shared-library behavior (where symbols are not necessarily
20-
# resolved when the shared library is linked) on OS X.
21-
if(APPLE)
1+
if(NOT DEFINED ENV{YOUR_LLVM_PATH})
2+
3+
add_llvm_library( LLVMAddressInterceptor
4+
# List your source files here.
5+
AddressIntercept.cpp
6+
AllocaRecognize.cpp
7+
MemoryOperationRecognize.cpp
8+
InlineInstrumentation.cpp
9+
Logger.cpp
10+
11+
ADDITIONAL_HEADER_DIRS
12+
${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms
13+
14+
DEPENDS
15+
intrinsics_gen
16+
)
17+
18+
else ()
19+
20+
add_library(AddressInterceptPass MODULE
21+
# List your source files here.
22+
AddressIntercept.cpp
23+
AllocaRecognize
24+
MemoryOperationRecognize
25+
InlineInstrumentation
26+
Logger
27+
)
28+
29+
add_definitions(-DADIN_LOAD_MODULE)
30+
31+
# Use C++11 to compile your pass (i.e., supply -std=c++11).
32+
target_compile_features(AddressInterceptPass PRIVATE cxx_range_for cxx_auto_type)
33+
34+
# LLVM is (typically) built with no C++ RTTI. We need to match that;
35+
# otherwise, we'll get linker errors about missing RTTI data.
2236
set_target_properties(AddressInterceptPass PROPERTIES
23-
LINK_FLAGS "-undefined dynamic_lookup"
37+
COMPILE_FLAGS "-fno-rtti"
2438
)
25-
endif(APPLE)
39+
40+
# Get proper shared-library behavior (where symbols are not necessarily
41+
# resolved when the shared library is linked) on OS X.
42+
if(APPLE)
43+
set_target_properties(AddressInterceptPass PROPERTIES
44+
LINK_FLAGS "-undefined dynamic_lookup"
45+
)
46+
endif(APPLE)
47+
48+
endif()

CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
cmake_minimum_required(VERSION 3.4)
22

3-
# we need LLVM_HOME in order not automatically set LLVM_DIR
4-
if(NOT DEFINED LLVM_HOME)
5-
message(FATAL_ERROR "$LLVM_HOME is not defined")
3+
message("YOUR_LLVM_PATH PATH : $ENV{YOUR_LLVM_PATH} ##################################")
4+
5+
# we need YOUR_LLVM_PATH in order not automatically set LLVM_DIR
6+
if(NOT DEFINED ENV{YOUR_LLVM_PATH})
7+
message(AUTHOR_WARNING "ENV{YOUR_LLVM_PATH} is not defined")
8+
message(AUTHOR_WARNING "Pass is built in to llvm project")
69
else ()
7-
set(ENV{LLVM_DIR} $ENV{LLVM_HOME}/lib/cmake/llvm)
10+
set(ENV{LLVM_DIR} $ENV{YOUR_LLVM_PATH}/lib/cmake/llvm)
11+
find_package(LLVM REQUIRED CONFIG)
12+
add_definitions(${LLVM_DEFINITIONS})
13+
include_directories(${LLVM_INCLUDE_DIRS})
14+
link_directories(${LLVM_LIBRARY_DIRS})
815
endif()
916

10-
find_package(LLVM REQUIRED CONFIG)
11-
add_definitions(${LLVM_DEFINITIONS})
12-
include_directories(${LLVM_INCLUDE_DIRS})
13-
link_directories(${LLVM_LIBRARY_DIRS})
14-
1517
add_subdirectory(AddressInterceptPass) # Use your pass name here.

0 commit comments

Comments
 (0)