Files
TheRock/third-party/sysdeps/linux/elfutils/patch_install.sh
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

72 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
set -e
PREFIX="${1:?Expected install prefix argument}"
PATCHELF="${PATCHELF:-patchelf}"
# update_library_links
# ---------------------
# Purpose:
# Normalize a shared library so that its real file is named exactly as its ELF SONAME,
# and rename the input file (usually a symlink) to a desired linker name (e.g., libfoo.so).
#
# Synopsis:
# update_library_links <libfile> <linker_name>
#
# Arguments:
# libfile Path to the library file or symlink.
# Example: $PREFIX/lib/librocm_sysdeps_elf.so
# linker_name Desired linker-name filename to exist in the same directory.
# Example: libelf.so
update_library_links() {
local libfile="$1" # e.g. $PREFIX/lib/librocm_sysdeps_elf.so
local linker_name="$2" # e.g. libelf.so
if [ ! -e "$libfile" ]; then
echo "Error: File '$libfile' not found" >&2
return 1
fi
local dir="$(dirname -- "$libfile")"
# Get the soname and realname
local lib_soname="$("$PATCHELF" --print-soname "$libfile" 2>/dev/null || true)"
local realname="$(readlink -f -- "$libfile" 2>/dev/null || true)"
if [[ -z "$lib_soname" || -z "$realname" ]]; then
[[ -z "$lib_soname" ]] && echo "Error: No SONAME found in '$libfile'" >&2
[[ -z "$realname" ]] && echo "Error: readlink -f failed for '$libfile'" >&2
return 1
fi
if [[ "$realname" != "$dir/$lib_soname" ]]; then
# Move the real file to $dir/$lib_soname
mv -v -- "$realname" "$dir/$lib_soname"
pushd "$dir" > /dev/null
ln -sf "$lib_soname" "$linker_name"
popd > /dev/null
rm "$libfile"
else
# Rename symlink in the same directory
mv "$libfile" "$dir/$linker_name"
fi
}
update_library_links "$PREFIX/lib/librocm_sysdeps_elf.so" "libelf.so"
update_library_links "$PREFIX/lib/librocm_sysdeps_asm.so" "libasm.so"
update_library_links "$PREFIX/lib/librocm_sysdeps_dw.so" "libdw.so"
# pc files are not output with a relative prefix. Sed it to relative.
sed -i -E 's|^prefix=.+|prefix=${pcfiledir}/../..|' $PREFIX/lib/pkgconfig/*.pc
# We don't need old v0 compat libs.
rm -f $PREFIX/lib/*-0.so
# We don't want the static libs.
rm $PREFIX/lib/*.a
# We don't need the programs.
rm -Rf $PREFIX/bin