This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 260
/
meson.build
117 lines (94 loc) · 2.85 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
#
# Project configuration, options, modules, scripts
#
project(
'graphene', 'c',
version: '1.2-rc1',
license: 'LGPLv3+',
# DISTRO EOL meson_version
# xenial 2021.04 0.29
# xenial-backports 2021.04 0.40
# bionic 2023.04 0.45
# buster 2022 0.49
# buster-backports 2022 0.52
# focal 2025.04 0.53
#
# https://wiki.ubuntu.com/Releases
# https://wiki.debian.org/DebianReleases#Production_Releases
meson_version: '>=0.45',
default_options: [
'c_std=c11',
'werror=true',
],
)
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'
ubsan = get_option('ubsan') == '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()
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
subdir('Scripts')
#
# Common checks and flags
#
# Not all compilers support mstack-protector-guard, so use stack protector only if supported.
# Graphene-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 Graphene 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
#
# The compilation
#
subdir('common')
subdir('Pal')
subdir('LibOS')
subdir('Runtime')
subdir('python')
run_target('clang-format', command: [meson_clang_format_prog])