17

I'm trying to build GCC for use with an AVR microcontroller and avr-ada, and I've hit a roadblock caused by my regular compiler being too picky about the version I needed for the AVR. I get the following warning, which in turn causes GCC or Make to report an error:

gcc -c -g -O2 -gnatpg -gnata -nostdinc -I- -I. -Iada
  -I../../gcc/ada ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o
exp_ch5.adb:177:16: warning: function "Has_Address_Clause" is not referenced
make[2]: *** [ada/exp_ch5.o] Error 1
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2

Is there a way to instruct GCC or Make to not fail on warnings?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dr. Watson
  • 3,752
  • 4
  • 32
  • 43
  • 1
    I don't think any of the debug options result in treating warnings as errors (at least not that I could find), is that the full output? – Tim Post Mar 10 '10 at 03:15
  • Normally (when not using `-gnatg` to apply all the checks required for a compiler build), GNAT (Ada in GCC) uses `-gnatwe` to treat warnings as errors, and `-gnatwn` to cancel that – Simon Wright Oct 23 '22 at 15:58

7 Answers7

52

Try make -k instead of just make. That will 'continue' rather than stop.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
15

As an alternative to diving into the build system, try setting -Wno-error in CFLAGS, which you should be able to do through the environment (or at configure time, if using the GNU build system).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jack
  • 151
  • 2
7

The trigger here is the -gnatpg (actually, the -gnatg): this is the "GNAT implementation mode (used for compiling GNAT units)". -gnatp means "suppress all checks".

I'm not sure of the full effect of -gnatg, though it certainly causes warnings to be treated as errors -- like -Werror -- at any rate while building the compiler itself; I think I remember seeing non-fatal warnings while building the RTS.

One possibility would be to compile just exp_ch5.adb by hand without -gnatg; the command you list was issued at gcc/, so

$ cd gcc
$ gcc -c -g -O2 -gnatp -gnata -nostdinc -I- -I. -Iada -I../../gcc/ada \
  ../../gcc/ada/exp_ch5.adb -o ada/exp_ch5.o

Then back up one level, and 'make' again.

This is a cross-compiler, so you won't (I hope!) need to repeat this for all three stages of a full build.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
5

It seems the -Werror flag is set in the Makefile. Maybe you can look for the CFLAGS options in the Makefile and remove the -Werror flag. The Werror flag will make all warnings into errors.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ZelluX
  • 69,107
  • 19
  • 71
  • 104
3

In general, it is not a good idea to ignore warnings from your compiler. However, if this is a portion of a larger make process there is likely a -Werror flag inserted earlier in the sequence. Start by looking for that.

After looking around, there seems to be a wealth of flags to control warnings while compiling Ada code. For instance, -gnatwF will Suppress warnings on unreferenced formals according to this guide. Possibly the switch you require can be found in the list provided there.

ezpz
  • 11,767
  • 6
  • 38
  • 39
  • Yeah, nothing in what he pasted would have resulted in -Werror being turned on. It had to be prior to the excerpt. – Tim Post Mar 10 '10 at 03:49
  • 1
    I know its not a good idea, and I tried building an older version of gcc/gnat (gcc-4.3.2) just so that I could build the AVR gcc/gnat (also gcc-4.3.2), but I was running into the exact same problem there too. After talking with the project owner, he told me my system Ada compiler (gcc-4.3.4) "smells too new" for the code base, and my options were to hack the source code or try to override the fail or warning. – Dr. Watson Mar 10 '10 at 14:01
  • Well, I remember dealing with Ada for a brief time and, for me, the approach would have to be augmenting the build. As I recall Ada is right finicky about things. – ezpz Mar 10 '10 at 14:52
  • Again, I agree with what you are saying. I'll try some of the options you listed as well as others in this thread when I get home today, but I'm learning towards just using the Windows version since I can easily get a binary and get to work. – Dr. Watson Mar 10 '10 at 15:19
1

In gcc configure you can add --disable-werror.

Though it's advisable to seek out a proper patch first.

Bob Blogge
  • 186
  • 9
0

Put "pragma warnings(off, "...")" into the offending parts of your code.

See http://www.adacore.com/2007/11/19/ada-gem-18/.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user275257
  • 41
  • 1