Last active
March 13, 2016 19:09
-
-
Save rindeal/8981858741dc50b5de18 to your computer and use it in GitHub Desktop.
ar/nm/ranlib wrapper for LTO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DEBUG=0 | |
[ "${DEBUG}" -eq 1 ] && set -x | |
CC=${CC:-"/usr/bin/gcc"} | |
lto_wrapper="$( $CC -v 2>&1 | /bin/awk -F= '/COLLECT_LTO_WRAPPER/{print $2}' )" | |
plugin_dir="${lto_wrapper%/*}" | |
util="${0##*/}" | |
# ar requires cmd to be before --plugin | |
cmd="" | |
if [ "x${util%ar}" != "x${util}" ]; then | |
cmd="$1" | |
shift | |
fi | |
run() { | |
if [ "${DEBUG}" -eq 1 ] ;then | |
for p in "${@}" ;do | |
printf "'%s' " "$p" >> /tmp/lto_wrapper.log | |
done | |
echo "" >> /tmp/lto_wrapper.log | |
fi | |
"$@" | |
} | |
run /usr/bin/$util $cmd --plugin "${plugin_dir}/liblto_plugin.so" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment