scons icon indicating copy to clipboard operation
scons copied to clipboard

bad targets are cached with --ignore-errors

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2006-02-09 08:06:03. This issue was reported by: stevenprentice.

stevenprentice said at 2006-02-09 08:06:03

If caching is enabled, SCons will cache a target even if the builder returned a non-zero exit code. This is very problematic because subsequent builds that use that cache will retrieve the cached target and assume everything was fine. The subsequent build doesn't even need to specify --ignore-errors because it doesn't know what happened.

I see two possible solutions:

  1. Don't cache the target if the builder returned a non-zero exit code.
  2. When caching a target, also cache the exit code (and maybe stderr). When retrieving a target from the cache also retrieve the exit code and process it as normal.

Steps to reproduce:

$ scons --version
SCons by Steven Knight et al.:
         script: v0.96.91.D001, 2005/09/08 09:14:36, by knight on roxbury
         engine: v0.96.91.D001, 2005/09/08 09:14:36, by knight on roxbury
Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
 
$ touch input_file
 
$ mkdir cache
 
$ cat - > sconstruct
CacheDir('cache')
Command('output_file', 'input_file', 'cat $SOURCE >
$TARGET ; exit 2')
 
$ scons --ignore-errors
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cat input_file > output_file ; exit 2
scons: *** [output_file] Error 2
scons: done building targets.
 
$ du cache
8       cache/3
12      cache
 
$ scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed output_file
scons: done cleaning targets.
 
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Retrieved `output_file' from cache
scons: done building targets.

Also, from the same setup, another problem:

$ scons -c
...
$ scons --no-cache
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cat input_file > output_file ; exit 2
scons: *** [output_file] Error 2
scons: building terminated because of errors.
 
$ scons --no-cache
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

So, the problem isn't just with caching. This problem seems to be rooted in the fact that we have a builder that generates an output file even if it fails. SCons will cache this output file if caching is enabled and SCons will also consider the target up to date even if it failed to build.

issues@scons said at 2006-02-09 08:06:03

Converted from SourceForge tracker item 1428423

gregnoel said at 2008-08-12 15:35:33

Bug party triage.

gregnoel said at 2008-12-26 13:27:32

Adjust triage of issues.

stevenknight said at 2009-11-10 18:00:19

stevenknight => issues@scons

bdbaddog avatar Jan 02 '18 09:01 bdbaddog

some relationship to #2718 and #4747

mwichmann avatar Oct 27 '25 17:10 mwichmann