Compile GCC on windows

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

I'm using an ATtiny2313 and compile it with WinAvr. When I looked to the results of the compiler, I found out the MOVW instruction wasn't used. With some search I found the patch: patch #4881.
So I decided to compile the compiler myself. I found the instructions from kai

I followed the instructions. I wanted to build the compiler first without the patch. Building binutils went fine, but got a problem with building GCC. When I type 'make', after a while there comes an error. It says:
"./tm.h:5:29: error: config/avr/avr.h: No such file or directory" After the a couple of other header files can't be found too.
I tried to search for this (type of) error, but couldn't find an helping answer.
The tutorial said to download only gcc-core-[Version].tar.bz2 and gcc-g++-[Version].tar.bz2. So I thought, I might be missing something. I tried downloading gcc-4.1.0.tar.bz2. But the error is still the same. So I went looking for the files in the directories.

tm.h is located inside "msys\1.0\home\HP_Eigenaar\gcc-4.1.0\host-i686-pc-mingw32\gcc\". The first include is "options.h" The compiler doesn't give an error on that file, as far as I can see. options.h is in the same directory as tm.h. After options.h is included, "config/avr/avr.h" is included. There is no config directory inside the directory where options.h and tm.h are. I located the file and it is in this directory: "msys\1.0\home\HP_Eigenaar\gcc-4.1.0\gcc\config\avr"

Now I'm out of ideas. I don't know how I can solve this problem. I might did something wrong, but can't figure out what. To be sure I didn't misspelled something, I tried every step twice, with deinstalling everything before I did it the second time.

Here follows some information, that might be usefull, don't have any idea what could help, so I'll give much info, that also might be useless ;)
OS is WinXP with SP2
Filesystem where MinGW and msys are installed is NTFS.
msys version 1.0.10
MinGW version 5.0.2
binutils version 2.16
gcc version 4.10

If someone has any idea what the problem can be, I would appreciate it much. If someone has another tutorial or guide how to compile gcc for AVR on windows, it would be nice too. I could try that :)

Thijs

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

Instruction for building AVR-GCC based on GCC 3.4.5 or GCC 4.1 can be found on my home page:
http://homepage.hispeed.ch/peter...

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

(quoted from pfleury's webpage)

Quote:
File: gcc-4.1.0/gcc/config/avr/avr.h

/* Offset from the frame pointer register value to the top of the stack. */
#define FRAME_POINTER_CFA_OFFSET(FNDECL) 0


Is anybody here familiar enough with AVR-GCC's ABI to be able to guarantee that the offset between the frame pointer and the cannonical frame address really is zero?

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

> "./tm.h:5:29: error: config/avr/avr.h: No such file or directory"

There appears to be a GNU make bug that triggers on MinGW.
Some macro that is never supposed to be null (IIRC it's
$(@D)) is null, so the argument to a -I option becomes null,
and the subsequent -I option will be misinterpreted as the
argument to the preceding -I. Thus, all header files that are
supposed to be found in the directory of the next option
won't be found.

This has been discussed already elsewhere, I think in
avr-gcc-list. You should be able to work around it by
editing the Makefile in question.

> Is anybody here familiar enough with AVR-GCC's
> ABI to be able to guarantee that the offset between
> the frame pointer and the cannonical frame address
> really is zero?

I'm not. Maybe Peter wants to comment on that?

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 for the tutorial pfleury!
It took me some time, but I finally managed to compile the GCC compiler!

I encounterd some problems, which I'll describe here.

I followed every step, but I was stuck at the make off gcc. I added the lines in avr.h. Configure works fine, but when I run make, I get an error. So I went looking for the makefile inside objdir/gcc. But I didn't see a gcc directory inside the objdir. There was a makefile inside the 'root' of objdir, but it doesn't contain "INCLUDE =" . The error I get is:

../../fixincludes/fixincl.c:28:22: sys/wait.h: No such file or directory
In file included from ../../fixincludes/fixincl.c:101:
../../fixincludes/fixincl.x:76: warning: string length `4662' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:224: warning: string length `552' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:269: warning: string length `532' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:313: warning: string length `808' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:399: warning: string length `5139' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:2419: warning: string length `729' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.x:7223: warning: string length `575' is greater than the length `509' ISO C89 compilers are required to support
../../fixincludes/fixincl.c: In function `main':
../../fixincludes/fixincl.c:115: warning: implicit declaration of function `isatty'
../../fixincludes/fixincl.c:129: warning: implicit declaration of function `exit'

And then a lot more warnings and errors inside fixincl.c

So this didn't seem to work. I tried to find information, but couldn't really find it.

In a desperate attempt, I didn't add the line to avr.h. And didn't compile with --with-dwarf2. The 'old' error (couldn't find config/avr/avr.h) showed up. But now there was a gcc directory. I removed '-I$(@D)' from the INCLUDE line in the makefile, and run make again. I received an error that it couldn't find avr-ar.exe. I went looking inside c:\avrgcc, but the executable was there. So I added the pad C:\avrgcc\bin to the PATH environment variable, and it compiled fine, finally :D

Only thing is, I can't used dwarf2 for debugging. That isn't a huge problem, but I would be nice to make it work too. If someone knows what the problem is, I'd like to know.

And a tip to pfleury, it might be wise to but the line "Add c:\avrgcc\bin to your PATH environment variable." earlier in your article. Although I now realize that I allready removed the winavr from the PATH environment variable. But if I didn't, it could work too, because it used the old avr-ar.exe, right? I don't know if it that is ok or not.

Thanks for the help :)

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

@Thijs
I did't had these problems when compiling with dfwarf2

>"Add c:\avrgcc\bin to your PATH
Yes you are right, I will update my instructions.

Jörg wrote:
>I' not. Maybe Peter wants to comment on that?

The #define FRAME_POINTER_CFA_OFFSET(FNDECL) 0 statement is not my idea,
this has beed suggested in GCC bug 26015 and 26504, as described on my home page.
http://gcc.gnu.org/bugzilla/show...

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

I saw that discussion in the GCC bug database as well. The original patch was used to allow GCC 4.1 targeting the VAX architecture to build with support for dwarf2 debug info.

I've been hesitant to try applying that fix on the AVR target myself until I saw some confirmation that AVR-GCC's ABI also works the same way. It's one thing for the compiler to build without any warnings. It's another thing entirely for the debug info that it spits out to be accurate.

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

I recompiled everything and it works fine now. Thanks for all the help and the nice guide :)

Thijs