mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-06 00:06:42 +08:00
88c07c6552
Most of the patches are copied over from GCC 8.3. The following patches are backported from the GCC 9.X development branch: toolchain/gcc/patches/9.1.0/970-recompute-dom-fast-queries-before-vn.patch toolchain/gcc/patches/9.1.0/975-g++-ICE-with-generic-lambda.patch The specs file changed with gcc 9, now it contains "%@{L*}" instead of "%{L*}" in older GCC versions. Signed-off-by: Joseph Benden <joe@benden.us>
91 lines
1.7 KiB
Bash
Executable File
91 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
DIR="$1"
|
|
|
|
if [ -d "$DIR" ]; then
|
|
DIR="$(cd "$DIR"; pwd)"
|
|
else
|
|
echo "Usage: $0 toolchain-dir"
|
|
exit 1
|
|
fi
|
|
|
|
echo -n "Locating cpp ... "
|
|
for bin in bin usr/bin usr/local/bin; do
|
|
for cmd in "$DIR/$bin/"*-cpp; do
|
|
if [ -x "$cmd" ]; then
|
|
echo "$cmd"
|
|
CPP="$cmd"
|
|
break
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ ! -x "$CPP" ]; then
|
|
echo "Can't locate a cpp executable in '$DIR' !"
|
|
exit 1
|
|
fi
|
|
|
|
patch_specs() {
|
|
local found=0
|
|
|
|
for lib in $(STAGING_DIR="$DIR" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do
|
|
if [ -d "$lib" ]; then
|
|
grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs"
|
|
if [ $found -lt 1 ]; then
|
|
echo -n "Patching specs ... "
|
|
STAGING_DIR="$DIR" "$CPP" -dumpspecs | awk '
|
|
mode ~ "link" {
|
|
sub(/(%@?\{L.\})/, "& -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)")
|
|
}
|
|
mode ~ "cpp" {
|
|
$0 = $0 " -idirafter %:getenv(STAGING_DIR /usr/include)"
|
|
}
|
|
{
|
|
print $0
|
|
mode = ""
|
|
}
|
|
/^\*cpp:/ {
|
|
mode = "cpp"
|
|
}
|
|
/^\*link.*:/ {
|
|
mode = "link"
|
|
}
|
|
' > "$lib/specs"
|
|
echo "ok"
|
|
found=1
|
|
fi
|
|
fi
|
|
done
|
|
|
|
[ $found -gt 0 ]
|
|
return $?
|
|
}
|
|
|
|
|
|
VERSION="$(STAGING_DIR="$DIR" "$CPP" --version | sed -ne 's/^.* (.*) //; s/ .*$//; 1p')"
|
|
VERSION="${VERSION:-unknown}"
|
|
|
|
case "${VERSION##* }" in
|
|
2.*|3.*|4.0.*|4.1.*|4.2.*)
|
|
echo "The compiler version does not support getenv() in spec files."
|
|
echo -n "Wrapping binaries instead ... "
|
|
|
|
if "${0%/*}/ext-toolchain.sh" --toolchain "$DIR" --wrap "${CPP%/*}"; then
|
|
echo "ok"
|
|
exit 0
|
|
else
|
|
echo "failed"
|
|
exit $?
|
|
fi
|
|
;;
|
|
*)
|
|
if patch_specs; then
|
|
echo "Toolchain successfully patched."
|
|
exit 0
|
|
else
|
|
echo "Failed to locate library directory!"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|