[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/11977] New: ld updates output timestamp even when compiler
From: |
jklowden at schemamania dot org |
Subject: |
[Bug binutils/11977] New: ld updates output timestamp even when compiler fails |
Date: |
3 Sep 2010 17:11:31 -0000 |
When provided with a spurious filename on the command line, ld updates the
output file's timestamp even if compilation fails. Re-invoking make
consequently produces a message that the target is up to date.
Consider two files: ldtest.h (empty, not included), and ldtest.C:
$ cat ldtest.C
int
main( int argc, char *argv[] )
{
return 0;
}
Build it, ruin the source, build it (fails), build it again (succeeds):
$ make ldtest.borked
c++ -o ldtest.borked ldtest.C ldtest.h
$ make break
<ldtest.C sed 's/return/r eturn/' > ldtest.c
mv ldtest.c ldtest.C
$ make ldtest.borked
c++ -o ldtest.borked ldtest.C ldtest.h
ldtest.C: In function int main(int, char**):
ldtest.C:4: error: r was not declared in this scope
ldtest.C:4: error: expected `;' before eturn
make: *** [ldtest.borked] Error 1
$ make ldtest.borked
make: `ldtest.borked' is up to date.
$ stat ldtest.C ldtest.borked | grep -E 'ldtest|Change'
File: `ldtest.C'
Change: 2010-09-03 12:56:18.140130000 -0400
File: `ldtest.borked'
Change: 2010-09-03 12:56:24.168658000 -0400
If ldtest.h is not on the command line, the binary is not updated:
$ make fix
<ldtest.C sed 's/r eturn/return/' > ldtest.c
mv ldtest.c ldtest.C
$ make ldtest
c++ -o ldtest ldtest.C
$ make break
<ldtest.C sed 's/return/r eturn/' > ldtest.c
mv ldtest.c ldtest.C
$ make ldtest
c++ -o ldtest ldtest.C
ldtest.C: In function int main(int, char**):
ldtest.C:4: error: r was not declared in this scope
ldtest.C:4: error: expected `;' before eturn
make: *** [ldtest] Error 1
$ make ldtest
c++ -o ldtest ldtest.C
ldtest.C: In function int main(int, char**):
ldtest.C:4: error: r was not declared in this scope
ldtest.C:4: error: expected `;' before eturn
make: *** [ldtest] Error 1
$ stat ldtest.C ldtest | grep -E 'ldtest|Change'
File: `ldtest.C'
Change: 2010-09-03 13:05:18.469643000 -0400
File: `ldtest'
Change: 2010-09-03 13:05:15.407893000 -0400
$ ld -V
GNU ld version 2.17.50.0.6-6.el5 20061020
Supported emulations:
elf_x86_64
elf_i386
i386linux
While one might argue GIGO, this is an easy mistake to make. I submit ld should
make every effort not to produce invalid binaries, and in this case it discards
information from the compiler.
--
Summary: ld updates output timestamp even when compiler fails
Product: binutils
Version: 2.17
Status: NEW
Severity: normal
Priority: P2
Component: binutils
AssignedTo: unassigned at sources dot redhat dot com
ReportedBy: jklowden at schemamania dot org
CC: bug-binutils at gnu dot org
GCC target triplet: elf_x86_64
http://sourceware.org/bugzilla/show_bug.cgi?id=11977
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
- [Bug binutils/11977] New: ld updates output timestamp even when compiler fails,
jklowden at schemamania dot org <=