nixos/cc-wrapper: Fix bug if dynamicLinker not found

If a dynamic linker for target is not found the generated script fails
due to unbound variable error (due to "set -u"). Correct by specifying
default value with dynamicLinker:- and not generating ldflagsBefore if
no linker is found.

This problem was found when cross compiling to mingw32 targets
This commit is contained in:
Bojan Nikolic 2017-11-03 21:36:43 +00:00
parent 21806cfb83
commit 3e9daece1d

View File

@ -286,7 +286,7 @@ stdenv.mkDerivation {
*) echo "Multiple dynamic linkers found for platform '${targetPlatform.config}'." >&2;;
esac
if [ -n "$dynamicLinker" ]; then
if [ -n "''${dynamicLinker:-}" ]; then
echo $dynamicLinker > $out/nix-support/dynamic-linker
'' + (if targetPlatform.isDarwin then ''
@ -296,7 +296,9 @@ stdenv.mkDerivation {
echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
fi
local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
if [ -n "''${dynamicLinker:-}" ]; then
local ldflagsBefore=(-dynamic-linker "$dynamicLinker")
fi
'') + ''
fi