Skip to content

Commit

Permalink
fix: add /usr/lib and /usr/include to linker
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Rynhard <[email protected]>
  • Loading branch information
andrewrynhard committed Oct 29, 2019
1 parent 8fdb32d commit d048c99
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/files/adjust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ mv -v /toolchain/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /toolchain/bin/{ld-new,ld}
ln -sv /toolchain/bin/ld /toolchain/$(gcc -dumpmachine)/bin/ld

gcc -dumpspecs | sed -e "s@/toolchain@@g" \
-e '/\*startfile_prefix_spec:/{n;s@.*@/lib/ @}' \
-e '/\*cpp:/{n;s@$@ -isystem /include@}' > `dirname $(gcc --print-libgcc-file-name)`/specs
gcc -dumpspecs | sed -e 's@/toolchain@@g' \
-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
-e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > `dirname $(gcc --print-libgcc-file-name)`/specs

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'
grep -o '/lib.*/crt[1in].*succeeded' dummy.log
grep -B1 '^ /include' dummy.log
ld --verbose | grep 'SEARCH_DIR("/usr/lib"); SEARCH_DIR("/lib");'
grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
grep -B1 '^ /usr/include' dummy.log
grep 'SEARCH.*/lib' dummy.log | sed 's|; |\n|g'
grep "/lib/libc.so succeeded" dummy.log
rm -v dummy.c a.out dummy.log

0 comments on commit d048c99

Please sign in to comment.