forked from gramineproject/gramine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
173 lines (137 loc) · 4.54 KB
/
meson.build
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# Project configuration, options, modules, scripts
#
project(
'gramine',
'c', 'cpp',
version: '1.2-rc1',
license: 'LGPLv3+',
meson_version: '>=0.55',
default_options: [
'c_std=c11',
'cpp_std=c++14',
'werror=true',
],
)
# we need this subdir() early, because we need scripts defined there for setting up global vars
subdir('Scripts')
prefix = get_option('prefix')
pkglibdir = join_paths(get_option('libdir'), meson.project_name())
pkgdatadir = join_paths(get_option('datadir'), meson.project_name())
direct = get_option('direct') == 'enabled'
sgx = get_option('sgx') == 'enabled'
skeleton = get_option('skeleton') == 'enabled'
dcap = get_option('dcap') == 'enabled'
ubsan = get_option('ubsan') == 'enabled'
asan = get_option('asan') == 'enabled'
cc = meson.get_compiler('c')
objcopy = find_program('objcopy')
# TODO: after deprecating 18.04/bionic, update this to import('python')
python3mod = import('python3')
python3 = python3mod.find_python()
python3_platlib = run_command(
python3, get_python_platlib_prog, get_option('prefix')).stdout()
python3_pkgdir = join_paths(python3_platlib, 'graminelibos')
pkgconfig = import('pkgconfig')
add_project_arguments(
'-Wa,--noexecstack',
'-Wall',
'-Wextra',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wwrite-strings',
cc.get_supported_arguments(
'-Wtrampolines',
'-Wnull-dereference',
),
language: 'c')
if get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized'
add_project_arguments('-DDEBUG', language: 'c')
endif
#
# Common checks and flags
#
# Not all compilers support mstack-protector-guard, so use stack protector only if supported.
# Gramine-custom stack protector uses the canary stored in the TCB (same for both in LibOS and PAL)
# at offset 0x8.
if host_machine.cpu_family() == 'x86_64'
cflags_custom_stack_protector = [
'-fstack-protector-strong',
'-mstack-protector-guard=tls',
'-mstack-protector-guard-reg=%gs',
'-mstack-protector-guard-offset=8',
]
else
cflags_custom_stack_protector = [
'-fstack-protector-strong',
]
endif
if not cc.has_multi_arguments(cflags_custom_stack_protector)
cflags_custom_stack_protector = '-fno-stack-protector'
endif
# Don't support b_sanitize: integration with sanitizers in Gramine is tricky and we want more
# control over the exact flags.
if get_option('b_sanitize') != 'none'
error('Please don\'t use the b_sanitize option; use -Dubsan=enabled instead.')
endif
cflags_sanitizers = []
if ubsan
cflags_sanitizers += [
'-fsanitize=undefined',
'-fno-sanitize-recover=undefined',
'-DUBSAN',
]
endif
if asan
if meson.get_compiler('c').get_id() != 'clang' or meson.get_compiler('cpp').get_id() != 'clang'
error('ASan is currently supported only for Clang (CC=clang CXX=clang++)')
endif
asan_shadow_start = '0x18000000000'
cflags_sanitizers += [
'-fsanitize=address',
'-fno-sanitize-link-runtime',
'-mllvm', '-asan-mapping-offset=' + asan_shadow_start,
'-mllvm', '-asan-use-after-return=0',
'-mllvm', '-asan-stack=0',
'-mllvm', '-asan-globals=0',
'-DASAN',
]
endif
#
# Dependencies
#
tomlc99_proj = subproject('tomlc99-208203af46bdbdb29ba199660ed78d09c220b6c5')
tomlc99_dep = tomlc99_proj.get_variable('tomlc99_dep')
tomlc99_inc = tomlc99_proj.get_variable('tomlc99_inc')
tomlc99_incpath = tomlc99_proj.get_variable('tomlc99_incpath')
tomlc99_src = tomlc99_proj.get_variable('tomlc99_src')
uthash_dep = subproject('uthash-2.1.0').get_variable('uthash_dep')
if sgx
threads_dep = dependency('threads')
mbedtls_proj = subproject('mbedtls-mbedtls-2.26.0')
mbedtls_dep = mbedtls_proj.get_variable('mbedtls_dep')
libcurl_dep = dependency('libcurl', version: '>=7.58.0')
cjson_dep = dependency('cjson', required: false)
if not cjson_dep.found()
# on Debian < 11 .pc file is not installed and dependency() fails, so we fallback to
# cc.find_library()
cjson_dep = cc.find_library('cjson', required: false)
endif
if not cjson_dep.found()
# Ubuntu 18.04 does not have cjson at all
cjson_dep = subproject('cJSON-1.7.12').get_variable('cjson_dep')
endif
if dcap
sgx_dcap_quoteverify_dep = cc.find_library('sgx_dcap_quoteverify')
endif
endif
#
# The compilation
#
subdir('common')
subdir('Pal')
subdir('LibOS')
subdir('python')
subdir('tools')
subproject('glibc-2.34')
run_target('clang-format', command: [meson_clang_format_prog])