2016-10-01 09:17:30 +00:00
|
|
|
#!@shell@
|
2017-08-02 16:48:51 +00:00
|
|
|
set -eu -o pipefail
|
|
|
|
shopt -s nullglob
|
2013-02-23 13:59:59 +00:00
|
|
|
|
2017-09-20 15:35:58 +00:00
|
|
|
if (( "${NIX_DEBUG:-0}" >= 7 )); then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2017-08-02 16:48:51 +00:00
|
|
|
declare -a args=("$@")
|
2013-02-23 13:59:59 +00: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 16:48:51 +00:00
|
|
|
declare -a argsBefore=(-z ignore) argsAfter=()
|
2013-02-23 13:59:59 +00: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 16:48:51 +00:00
|
|
|
while (( $# )); do
|
2013-02-23 13:59:59 +00:00
|
|
|
case "${args[$i]}" in
|
2017-08-02 16:48:51 +00:00
|
|
|
-L) argsBefore+=("$1" "$2"); shift ;;
|
|
|
|
-L?*) argsBefore+=("$1") ;;
|
|
|
|
*) argsAfter+=("$1") ;;
|
2013-02-23 13:59:59 +00:00
|
|
|
esac
|
2017-08-02 16:48:51 +00:00
|
|
|
shift
|
2013-02-23 13:59:59 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Trace:
|
|
|
|
set -x
|
2017-08-02 16:48:51 +00:00
|
|
|
exec "@ld@" "${argsBefore[@]}" "${argsAfter[@]}"
|