How to write GCC plugin to work with avr-gcc

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

Hi guys,

I have a gcc plugin which works for my simple test (non embedded) programs. And, I load the plugin as

g++ -fplugin=path_to_plugin_so/plugin.so -c test_prog.c

However, the end goal of my plugin is to work with avr-gcc for embedded programs.

In usual case, I build my simple embedded program (lets say em_prog.c) as

avr-gcc -mmcu=atmega8 em_prog.c

where atmega8 is the host micro-controller name.

My question is - how do I now make my plugin work with '-mmcu=atmega8' option and with avr-gcc?

I tried

g++ -fplugin=path_to_plugin_so/plugin.so -mmcu=atmega8 -c test_prog.c

and

avr-gcc -fplugin=path_to_plugin_so/plugin.so -mmcu=atmega8 -c test_prog.c

But none of these work.

Can someone please help me with it? I am badly stuck at this point.

Thanks and regards,
Sandeep.

Thanks and regards,
Sandeep K Chaudhary,
University of Waterloo, Canada.

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

Maybe the compiler driver (avr-gcc) does not pass on the -f to the compiler proper (avr-g++)?

Have you tried

avr-g++ -fplugin=path_to_plugin_so/plugin.so -mmcu=atmega8 -c test_prog.c

?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I had a quick look into the GCC docs and it seems the -plugin (and the whole plugin API) was introduced in 4.9.0.

What version of GCC is your avr-gcc based on? Did you build it yourself, or are you using e.g. the toolchain supplied by Atmel? If the latter: I don't think they are basing it on the latest GCC.

The next-to-latest Atmel toolchain 3.4.2 was based on GCC 4.7.2, which is a bit behind the 4.9.0.

I will not install toolchain 3.4.4 to check what it is based on, and as usual Atmels release procedures are lacking - there is nothing in the release notes next to the distribution which could tell us about it..

Do

avr-gcc --version

on a command prompt to get something like this:

avr-gcc (AVR_8_bit_GNU_Toolchain_3.4.2_992) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In there you see that my Atmel tool chain is based on 4.7.2.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

If you are into GCC internals, then mailing list gcc-help@gcc.gnu.org is a much better place than here.

You will have to be more specific about what "none of these work" means, how you configured your compiler, etc.

But with almost 100% certainty, this is pointless here.

avrfreaks does not support Opera. Profile inactive.

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

JohanEkdahl wrote:

I will not install toolchain 3.4.4 to check what it is based on, and as usual Atmels release procedures are lacking - there is nothing in the release notes next to the distribution which could tell us about it..

Atmel's 3.4.4 is based on GCC 4.8.1

Here's a snip from my own build of Atmels 3.4.4 sources.

$avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/local/avr/libexec/gcc/avr/4.8.1/lto-wrapper
Target: avr
Configured with: /home/bingo/1-Build-Avr-GCC/Atmel-3.4.4/builddir/src/gcc/configure LDFLAGS=-L/usr/local/avr/lib CPPFLAGS= --target=avr --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr/local/avr --libdir=/usr/local/avr/lib --enable-languages=c,c++ --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-avrlibc=yes --with-mpfr=/usr/local/avr --with-gmp=/usr/local/avr --with-mpc=/usr/local/avr --enable-fixed-point --with-pkgversion=AVR_8_bit_GNU_Toolchain_3.4.4-Bingo-_201406211801 --with-bugurl=http://www.atmel.com
Thread model: single
gcc version 4.8.1 (AVR_8_bit_GNU_Toolchain_3.4.4-Bingo-_201406211801) 

/Bingo

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

No, gcc has had plugin support for a while. I know plugins work on 4.7.x - I wrote one myself. But yes, the gcc-help mailing list is the right place to discuss this further.

Regards

Senthil

 

blog | website

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

Quote:

No, gcc has had plugin support for a while.

OK. I just did a dig around the GCC documentation re options. It seems to me that while plugins might have been around for a long time as you say, the -fplugin option was added quite recently. OR at least wasn't documented until quite recently.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Thanks a lot for the reply guys !

My avr-gcc is based on 4.8.2.

sandeep@ubuntu:~/ispec/tool/gcc_plugin/gimple$ avr-gcc --version
avr-gcc (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So if the latest avr-gcc is older than 4.9.0 then how do I get around this?

How can I know what version of gcc the latest avr-gcc is based on?

And, yeah - I did asking this on gcc-help@gcc.gnu.org but didn't get any response on this forum. That's why I asked it here.

Thanks and regards,
Sandeep K Chaudhary,
University of Waterloo, Canada.