-g and compiling via assembly fails

Bug #240884 reported by Iain Lane
2
Affects Status Importance Assigned to Milestone
binutils
Fix Released
Medium
binutils (Ubuntu)
Fix Released
Low
Unassigned
gcc-4.3 (Debian)
Fix Released
Unknown

Bug Description

Binary package hint: gcc-4.3

When attempting to merge the darcs package from Debian, I stumbled across the following bug in gcc-4.3.

A similar bug is reported on the BTS as debian bug #481592. There it only affects the IA64 architecture, but in Intrepid I'm seeing it on amd64, i386 and lpia.

Test case and error taken from the above bug:

echo -e '#include "test2.h"\nint main (int argc, char** argv) {callme(); return 1;}' > test2.c
echo 'int callme() {}' > test2.h
gcc -S -g test2.c -o test2.s; gcc test2.s -o test2 -g

Results in the error:

gcc -S -g test2.c -o test2.s; gcc test2.s -o test2 -g
test2.s: Assembler messages:
test2.s:31: Error: file number 2 already allocated

Failed build logs for darcs in my PPA:
amd64 - https://launchpad.net/~laney/+archive/+build/641764
i386 - https://launchpad.net/~laney/+archive/+build/641765
lpia - https://launchpad.net/~laney/+archive/+build/641766

Thanks.

Changed in gcc-4.3:
status: Unknown → New
Matthias Klose (doko)
Changed in binutils:
status: New → Confirmed
Revision history for this message
In , Matthias Klose (doko) wrote :

seen with current trunk, not with the 2.18 branch, testcase taken from the darcs
configury.

echo -e '#include "test2.h"\nint main (int argc, char** argv) {callme(); return
1;}' > test2.c
echo 'int callme() {}' > test2.h
gcc -S -g test2.c -o test2.s; gcc test2.s -o test2 -g
test2.s: Assembler messages:
test2.s:31: Error: file number 2 already allocated

omitting the -g for the linking avoids the error.

Changed in binutils:
status: Unknown → Confirmed
Revision history for this message
In , Alan Modra (amodra-gmail) wrote :

target? gcc version? Really, for assembler errors, you ought to give us the
assembler input, removing the dependency on gcc.

Revision history for this message
In , Matthias Klose (doko) wrote :

Created attachment 2783
testcase (.s file generated by GCC-4.3.1)

this is on i386-linux-gnu, built with GCC-4.3.1 release.

Revision history for this message
In , Matthias Klose (doko) wrote :

Created attachment 2784
testcase (.s file for ia64, generated by GCC-4.3.1)

on ia64-linux-gnu the testcase fails with both 2.18 branch and the trunk.

Revision history for this message
In , Alan Modra (amodra-gmail) wrote :

Actually, I should have recognized the problem just from the description.
Asking the assembler to generate dwarf debug info, when the file already has
debug info generated by the compiler, is just one of those things you should not
do. Of course, the assembler ought to give a better error message..

You see, the compiler emits file and line number info referring to the C (or
other language) source file and line numbers, while "as -g" emits file and line
number info for the assembly file. Having both sets of debug info doesn't make
much sense, since they give contradictory information.

Revision history for this message
Matthias Klose (doko) wrote :

see the comment from upstream in http://sourceware.org/bugzilla/show_bug.cgi?id=6656#c4

so avoid using -g for both invocations.

Changed in binutils:
importance: Undecided → Low
Revision history for this message
In , Hjl-tools (hjl-tools) wrote :

Alan is correct. You shouldn't use "gcc -g" on assembly code which
already has debug info.

Changed in binutils:
status: Confirmed → Invalid
Revision history for this message
Iain Lane (laney) wrote :

Invalidating per upstream's and Matthias's comments. Thanks for your time.

Changed in binutils:
status: Confirmed → Invalid
Revision history for this message
In , Alan Modra (amodra-gmail) wrote :

Fixing.

Revision history for this message
In , Alan Modra (amodra-gmail) wrote :
Changed in binutils:
status: Invalid → Fix Released
Matthias Klose (doko)
Changed in binutils:
status: Invalid → In Progress
Changed in gcc-4.3:
status: New → Confirmed
Revision history for this message
Iain Lane (laney) wrote :

Wicked, darcs now builds without changes to CFLAGS. Nice work!

Changed in binutils:
status: In Progress → Fix Released
Changed in binutils:
importance: Unknown → Medium
Changed in gcc-4.3 (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.