gcc 4.1.1 broken dwarf2 support?

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

Is gcc-core 4.1.1 broken for dwarf-2 support? I cannot get it to compile with --with-dwarf2 on the configure line. Which is a shame, because I like to debug with avr studio atm.

I have reported a bug on bugzilla, but maybe there is something I am doing wrong? (I am a relative newbie to linux)

binutils 2.17 is installed, my configure for gcc-core is:

../configure --target=avr --prefix=/usr/local/avr --enable-languages=c --with-dwarf2 --with-elf --with-stabs --disable-libssp --disable-libada --disable-nls

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oops, my mistake here, there is already a gcc bug report for this error. Unfortunately I didn't spot it with a search through bugzilla. Hope they're not too mad at me!

But have successfully compiled 4.0.3 avr-gcc with dwarf-2 support, and I'm now just doing some tests to try it out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's a patch for GCC 4.1.0 to address that issue. I believe the same fix should work for 4.1.1, since it's the same error message in both cases.

I'm still wary of it, since the fix seems to have been arbitrarily chosen. But it has passed several users' "works for me" tests, including mine, so I guess it should be fine for experimental users. I still wouldn't use it for production applications though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wouldn't worry using it for production applications,
as the applications itself are not affected by the
(in)correctness of the debugging information.

However, as I only use Unix systems, and GDB has
never been adapted to DWARF-2 on the AVR, stabs
is still the debugging format of choice here, so I don't
care much (and don't have the resources to fix GDB).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'll do a search for that patch then. At the moment, I just want to setup a development envrionment on a dev box. Once I'm more familier with unix, I may swap over.

But as the I'm coming from starting from winavr, I'd rather do the debugging in a familiar environment to make sure the compilers right first. Then I'll move on to debugging on the same box.

I will look more into stabs too. Thanks for the info.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note that debugging on a different platform has some gotchas,
as the path names to the source files recorded in the object
files won't match the other system. However, it should be doable,
it's just that AVR Studio will ask you for any file name it encounters
for where the actual source file is located. It will only ask you once,
but you can always later edit the XML project file for the mapping
if you want.

You can find my version of the patch at
http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/ports/devel/avr-gcc-devel/files/patch-dwarf?rev=1.1&content-type=text/plain

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Joerg you're patch worked fine.

I'm still struggling a little though (blame the newness to linux, and gcc!)

If I create a demo.c file with nothing but a few includes from the standard avr include library then compile with
avr-gcc -g -Os -mmcu=at90s2333 -c demo.c

as in the avrlibc manual, I get an error showing that the avr/io.h file and inttypes.h cannot be found. If I manually add -I/usr/local/avr/include then I get the object file created fine.

However, when I try to create an elf file afterwards, I get the message that the linker cannot find crts2333.o : No such file or directory.

I can't figure out how to fix that though?

I should further add that this is with avr-gcc 4.1.1 patched with your dwarf2 patch, binutils 2.17 and avrlibc 1.4.4

Also crts2333.o is present under /usr/local/avr/lib

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you configure the compiler also with --prefix=/usr/local/avr?
It seems to me you didn't.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Joerg, the output from avr-gcc -v is:

Target: avr
Configured with: ../configure --target=avr --prefix=/usr/local/avr --enable-languages=c --with-stabs -with-elf --with-dwarf2 --disable-libssp --disable-libada --disable-nls
Thread model: single
gcc version 4.1.1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It would appear that for some reason it is searching /usr/local/avr/avr for the include and lib directories. I noticed while doing another compile of gcc references to /usr/local/avr/avr/include which didn't seem right as that folder does not exist in a std install. I am compiling again, and will attach the compile time text if it is of any use.

Anyway, I am happy, as I now have a compiler that is working for me.

cp -r /usr/local/avr/lib /usr/local/avr/avr
and
cp -r /usr/local/avr/include /usr/local/avr/include

did the trick for me so that I do not need to use -I, and linking now works okay (well I've only tested the 90s2333 device so far actually)

Thanks for all your help so far.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a pointer to the problem I think:

prefix.o version.o ../libcpp/libcpp.a ../libiberty/libiberty.a
/usr/src/gcc-4.1.1/avrtestbuild/./gcc/xgcc -B/usr/src/gcc-4.1.1/avrtestbuild/./gcc/ -B/usr/local/avr/avr/bin/ -B/usr/local/avr/avr/lib/ -isystem /usr/local/avr/avr/include -isystem /usr/local/avr/avr/sys-include -dumpspecs > tmp-specs
mv tmp-specs specs

Though I am guessing totally really. Please find the configure and make logs attached.

Configure line is as before:

../configure --target=avr --prefix=/usr/local/avr --enable-languages=c --with-stabs --with-elf --with-dwarf2 --disable-libssp --disable-libada --disable-nls

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please use strace -f to see where the compiler is actually looking
for these files.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I traced a compile after removing the files I copied to /usr/local/avr/avr/include and usr/local/avr/avr/lib

Please find the complete log file attached. demo.c is next to nothing...

#include 
#include 
#include 

int main (void)
{
    while(1)
    {
    }

    return (0);
}

Best Regards,
Brian.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
[pid 18394] open("/usr/local/avr/lib/gcc/avr/4.1.1/../../../../avr/include/inttypes.h", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)

It expects to find the file in /usr/local/avr/avr/include/inttypes.h,
when it is actually in /usr/local/avr/include/inttypes.h.

Somehow, the prefix settings don't match.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Should I report this as a bug anywhere?

This is gentoo linux 2.6 kernel and is running in a vmware session, but vmware seems very stable for all other things I've done in it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I still believe it's a problem in your local build (which I figured
you did yourself, didn't you?).

After comparing with my own installation, it appears to me the
installed avr-libc version is configured for a prefix of /usr/local
rather than /usr/local/avr, as otherwise it would indeed install
its header files under /usr/local/avr/avr/include.

Btw., for Gentoo, did you try using their official portage packages?
Last time I've been in contact with their AVR portage maintainer,
he gave me the impression of being very eager to keep his stuff
up to date.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

Last Edited: Mon. Jul 10, 2006 - 01:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, it's a build I have done. I could start from scratch and rebuild everything again to make sure. But during this process I have done that several times already. Once more can't hurt.

I did not use portage, I built from the latest sources.. I'll do some more testing later on today.

I'll do a rebuild from scratch of everything then and see what I turn up. Thanks for the pointers.

Last Edited: Mon. Jul 10, 2006 - 01:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, my edit of the previous article crossed with your reply, so
please read again above. (I didn't expect you to be that fast ;-).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh dear. Its time to hang my head in shame...
From avrlibc-1.4.4/config.log:
command line was
$ ./configure --target=/usr/local/avr --build=i686-pc-linux-gnu --host=avr

What a waste of time. Anyway, I have re-built gcc and it now works fine.

Thanks for all the pointers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Funny it let you go away with that target name. ;-)

Glad to hear it works now.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.