blob: f066592b34a07e3386fbd348b384a3738ed9c289 (
plain) (
blame)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# Build dependencies
install_build_dependencies_llvm() {
source "${DIR}/common-functions"
# Check if the Ubuntu version is an LTS version - otherwise no cmake version available
if grep -q LTS /etc/os-release; then
with_sudo apt update -y
# Add Kitware's certificate for CMake
dependencies=(
apt-transport-https
ca-certificates
gnupg
lsb-release
software-properties-common
wget
)
with_sudo apt -y --no-install-recommends install "${dependencies[@]}"
wget -O - "https://apt.kitware.com/keys/kitware-archive-latest.asc" 2> /dev/null \
| gpg --dearmor - | with_sudo tee /etc/apt/trusted.gpg.d/kitware.gpg > /dev/null
# Add CMake repository
codename="$(lsb_release --codename --short)"
with_sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ ${codename} main"
fi
with_sudo apt update -y
dependencies=(
ca-certificates
build-essential
autoconf
automake
groff
gcc
g++
python-dev
python3-distutils
make
git # To check out code
zlib1g-dev
cmake
git
)
if [[ "${SANITIZERS[*]}" == "memory" ]]; then
dependencies+=(ninja-build)
fi
#Install essential dependencies
with_sudo apt -y --no-install-recommends install "${dependencies[@]}"
}
install_binary_artifact_llvm() {
# No need to check for optimised, we can build against LLVM with optimised and non-optimised versions
# local enable_optimized=$(to_bool "${ENABLE_OPTIMIZED}")
local enable_debug=$(to_bool "${ENABLE_DEBUG}")
local disable_assertions=$(to_bool "${DISABLE_ASSERTIONS}")
local requires_rtti=$(to_bool "${REQUIRES_RTTI}")
local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
# No support for LLVM packages with debug information, incompatible if requested otherwise
[[ "${enable_debug}" -eq 1 ]] && return 1
# Packages are build with assertions disabled, incompatible if requested otherwise
[[ "${disable_assertions}" -eq 0 ]] && return 1
# Packages are build with RTTI enabled, incompatible if requested otherwise
[[ "${requires_rtti}" -eq 0 ]] && return 1
# Enable/Disable optimized does not matter
source "${DIR}/common-functions"
# Add certificate
with_sudo apt update -y
dependencies=(
ca-certificates
wget
lsb-release
gnupg
)
with_sudo apt -y --no-install-recommends install "${dependencies[@]}"
local version=""
[[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${LLVM_VERSION}"
[[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${LLVM_VERSION_MAJOR}"
# Add LLVM upstream repository if available
codename="$(lsb_release --codename --short)"
if wget -q "https://apt.llvm.org/${codename}/dists/llvm-toolchain-${codename}${version}/"; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| with_sudo apt-key add -
apt_entry="deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}${version} main"
if ! grep -rq "${apt_entry}" /etc/apt; then
echo "${apt_entry}" | with_sudo tee -a /etc/apt/sources.list
with_sudo apt update -y
fi
fi
dependencies=(
"llvm${version}"
"llvm${version}-dev"
"llvm${version}-runtime"
"clang${version}"
)
#Install essential dependencies
with_sudo apt -y --no-install-recommends install "${dependencies[@]}" || return 1
}
check_llvm_config_version() {
local check_mode=1
strict_mode="$1" # if llvm-config should be checked strictly
local lc=""
lc="$2" # path to llvm-config
# If not set return error
[[ -z "${lc}" ]] && return 1
# First check, if the provided llvm-config is a full path
if [[ ! -f "${lc}" ]]; then
# Nothing found, assume it's just the name of the binary in path, find the path
lc=$(which "${lc}")
# If path not found return error
[[ -z "${lc}" ]] && return 1
fi
local version=""
local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
[[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="${LLVM_VERSION}"
[[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="${LLVM_VERSION_MAJOR}"
# Check for llvm-config without suffix but correct version number
[[ $($lc --version) == "${LLVM_VERSION}"* ]] || return 1
# In case correct version numbers are required, return already
[[ "${check_mode}" == "0" ]] && return 0;
local rtti
rtti="$(${lc} --has-rtti)"
local assertion
assertion="$(${lc} --assertion-mode)"
local build_mode
build_mode="$(${lc} --build-mode)"
# Check requested mode with mode of the found item
[[ $(to_bool "${REQUIRES_RTTI}") -eq $(to_bool "${rtti}") ]] || return 1
[[ $(to_bool "${DISABLE_ASSERTIONS}") -ne $(to_bool "${assertion}") ]] || return 1
local shared_mode
shared_mode="$(${lc} --shared-mode)" || return 1
}
# Check if the binary artifact is installed
is_installed_llvm() {
# Check for variables set and not empty
local version=""
local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
[[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="${LLVM_VERSION}"
[[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="${LLVM_VERSION_MAJOR}"
# Check for llvm-config without suffix but correct version number
local lc
# First check with the version-specific number
lc=$(which "llvm-config-${LLVM_VERSION_MAJOR}")
check_llvm_config_version 1 "${lc}" && return 0
# As alternative, try the version-less number
lc=$(which "llvm-config")
check_llvm_config_version 1 "${lc}" && return 0
return 1
}
setup_artifact_variables_llvm() {
# Check for variables set and not empty
local version=""
local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
[[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="${LLVM_VERSION}"
[[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="${LLVM_VERSION_MAJOR}"
local lc=""
# Check for llvm-config without suffix but correct version number
lc=$(which "llvm-config")
local is_ins=$(check_llvm_config_version 1 "${lc}")
if [[ ! "${is_ins}" ]]; then
# Check if llvm-config with the right version exists
lc=$(which "llvm-config-${version}")
is_ins=$(check_llvm_config_version 1 "${lc}") || return 1
fi
LLVM_CONFIG="${lc}"
LLVM_INSTALL="$(${lc} --bindir)"
BITCODE_CC="${LLVM_INSTALL}/clang"
BITCODE_CXX="${LLVM_INSTALL}/clang++"
LLVM_BIN="${LLVM_INSTALL}/bin"
}
get_build_artifacts_llvm() {
is_installed_llvm
[[ $? -ne 0 ]] && return 1
return 0
}
|