From 9172c1eee2e376ef9070d1db0586471c52397242 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 31 Oct 2018 14:26:54 -0500 Subject: [PATCH] setup.sh: avoid running the same hook twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In strictDeps=false, we don’t want the same package hook to be run twice, otherwise we get duplicates in some flags. Fixes #41340 --- pkgs/stdenv/generic/setup.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 8af369b1d17d..7e55f0db2aac 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -562,6 +562,10 @@ _addToEnv() { (( "$depHostOffset" <= "$depTargetOffset" )) || continue local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]" if [[ -z "${strictDeps-}" ]]; then + + # Keep track of which packages we have visited before. + local visitedPkgs="" + # Apply environment hooks to all packages during native # compilation to ease the transition. # @@ -574,7 +578,11 @@ _addToEnv() { ${pkgsHostTarget+"${pkgsHostTarget[@]}"} \ ${pkgsTargetTarget+"${pkgsTargetTarget[@]}"} do + if [[ "$visitedPkgs" = *"$pkg"* ]]; then + continue + fi runHook "${!hookRef}" "$pkg" + visitedPkgs+=" $pkg" done else local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"