cc/gcc: Create liblto_plugin symbolic link with correct extension

Previously, cc/gcc.sh assumed that liblto_plugin would always be
installed with the ".so" file extension. However, this assumption is
incorrect when the host machine is Windows (".dll") or MacOS (".dylib").

This patch corrects this issue by probing the file extension in similar
fashion to the way adjacent code determines the file extension of
executable binaries.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
This commit is contained in:
Joel Holdsworth 2022-02-24 15:33:06 +00:00 committed by Chris Packham
parent d10a4318ac
commit fd694dde63

View File

@ -718,8 +718,12 @@ do_gcc_core_backend() {
# If binutils want the LTO plugin, point them to it
if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then
local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" )
CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \
"${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so"
local plugins_dir="libexec/gcc/${CT_TARGET}/${gcc_version}"
file="$( ls -1 "${CT_PREFIX_DIR}/${plugins_dir}/liblto_plugin."* 2>/dev/null | \
sort | head -n1 || true )"
[ -z "${file}" ] && ext="" || ext=".${file##*.}"
CT_DoExecLog ALL ln -sfv "../../${plugins_dir}/liblto_plugin${ext}" \
"${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin${ext}"
fi
}
@ -1269,7 +1273,11 @@ do_gcc_backend() {
# If binutils want the LTO plugin, point them to it
if [ -d "${CT_PREFIX_DIR}/lib/bfd-plugins" -a "${build_step}" = "gcc_host" ]; then
local gcc_version=$(cat "${CT_SRC_DIR}/gcc/gcc/BASE-VER" )
CT_DoExecLog ALL ln -sfv "../../libexec/gcc/${CT_TARGET}/${gcc_version}/liblto_plugin.so" \
"${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin.so"
local plugins_dir="libexec/gcc/${CT_TARGET}/${gcc_version}"
file="$( ls -1 "${CT_PREFIX_DIR}/${plugins_dir}/liblto_plugin."* 2>/dev/null | \
sort | head -n1 || true )"
[ -z "${file}" ] && ext="" || ext=".${file##*.}"
CT_DoExecLog ALL ln -sfv "../../${plugins_dir}/liblto_plugin${ext}" \
"${CT_PREFIX_DIR}/lib/bfd-plugins/liblto_plugin${ext}"
fi
}