-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile_llvm
More file actions
60 lines (48 loc) · 1.82 KB
/
Makefile_llvm
File metadata and controls
60 lines (48 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# For McMini to check data races concerning shared variables, the target
# program must be specially compiled to use LLVM.
# On most Linux distros, LLVM can be installed by adding the following packages:
# llvm llvm-dev clang
# On Red Hat-based distros, use llvm-devel
#
# To compile the target_file with LLVM, run:
# make -f Makefile_llvm TEST="path/to/target_file"
CLANG := clang
CLANGXX := clang++
OPT := opt
LLVM_CONFIG := llvm-config
PASS_SRC := test/data-races/llvmDataRacePass.cpp
PASS_SO := test/data-races/llvmDataRacePass.so
LIBOBJS := libmcmini.so
TEST ?= test/data-races/simple-data-race
.PHONY: all clean
all: $(PASS_SO)
# Build the LLVM instrumentation pass shared library
$(PASS_SO): $(PASS_SRC)
$(CXX) -g3 -O0 -Iinclude -fPIC \
`$(LLVM_CONFIG) --cxxflags` \
-shared -o $@ $< \
`$(LLVM_CONFIG) --ldflags` \
`$(LLVM_CONFIG) --libs core irreader passes analysis transformutils support` \
`$(LLVM_CONFIG) --system-libs` \
-I`$(LLVM_CONFIG) --includedir`
# Compile .c to LLVM IR (Intermediate Representation)
# *.ll is human readable, compiled with -S flag
# *.bc is "bit code", without the -S flag
%.ll: %.c
$(CLANG) -O0 -g -emit-llvm -c -S $< -o $@
# Instrument bitcode using the LLVM pass
%_mcmini.ll: %.ll $(PASS_SO)
$(OPT) -load-pass-plugin=`pwd`/$(PASS_SO) \
-passes=instrument-mcmini-globals -S $< -o $@
# Link instrumented bitcode to executable
%_mcmini: %_mcmini.ll
$(CLANGXX) $< $(LIBOBJS) -Iinclude -o $@ -lpthread -lrt -lm -ldl
# Build uninstrumented executable directly from source
%_uninstr: %.c
$(CLANG) -O0 -g $< -o $@ -lpthread -lrt -lm -ldl
check: all test/data-races/simple-data-race.c
$(MAKE) -f Makefile_llvm $(addsuffix _mcmini, $(TEST))
./mcmini -m5 ./test/data-races/simple-data-race_mcmini
clean:
rm -f $(PASS_SO)
cd test/data-races && rm -f *.ll *_mcmini.ll *_mcmini *_uninstr