Skip to content

Commit ee89427

Browse files
committed
Update a post: portable-gcc-toolchain.md
1 parent 0a6fc8c commit ee89427

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

content/post/portable-gcc-toolchain.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ filename="$(basename "${interpreter}")"
420420
dirname="$(dirname "${interpreter}")"
421421
422422
"${toolchain_home}/bin/gcc" -dumpspecs | sed "{
423-
s/:\([^;}:]*\)\/\(${filename/.so*/}\)/:${dirname//\//\\/}\/\2/g
424-
s/collect2/collect2 -rpath ${dirname//\//\\/}/
423+
s|:\([^;}:]*\)/\(${filename/.so*/}\)|:${dirname}/\2|g
424+
s|collect2|collect2 -rpath ${dirname}|
425425
}" >"${toolchain_home}/lib/gcc/$(uname -m)-linux-gnu/specs"
426426
```
427427
@@ -531,9 +531,9 @@ function relocate() {
531531
while read -r file; do
532532
if old_rpath="$(patchelf --print-rpath "${file}" 2>/dev/null)"; then
533533
if ${overwrite}; then
534-
old_rpath="\$ORIGIN:\$ORIGIN/lib:\$ORIGIN/lib64:\$ORIGIN/../lib:\$ORIGIN/../lib64"
534+
old_rpath="\$ORIGIN:\$ORIGIN/lib64:\$ORIGIN/lib:\$ORIGIN/../lib64:\$ORIGIN/../lib"
535535
fi
536-
new_rpath="${old_rpath:+${old_rpath}:}${library_path}"
536+
new_rpath="${library_path}${old_rpath:+:${old_rpath}}"
537537
patchelf --set-rpath "${new_rpath}" "${file}"
538538
if readelf -S "${file}" | grep '.interp' >/dev/null; then
539539
patchelf --set-interpreter "${interpreter}" "${file}"
@@ -550,7 +550,7 @@ bash: ./g++: No such file or directory
550550
$ relocate --overwrite /root/toolchain g++
551551
552552
$ patchelf --print-rpath g++
553-
$ORIGIN:$ORIGIN/lib:$ORIGIN/lib64:$ORIGIN/../lib:$ORIGIN/../lib64:/root/toolchain/lib
553+
/root/toolchain/lib:$ORIGIN:$ORIGIN/lib64:$ORIGIN/lib:$ORIGIN/../lib64:$ORIGIN/../lib
554554
555555
$ patchelf --print-interpreter g++
556556
/root/toolchain/lib/ld-linux-x86-64.so.2
@@ -625,13 +625,13 @@ function configure_toolchain() {
625625
popd >/dev/null || exit
626626
627627
local rpaths=(
628+
"$(pwd)/$(uname -m)-linux-gnu/lib"
629+
"$(dirname "${libc_so}")"
628630
"\$ORIGIN"
629-
"\$ORIGIN/lib"
630631
"\$ORIGIN/lib64"
631-
"\$ORIGIN/../lib"
632+
"\$ORIGIN/lib"
632633
"\$ORIGIN/../lib64"
633-
"$(pwd)/$(uname -m)-linux-gnu/lib"
634-
"$(dirname "${libc_so}")"
634+
"\$ORIGIN/../lib"
635635
)
636636
local rpaths_in_line
637637
rpaths_in_line="$(

0 commit comments

Comments
 (0)