Dear Devs,
I stumbled upon a rather rare case where Make produces a false error with the 
--dry-run switch. I've attached a sample Makefile for reproduction.

The output of make main_target with this file is the following:
$ make main_target
mkdir logs
make external_target | tee logs/external_task.log
make[1]: Entering directory '/tmp/21176961.tmpdir/bugrepro'
This could be in a separate file somewhere
make[1]: Leaving directory '/tmp/21176961.tmpdir/bugrepro'

Nothing interesting there. But with the -n or --dry-run switch I get:
$ make main_target -n
mkdir logs
make external_target | tee logs/external_task.log
tee: logs/external_task.log: No such file or directory
make[1]: Entering directory '/tmp/21176961.tmpdir/bugrepro'
echo "This could be in a separate file somewhere"
make[1]: Leaving directory '/tmp/21176961.tmpdir/bugrepro'
make: *** [Makefile:11: main_target] Error 1

I get that the sub-make invocation gets executed with the switch passed to it 
as well, and that is correct functionality. But then the statement after the 
pipe also gets executed and throws an error about the missing log directory due 
to the prerequisite target not having been run. This causes false failures in 
release checks that use the --dry-run option of Make.

This behavior is the same in both versions of GNU make that I have access to on 
the production system I'm using, 3.82 and 4.3
$ uname -r
3.10.0-693.21.1.el7.x86_64
$ make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
# (...) Loading other version
$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

Attachment: Makefile
Description: Makefile

Reply via email to