blob: 06ca99183e88a65b76f5f6d404c7e40311b34598 (
plain)
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
|
#!/bin/bash
#
# Copyright (C) 2020 by Michael Olbrich <m.olbrich@pengutronix.de>
#
# For further information about the PTXdist project and license conditions
# see the README file.
#
#
# Check for defined icecc
# Check for a usefull icecc version and setup the host environment
#
ptxd_lib_setup_host_icecc() {
local icecc_dir="${sysroot_host}/lib/icecc"
if [ -z "${PTXDIST_ICECC}" ]; then
return
fi
"${wrapper_dir}/real/gcc" --version > "${PTXDIST_TEMPDIR}/host-gcc-version" 2>&1
if [ -d "${icecc_dir}/host" -a -f "${icecc_dir}/host-gcc-version" ]; then
if ! diff -q "${PTXDIST_TEMPDIR}/host-gcc-version" "${icecc_dir}/host-gcc-version" >& /dev/null; then
rm -rf "${icecc_dir}/host" "${icecc_dir}/host-gcc-version" "${icecc_dir}/gcc"
fi
fi
if [ ! -d "${icecc_dir}/host" ]; then
if ! "${PTXDIST_ICECC}" --version | grep -q 'ICECC 1\.'; then
ptxd_bailout "PTXdist only supports icecc 1.x"
fi
mkdir -p "${icecc_dir}/host" &&
(
echo "Creating icecc host environment..."
if file -L "${wrapper_dir}/real/gcc" | grep script; then
ptxd_bailout "'$(readlink "${wrapper_dir}/real/gcc")' must not be a script if icecc is used!"
fi
cd "${icecc_dir}/host"
local -a args
if [ -e "${wrapper_dir}/real/clang" ]; then
args[${#args[@]}]="--clang"
args[${#args[@]}]="${wrapper_dir}/real/clang"
fi
"${PTXDIST_ICECC_CREATE_ENV}" "${args[@]}" --gcc \
"${wrapper_dir}/real/gcc" \
"${wrapper_dir}/real/g++" > "${PTXDIST_TEMPDIR}/icecc.log" 2>&1 || \
{
cat "${PTXDIST_TEMPDIR}/icecc.log"
ptxd_bailout "Failed to create icecc host environment!"
}
ln -s "$(readlink -f "${wrapper_dir}/real/gcc")" "${icecc_dir}/gcc"
) &&
mv "${PTXDIST_TEMPDIR}/host-gcc-version" "${icecc_dir}/"
fi &&
export PTXDIST_ICECC_DIR="${icecc_dir}" &&
if "${PTXDIST_ICECC}" --help | grep -q ICECC_REMOTE_CPP; then
export PTXDIST_ICECC_REMOTE_CPP=1
fi
}
export -f ptxd_lib_setup_host_icecc
#
# Check for defined icecc
# Setup the host environment
#
ptxd_lib_setup_target_icecc() {
local icecc_dir="${sysroot_host}/lib/icecc"
if [ -z "${PTXDIST_ICECC}" ]; then
return
fi
if [ -z "${toolchain}" -o "$(readlink -f "${icecc_dir}/toolchain")" != "${toolchain}" ]; then
rm -rf "${icecc_dir}/target" "${icecc_dir}/target-gcc-version" "${icecc_dir}/toolchain"
fi
"${wrapper_dir}/real/${compiler_prefix}gcc" --version > "${PTXDIST_TEMPDIR}/target-gcc-version" 2>&1
if [ -d "${icecc_dir}/target" -a -f "${icecc_dir}/host-gcc-version" ]; then
if ! diff -q "${PTXDIST_TEMPDIR}/target-gcc-version" "${icecc_dir}/target-gcc-version" >& /dev/null; then
rm -rf "${icecc_dir}/target" "${icecc_dir}/target-gcc-version" "${icecc_dir}/toolchain"
fi
fi
if [ ! -d "${icecc_dir}/target" ]; then
mkdir -p "${icecc_dir}/target" &&
(
echo "Creating icecc target environment..."
cd "${icecc_dir}/target"
local -a args
local gxx
if [ -e "${wrapper_dir}/real/${compiler_prefix}g++" ]; then
gxx="${wrapper_dir}/real/${compiler_prefix}g++"
else
gxx="/bin/false"
fi
if [ -e "${wrapper_dir}/real/${compiler_prefix}clang" ]; then
args[${#args[@]}]="--clang"
args[${#args[@]}]="${wrapper_dir}/real/${compiler_prefix}clang"
fi
"${PTXDIST_ICECC_CREATE_ENV}" "${args[@]}" --gcc \
"${wrapper_dir}/real/${compiler_prefix}gcc" "${gxx}" > \
"${PTXDIST_TEMPDIR}/icecc.log" 2>&1 || \
{
cat "${PTXDIST_TEMPDIR}/icecc.log"
ptxd_bailout "Failed to create icecc target environment!"
}
if [ ${#args[*]} -gt 0 ]; then
tar --strip-components=2 -xf *.tar.gz usr/bin/as &&
./as --verbose --version > env.log 2>&1 &&
${compiler_prefix}as --verbose --version > real.log 2>&1
if ! cmp -s env.log real.log; then
echo "Broken icecc-create-env, disabling icecc clang support!"
rm *.tar.gz
"${PTXDIST_ICECC_CREATE_ENV}" --gcc \
"${wrapper_dir}/real/${compiler_prefix}gcc" "${gxx}" > \
"${PTXDIST_TEMPDIR}/icecc.log" 2>&1 || \
{
cat "${PTXDIST_TEMPDIR}/icecc.log"
ptxd_bailout "Failed to create icecc target environment!"
}
fi
rm as env.log real.log
fi
ln -s "${toolchain}" "${icecc_dir}/toolchain"
) &&
mv "${PTXDIST_TEMPDIR}/target-gcc-version" "${icecc_dir}/"
fi &&
ptxd_get_path "${icecc_dir}/target"/*.tar.gz &&
if tar -tf "${ptxd_reply}" | grep -q clang; then
export PTXDIST_ICECC_CLANG=1
fi
}
export -f ptxd_lib_setup_target_icecc
|