diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 74bcc4a3674855ca2a4879b96fe0a9413f98fb35..82c55a70e1f22972dbb75d9cda16fd254ef0bb5e 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -197,8 +197,10 @@ ifneq "$$(BINDIST)" "YES"
 # The quadrupled $'s here are because the _<way>_LIB variables aren't
 # necessarily set when this part of the makefile is read
 $1/$2/build/tmp/$$($1_$2_PROG) $1/$2/build/tmp/$$($1_$2_PROG).dll : \
-    $$(foreach dep,$$($1_$2_DEP_COMPONENT_IDS),\
+    $$(foreach dep,$$($1_$2_TRANSITIVE_DEP_COMPONENT_IDS),\
         $$$$($$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB))
+# Workaround: We use TRANSITIVE_DEP_COMPONENT_IDS here as a workaround for
+# Trac #12078.
 
 $1_$2_PROG_NEEDS_C_WRAPPER = NO
 $1_$2_PROG_INPLACE = $$($1_$2_PROG)