Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gcc-config:master commit in: /
Date: Fri, 06 Sep 2019 06:53:44
Message-Id: 1567752790.4e5b7557ea50bc7e6b037e67ac222fb65766646d.slyfox@gentoo
1 commit: 4e5b7557ea50bc7e6b037e67ac222fb65766646d
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Fri Sep 6 00:59:02 2019 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Fri Sep 6 06:53:10 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=4e5b7557
7
8 gcc-config: Use findmnt for mountpoint check when available.
9
10 Closes: https://bugs.gentoo.org/693588
11 Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
12 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
13
14 gcc-config | 37 +++++++++++++++++++++++++++++++++----
15 1 file changed, 33 insertions(+), 4 deletions(-)
16
17 diff --git a/gcc-config b/gcc-config
18 index 9e5abf8..169f8bc 100755
19 --- a/gcc-config
20 +++ b/gcc-config
21 @@ -145,6 +145,37 @@ is_cross_compiler() {
22 [[ ${CC_COMP/${CHOST}} == ${CC_COMP} ]]
23 }
24
25 +is_same_mountpoint() {
26 + local file1=$1 file2=$2
27 +
28 + if type -P findmnt > /dev/null ; then
29 + local file1_mountpoint=$(findmnt -n -o TARGET -T "${file1}")
30 + local file2_mountpoint=$(findmnt -n -o TARGET -T "${file2}")
31 +
32 + [[ ${file1_mountpoint} == ${file2_mountpoint} ]]
33 + return
34 + else
35 + local file1_check_file file2_check_file result
36 + if [[ -d ${file1} ]] ; then
37 + file1_check_file=${file1}/.gcc.config.mountpoint_check_file1.$$
38 + else
39 + file1_check_file=${file1%/*}/.gcc.config.mountpoint_check_file1.$$
40 + fi
41 + if [[ -d ${file2} ]] ; then
42 + file2_check_file=${file2}/.gcc.config.mountpoint_check_file2.$$
43 + else
44 + file2_check_file=${file2%/*}/.gcc.config.mountpoint_check_file2.$$
45 + fi
46 +
47 + rm -f "${file1_check_file}" "${file2_check_file}"
48 + touch "${file1_check_file}"
49 + ln "${file1_check_file}" "${file2_check_file}" 2> /dev/null
50 + result=$?
51 + rm -f "${file1_check_file}" "${file2_check_file}"
52 + return ${result}
53 + fi
54 +}
55 +
56 # Usage: atomic_ln <source file> <destination dir> <destination file name>
57 atomic_ln() {
58 local src=$1 dst=$2 dstfile=$3 tmp
59 @@ -277,13 +308,11 @@ handle_split_usr() {
60 # We use the same ordering logic as mentioned in the MY_LDPATH setup.
61 # We get the libs from the latest version available.
62 local LDPATH
63 -
64 eval $(grep -h '^LDPATH=' "${GCC_ENV_D}"/${CHOST}-* | tail -1)
65 LDPATH=${LDPATH%%:*}
66
67 - # If /usr isn't a sep mount, then don't bother with linking stuff.
68 - if ln "${ROOT}/${LDPATH}/libgcc.a" "${EROOT}"/lib/.gcc.config.$$ 2>/dev/null ; then
69 - rm -f "${EROOT}"/lib/.gcc.config.$$
70 + # If GCC directory is not in separate mountpoint than /lib, then do not bother with copying libraries to /lib.
71 + if is_same_mountpoint "${EROOT}/lib" "${ROOT}/${LDPATH}" ; then
72 local lib old_libs=0 saved_nullglob=$(shopt -p nullglob)
73 shopt -s nullglob
74 for lib in "${EROOT}"/lib*/libgcc_s{.so*,*dylib} "${EROOT}"/lib*/libunwind.so.7* ; do