forked from gramineproject/gramine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (121 loc) · 5.81 KB
/
Makefile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Build Redis as follows:
#
# - make -- create non-SGX no-debug-log manifest
# - make SGX=1 -- create SGX no-debug-log manifest
# - make SGX=1 DEBUG=1 -- create SGX debug-log manifest
#
# Any of these invocations clones Redis' git repository and builds Redis in
# default configuration and in the latest-to-date (6.0.5) version.
#
# By default, Redis uses poll/epoll mechanism of Linux. To build Redis with
# select, use `make USE_SELECT=1`. For correct re-builds, always clean up
# Redis source code beforehand via `make distclean`.
#
# Use `make clean` to remove Gramine-generated files and `make distclean` to
# additionally remove the cloned Redis git repository.
################################# CONSTANTS ###################################
# directory with arch-specific libraries, used by Redis
# the below path works for Debian/Ubuntu; for CentOS/RHEL/Fedora, you should
# overwrite this default like this: `ARCH_LIBDIR=/lib64 make`
ARCH_LIBDIR ?= /lib/$(shell $(CC) -dumpmachine)
SRCDIR = src
COMMIT = 6.0.5
TAR_SHA256 = f7ded6c27d48c20bc78e797046c79b6bc411121f0c2d7eead9fea50d6b0b6290
ifeq ($(DEBUG),1)
GRAMINE_LOG_LEVEL = debug
else
GRAMINE_LOG_LEVEL = error
endif
.PHONY: all
all: redis-server redis-server.manifest redis-benchmark
ifeq ($(SGX),1)
all: redis-server.manifest.sgx redis-server.sig redis-benchmark
endif
############################## REDIS EXECUTABLE ###############################
# Redis is built as usual, without any changes to the build process (except to
# test select syscall instead of poll/epoll). The source is downloaded from the
# GitHub repo (6.0.5 tag) and built via `make`. The result of this build process
# is the final executable "src/redis-server".
$(SRCDIR)/Makefile:
../common_tools/download --output redis.tar.gz \
--sha256 $(TAR_SHA256) \
--url https://github.com/antirez/redis/archive/$(COMMIT).tar.gz \
--url https://packages.gramineproject.io/distfiles/redis-$(COMMIT).tar.gz
mkdir $(SRCDIR)
tar -C $(SRCDIR) --strip-components=1 -xf redis.tar.gz
ifeq ($(USE_SELECT),1)
$(SRCDIR)/src/redis-server: $(SRCDIR)/Makefile
sed -i 's|#define HAVE_EPOLL 1|/* no HAVE_EPOLL */|g' src/src/config.h
$(MAKE) -C $(SRCDIR)
else
$(SRCDIR)/src/redis-server: $(SRCDIR)/Makefile
$(MAKE) -C $(SRCDIR)
endif
################################ REDIS MANIFEST ###############################
# The template file is a Jinja2 template and contains almost all necessary
# information to run Redis under Gramine / Gramine-SGX. We create
# redis-server.manifest (to be run under non-SGX Gramine) by replacing variables
# in the template file using the "gramine-manifest" script.
redis-server.manifest: redis-server.manifest.template
gramine-manifest \
-Dlog_level=$(GRAMINE_LOG_LEVEL) \
-Darch_libdir=$(ARCH_LIBDIR) \
$< > $@
# Manifest for Gramine-SGX requires special "gramine-sgx-sign" procedure. This
# procedure measures all Redis trusted files, adds the measurement to the
# resulting manifest.sgx file (among other, less important SGX options) and
# creates redis-server.sig (SIGSTRUCT object).
# Make on Ubuntu <= 20.04 doesn't support "Rules with Grouped Targets" (`&:`),
# see the helloworld example for details on this workaround.
redis-server.sig redis-server.manifest.sgx: sgx_outputs
@:
.INTERMEDIATE: sgx_outputs
sgx_outputs: redis-server.manifest $(SRCDIR)/src/redis-server
gramine-sgx-sign \
--manifest redis-server.manifest \
--output redis-server.manifest.sgx
########################### COPIES OF EXECUTABLES #############################
# Redis build process creates the final executable as src/redis-server. For
# simplicity, copy it into our root directory.
redis-server: $(SRCDIR)/src/redis-server
cp $< $@
redis-benchmark: $(SRCDIR)/src/redis-benchmark
cp $< $@
################################## CLEANUP ####################################
.PHONY: clean
clean:
$(RM) *.token *.sig *.manifest.sgx *.manifest redis-server *.rdb redis-benchmark
.PHONY: distclean
distclean: clean
$(RM) -r $(SRCDIR) redis.tar.gz
eurosys-reproduce-server-%-sgx: export SGX=1
eurosys-reproduce-server-gramine-%: export PATH := $(HOME)/.local/gramine/bin:$(PATH)
eurosys-reproduce-server-gramine-%: export PYTHONPATH := $(HOME)/.local/gramine/lib/python3.10/site-packages:$(PYTHONPATH)
eurosys-reproduce-server-gramine-%: export PKG_CONFIG_PATH := $(HOME)/.local/gramine/lib/x86_64-linux-gnu/pkgconfig:$(PKG_CONFIG_PATH)
eurosys-reproduce-server-gramine-%: export SETTING := Gramine
eurosys-reproduce-server-rakis-%: export PATH := $(HOME)/.local/rakis/bin:$(PATH)
eurosys-reproduce-server-rakis-%: export PYTHONPATH := $(HOME)/.local/rakis/lib/python3.10/site-packages:$(PYTHONPATH)
eurosys-reproduce-server-rakis-%: export PKG_CONFIG_PATH := $(HOME)/.local/rakis/lib/x86_64-linux-gnu/pkgconfig:$(PKG_CONFIG_PATH)
eurosys-reproduce-server-rakis-%: export SETTING := Rakis
eurosys-reproduce-server-native: export NATIVE = 1
eurosys-reproduce-server-native: export PATH := $(HOME)/.local/rakis/bin:$(PATH)
eurosys-reproduce-server-native: export PYTHONPATH := $(HOME)/.local/rakis/lib/python3.10/site-packages:$(PYTHONPATH)
eurosys-reproduce-server-native: export PKG_CONFIG_PATH := $(HOME)/.local/rakis/lib/x86_64-linux-gnu/pkgconfig:$(PKG_CONFIG_PATH)
eurosys-reproduce-server-%: export USE_SELECT = 1
eurosys-reproduce-server-%: export LD_LIBRARY_PATH := $(LIBEVENT_INS)/lib
eurosys-reproduce-server-%: clean
$(MAKE) eurosys-reproduce-run-server
eurosys-reproduce-run-server: all
ifeq ($(NATIVE),1)
@echo "\n******************************************"
@echo "[*] Running redis in NATIVE setting..."
./redis-server
else ifeq ($(SGX),1)
@echo "\n******************************************"
@echo "[*] Running redis in $(SETTING)-SGX setting..."
gramine-sgx ./redis-server
else
@echo "\n******************************************"
@echo "[*] Running redis in $(SETTING)-Direct setting..."
gramine-direct ./redis-server
endif