forked from ClangBuiltLinux/tc-build
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild-toolchain.sh
executable file
·45 lines (36 loc) · 1.17 KB
/
build-toolchain.sh
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
#!/usr/bin/env bash
set -eo pipefail
# Function to show an informational message
function msg() {
echo -e "\e[1;32m$@\e[0m"
}
# Don't touch repo if running on CI
[ -z "$GH_RUN_ID" ] && repo_flag="--shallow-clone" || repo_flag="--no-update"
# Build LLVM
msg "Building LLVM..."
./build-llvm.py \
--clang-vendor "Proton" \
--targets "ARM;AArch64;X86" \
"$repo_flag" \
--pgo kernel-defconfig \
--lto full
# Build binutils
msg "Building binutils..."
./build-binutils.py --targets arm aarch64 x86_64
# Remove unused products
msg "Removing unused products..."
rm -fr install/include
rm -f install/lib/*.a install/lib/*.la
# Strip remaining products
msg "Stripping remaining products..."
for f in $(find install -type f -exec file {} \; | grep 'not stripped' | awk '{print $1}'); do
strip ${f: : -1}
done
# Set executable rpaths so setting LD_LIBRARY_PATH isn't necessary
msg "Setting library load paths for portability..."
for bin in $(find install -mindepth 2 -maxdepth 3 -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do
# Remove last character from file output (':')
bin="${bin: : -1}"
echo "$bin"
patchelf --set-rpath '$ORIGIN/../lib' "$bin"
done