2016-10-01 12:17:30 +03:00
|
|
|
#!@shell@
|
2017-08-02 19:48:51 +03:00
|
|
|
set -eu -o pipefail
|
|
|
|
shopt -s nullglob
|
2013-02-23 17:59:59 +04:00
|
|
|
|
2017-08-02 19:48:51 +03:00
|
|
|
declare -a args=("$@")
|
2013-02-23 17:59:59 +04:00
|
|
|
# I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'(
|
|
|
|
# Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3
|
|
|
|
# but still no success.
|
2017-08-02 19:48:51 +03:00
|
|
|
declare -a argsBefore=(-z ignore) argsAfter=()
|
2013-02-23 17:59:59 +04:00
|
|
|
|
|
|
|
# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library.
|
|
|
|
# GNU binutils does not have this problem:
|
|
|
|
# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter
|
2017-08-02 19:48:51 +03:00
|
|
|
while (( $# )); do
|
2013-02-23 17:59:59 +04:00
|
|
|
case "${args[$i]}" in
|
2017-08-02 19:48:51 +03:00
|
|
|
-L) argsBefore+=("$1" "$2"); shift ;;
|
|
|
|
-L?*) argsBefore+=("$1") ;;
|
|
|
|
*) argsAfter+=("$1") ;;
|
2013-02-23 17:59:59 +04:00
|
|
|
esac
|
2017-08-02 19:48:51 +03:00
|
|
|
shift
|
2013-02-23 17:59:59 +04:00
|
|
|
done
|
|
|
|
|
|
|
|
# Trace:
|
|
|
|
set -x
|
2017-08-02 19:48:51 +03:00
|
|
|
exec "@ld@" "${argsBefore[@]}" "${argsAfter[@]}"
|