From fd694dde63635183a0496600e40e7930060f1cb0 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 24 Feb 2022 15:33:06 +0000 Subject: [PATCH] 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 --- scripts/build/cc/gcc.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 2b7779a6..e32fcd0f 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -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 }