Repository navigation
Description
This issue was originally created at: 2016-05-18 05:05:15.
This issue was reported by: calmer.
calmer said at 2016-05-18 05:05:15
On Windows when using SCons in interactive mode for incrementally building a target then the build step sporadically fails, because SCons doesn't pass the source files to be compiled to the compiler any more.
I've managed to reproduce the bug in a standalone test setup. I'll attach a zip file and log file of the bug reproduction.
The bug triggers only if the target is already built when --interactive mode is entered. Then after cleaning the target and trying to rebuild it, it will fail.
Steps to reproduce:
- run
scons mylibin the test buildsystem - run
scons --interactive, then in the interactive shell:- run
clean mylib - run
build mylib
- run
--> The bug should be triggered, the compiler stating "missing source file name".
This was reproduced using scons 2.5.0. But is also happens in older versions (tested with 2.3.0, too). I've used Windows 7 with Visual Studio 2015 to trigger this. But it also happened with Visual Studio 2012.
It seems to me that in the bug situation the construction variable CHANGED_SOURCES is not correctly refreshed. In Executor.py, Executor.get_lvars(), for example, there is some kind of caching mechanism that returns an empty CHANGED_SOURCES in case of the bug. But that is just a shot in the dark of mine.
calmer said at 2016-05-18 05:06:27 Created an attachment (id=967)
scons setup for triggering the bug
calmer said at 2016-05-18 05:08:05 Created an attachment (id=968)
Console output when reproducing the bug
Votes for this issue: 2.
calmer attached scons_bug.zip at 2016-05-18 05:06:27.
scons setup for triggering the bug
calmer attached bug_session.txt at 2016-05-18 05:08:05.
Console output when reproducing the bug
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
peterphonic commentedon Jul 25, 2018
Bug still present with this configuration :
mwichmann commentedon Jan 29, 2025
I just tried this on my Windows system, and confirm the same failure ("missing source filename") still occurs. Details: SCons git master (4.8.1 + changes since), python 3.13.1, Windows 11, Visual Studio 2022).
The
SConstructfrom the included reproducer specifiedMSVC_VERSION=14.0which I got rid of since that system has 14.3, 14.2 and 14.1 installed but not 14.0.mwichmann commentedon Jan 31, 2025
It was observed on Discord that the difference between Windows/msvc (that sees this problem) and basically all other platform/compiler combos is that on Windows (a)
$TEMPFILEis used, and (b)$CHANGED_SOURCESis used instead of$SOURCES, to support batch mode. The latter appears to be the culprit, as surmised in the original posting. TheExecutorclass methods_get_changed_sourcesand_get_changed_targets, as well asget_lvars, use a kind of memoization, for example_get_changed_sourceslooks like:So if the first thing through in interactive mode is to clean, and
_changed_sources_listends up empty as it seems to, that's saved and returned for subsequent operations, without re-callingself._get_changes()to rescan.There are steps otherwise taken in interactive mode to clear some things out so that stuff is not remembered when not appropriate; perhaps this was something else that needed clearing (at the moment, not sure what that would look like).
mwichmann commentedon Jan 31, 2025
A few further notes - there is some "information clearing" in interactive mode, the memo dictionary is dropped after each op to avoid remembering too much stuff between "independent" operations within a single scons invocation. However, the four attributes
_changed_sources_list._changed_targets_list._unchanged_sources_listand_unchanged_targets_listare just set directly as attributes in the instance (for which there might be reasons - not fully investigated yet), not in the memo dict, so they don't get cleared by this step. Adding an experimentaldelof the_changed_sources_listin the same clean function seems to clear up the reported problem. Whether that's a viable solution, or whether it's appropriate to move these four (or maybe just the one) into the memo dict is also unknown at this point.mwichmann commentedon Feb 2, 2025
After more conversation with @bdbaddog, here's a patch to
Executor.pythat moves the four lists of sources/targets from executor attributes to entries in the executor's memo dict, which is already cleared in the appropriate circumstances in interactive mode. All four of the functions now use an executor memo attribute, all four are set by the_get_changesmethod, whichever one of those functions that fires first will thus trigger the setup and the other three will get the memoized attribute to avoid_get_changesbeing re-called.Okay, github refuses to let me attach that file ("failed uploading"). Looking for solutions...
mwichmann commentedon Feb 2, 2025
simpkins commentedon Feb 25, 2025
Yeah, I spent a little bit of time poking around at this, and your patch looks like the correct fix to me.
Note that the
CHANGED_SOURCEScomputed in_get_changes()only appears to be used sometimes.I was testing printing out the return values whenever
scons_subst_list("${CXXCOM}")is called, and in interactive mode it gets the correct sources list when initially scanning dependencies, and only gets the wrong value later when actually executing the action.When scanning deps it appears to be getting the
CHANGED_SOURCESvalue from this code here:scons/SCons/Subst.py
Lines 316 to 321 in de74f54
WIP: Interactive mode batch + src/tgt clearing
Interactive mode batch + src/tgt clearing
Interactive mode batch + src/tgt clearing