Skip to content

Instantly share code, notes, and snippets.

@rindeal
Last active March 13, 2016 19:09
Show Gist options
  • Save rindeal/8981858741dc50b5de18 to your computer and use it in GitHub Desktop.
Save rindeal/8981858741dc50b5de18 to your computer and use it in GitHub Desktop.
ar/nm/ranlib wrapper for LTO
#!/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