diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2019-09-06 02:59:02 +0200 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2019-09-06 07:53:10 +0100 |
commit | 4e5b7557ea50bc7e6b037e67ac222fb65766646d (patch) | |
tree | e0078d656b52a8e56ad1c5b228aa429d9f2206b0 | |
parent | gcc-config: change comment to clarify why env-udate is still useful (diff) | |
download | gcc-config-4e5b7557ea50bc7e6b037e67ac222fb65766646d.tar.gz gcc-config-4e5b7557ea50bc7e6b037e67ac222fb65766646d.tar.bz2 gcc-config-4e5b7557ea50bc7e6b037e67ac222fb65766646d.zip |
gcc-config: Use findmnt for mountpoint check when available.
Closes: https://bugs.gentoo.org/693588
Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rwxr-xr-x | gcc-config | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -145,6 +145,37 @@ is_cross_compiler() { [[ ${CC_COMP/${CHOST}} == ${CC_COMP} ]] } +is_same_mountpoint() { + local file1=$1 file2=$2 + + if type -P findmnt > /dev/null ; then + local file1_mountpoint=$(findmnt -n -o TARGET -T "${file1}") + local file2_mountpoint=$(findmnt -n -o TARGET -T "${file2}") + + [[ ${file1_mountpoint} == ${file2_mountpoint} ]] + return + else + local file1_check_file file2_check_file result + if [[ -d ${file1} ]] ; then + file1_check_file=${file1}/.gcc.config.mountpoint_check_file1.$$ + else + file1_check_file=${file1%/*}/.gcc.config.mountpoint_check_file1.$$ + fi + if [[ -d ${file2} ]] ; then + file2_check_file=${file2}/.gcc.config.mountpoint_check_file2.$$ + else + file2_check_file=${file2%/*}/.gcc.config.mountpoint_check_file2.$$ + fi + + rm -f "${file1_check_file}" "${file2_check_file}" + touch "${file1_check_file}" + ln "${file1_check_file}" "${file2_check_file}" 2> /dev/null + result=$? + rm -f "${file1_check_file}" "${file2_check_file}" + return ${result} + fi +} + # Usage: atomic_ln <source file> <destination dir> <destination file name> atomic_ln() { local src=$1 dst=$2 dstfile=$3 tmp @@ -277,13 +308,11 @@ handle_split_usr() { # We use the same ordering logic as mentioned in the MY_LDPATH setup. # We get the libs from the latest version available. local LDPATH - eval $(grep -h '^LDPATH=' "${GCC_ENV_D}"/${CHOST}-* | tail -1) LDPATH=${LDPATH%%:*} - # If /usr isn't a sep mount, then don't bother with linking stuff. - if ln "${ROOT}/${LDPATH}/libgcc.a" "${EROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then - rm -f "${EROOT}"/lib/.gcc.config.$$ + # If GCC directory is not in separate mountpoint than /lib, then do not bother with copying libraries to /lib. + if is_same_mountpoint "${EROOT}/lib" "${ROOT}/${LDPATH}" ; then local lib old_libs=0 saved_nullglob=$(shopt -p nullglob) shopt -s nullglob for lib in "${EROOT}"/lib*/libgcc_s{.so*,*dylib} "${EROOT}"/lib*/libunwind.so.7* ; do |