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